@codady/coax 0.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.
package/script-note.js ADDED
@@ -0,0 +1,34 @@
1
+
2
+ /**
3
+ * Last modified: 2026/01/04 15:27:02
4
+ */
5
+ import { readFileSync } from 'fs';
6
+ import { fileURLToPath } from 'url';
7
+ import { dirname, resolve } from 'path';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = dirname(__filename);
11
+
12
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, './package.json'), 'utf8'));
13
+
14
+ const now = new Date();
15
+ const times = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
16
+
17
+ const note = `
18
+ /*!
19
+ * @since Last modified: ${times}
20
+ * @name Coax event management system.
21
+ * @version ${pkg.version}
22
+ * @author AXUI development team <3217728223@qq.com>
23
+ * @description Coax is a custom web component that enables syntax highlighting for various programming languages inside your HTML documents.
24
+ * @see {@link https://coax.axui.cn|Official website}
25
+ * @see {@link https://github.com/codady/coax/issues|github issues}
26
+ * @see {@link https://gitee.com/codady/coax/issues|Gitee issues}
27
+ * @see {@link https://www.npmjs.com/package/@codady/coax|NPM}
28
+ * @issue QQ Group No.1:952502085
29
+ * @copyright This software supports the MIT License, allowing free learning and commercial use, but please retain the terms 'coax', 'Coax' and 'COAX' within the software.
30
+ * @license MIT license
31
+ */
32
+ `;
33
+
34
+ export default note;
package/src/Coax.js ADDED
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Last modified: 2026/01/04 15:50:55
3
+ */
4
+ class Coax extends HTMLElement {
5
+ // A static Map to hold the configuration for different languages
6
+ static languages = new Map();
7
+ // Raw code as text from the HTML content
8
+ rawCode;
9
+ constructor() {
10
+ super();
11
+ // Attach a Shadow DOM to the custom element
12
+ this.attachShadow({ mode: 'open' });
13
+ // Remove leading/trailing whitespace from the raw code content
14
+ this.rawCode = this.textContent?.replace(/^\s*\n|\n\s*$/g, '') || '';
15
+ }
16
+ /**
17
+ * Registers a new language with a set of syntax highlighting rules.
18
+ * @param name - The name of the programming language.
19
+ * @param config - Configuration for the language, including rules, theme, and optional CSS.
20
+ */
21
+ static register(name, { rules, theme = {}, internalCss = '', cssPrefix = '' }) {
22
+ // Store the language configuration in the static map
23
+ this.languages.set(name, { rules, theme, internalCss, cssPrefix });
24
+ // Render the highlighted code for all elements with the registered language
25
+ document.querySelectorAll('ax-code').forEach(el => {
26
+ if (el.getAttribute('lang') === name)
27
+ el.render();
28
+ });
29
+ }
30
+ // Called when the element is connected to the DOM
31
+ connectedCallback() { this.render(); }
32
+ // Observed attributes for changes
33
+ static get observedAttributes() { return ['lang', 'height', 'max-height']; }
34
+ /**
35
+ * Called when any of the observed attributes change.
36
+ */
37
+ attributeChangedCallback() {
38
+ this.render();
39
+ }
40
+ /**
41
+ * Renders the highlighted code within the shadow DOM.
42
+ */
43
+ render() {
44
+ // Get language name, fallback to 'js' if not provided
45
+ const lang = this.getAttribute('lang') || 'js',
46
+ // Get the language configuration
47
+ config = Coax.languages.get(lang),
48
+ // Default to language name if no prefix is set
49
+ cssPrefix = config?.cssPrefix || lang, height = this.getAttribute('height'), maxHeight = this.getAttribute('max-height');
50
+ let highlightedCode = '', dynamicStyles = '';
51
+ if (config) {
52
+ //Generate the highlighted HTML by applying the syntax rules
53
+ const combinedRegex = new RegExp(config.rules.map((r) => `(${r.reg.source})`).join('|'), 'g'), escaped = this.rawCode.replace(/[&<>]/g, m => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[m]));
54
+ // Replace code with highlighted syntax
55
+ highlightedCode = escaped.replace(combinedRegex, (match, ...args) => {
56
+ const index = args.findIndex(val => val !== undefined);
57
+ return index !== -1 && config.rules[index] ? `<span class="ax-${cssPrefix}-${config.rules[index].name}">${match}</span>` : match;
58
+ });
59
+ //Generate dynamic CSS classes for each syntax rule
60
+ // 为 rules 中的每一个 name 生成类似 .hl-name { color: var(--ax-code-name); }
61
+ dynamicStyles = config.rules.map((rule) => `
62
+ .ax-${cssPrefix}-${rule.name} { color: var(--ax-${cssPrefix}-${rule.name}); }
63
+ `).join('\n');
64
+ }
65
+ else {
66
+ // If no config, display raw code without highlighting
67
+ highlightedCode = this.rawCode;
68
+ }
69
+ //Generate CSS theme variables if a theme is provided
70
+ const themeVars = config?.theme
71
+ ? Object.entries(config.theme).map(([k, v]) => `--ax-${cssPrefix}-${k}: ${v};`).join('\n')
72
+ : '';
73
+ // Set the inner HTML of the shadow root, including styles and highlighted code
74
+ this.shadowRoot.innerHTML = `
75
+ <style>
76
+ :host {
77
+ ${themeVars}
78
+
79
+ font-size: var(--ax-code-fs,14px);
80
+ display: block;
81
+ padding: var(--ax-code-p,1em);
82
+ box-sizing:border-box;
83
+ line-height: var(--ax-code-lh,1.5);
84
+ background-color:var(--ax-code-bg,rgba(0,0,0,0.02));
85
+ color:var(--ax-code-c,#333);
86
+ border:var(--ax-code-bw,1px) solid var(--ax-code-bc,rgba(0,0,0,0.08));
87
+ height:${height || 'var(--ax-code-h,auto)'};
88
+ max-height:${maxHeight || 'var(--ax-code-mh,500px)'};
89
+ overflow:auto;
90
+ transition: border-color 0.3s ease,color 0.3s ease;
91
+ border-radius: var(--ax-code-r,9px);
92
+ }
93
+ pre,code{
94
+ font-family:"Consolas", "Monaco", "Andale Mono", "Ubuntu Mono", "monospace", "microsoft yahei", "Microsoft JhengHei", "Yu Mincho", "simsun";
95
+ margin:0;
96
+ padding:0;
97
+ }
98
+
99
+
100
+ /* Dynamically generated styles for syntax highlighting */
101
+ ${dynamicStyles}
102
+
103
+ /* Inject additional CSS specific to the language if provided */
104
+ ${config?.internalCss || ''}
105
+ </style>
106
+ <pre><code>${highlightedCode}</code></pre>`;
107
+ }
108
+ }
109
+ customElements.define('ax-code', Coax);
110
+ Coax.register('html', {
111
+ rules: [
112
+ { name: 'comment', reg: /&lt;!--[\s\S]*?--&gt;/ },
113
+ { name: 'doctype', reg: /&lt;!DOCTYPE[\s\S]*?&gt;/i },
114
+ // 匹配标签名: <div, </div
115
+ { name: 'tag', reg: /&lt;\/?[a-zA-Z0-9]+/ },
116
+ // 匹配属性名: class=
117
+ { name: 'attr', reg: /[a-zA-Z-]+(?=\s*=\s*)/ },
118
+ // 匹配属性值: "value"
119
+ { name: 'string', reg: /(['"])(?:\\.|[^\\])*?\1/ },
120
+ // 匹配标签闭合: >, />
121
+ { name: 'bracket', reg: /\/?&gt;/ }
122
+ ],
123
+ //添加root变量:--ax-html-keyword
124
+ /* theme: {
125
+ 'tag': '#e06c75', // 红色
126
+ 'attr': '#d19a66', // 橙色
127
+ 'bracket': '#abb2bf', // 灰色
128
+ 'doctype': '#56b6c2' // 青色
129
+ } */
130
+ });
131
+ Coax.register('css', {
132
+ rules: [
133
+ { name: 'comment', reg: /\/\*[\s\S]*?\*\// },
134
+ { name: 'value', reg: /(?:'|")(?:\\.|[^\\'"\b])*?(?:'|")/ },
135
+ { name: 'func', reg: /[a-z-]+\(?=/ },
136
+ { name: 'property', reg: /[a-z-]+(?=\s*:)/ },
137
+ { name: 'selector', reg: /[.#a-z0-9, \n\t>:+()_-]+(?=\s*\{)/i },
138
+ { name: 'unit', reg: /(?<=\d)(px|em|rem|%|vh|vw|ms|s|deg)/ },
139
+ { name: 'number', reg: /\b\d+(\.\d+)?\b/ },
140
+ { name: 'punct', reg: /[{}();:]/ }
141
+ ],
142
+ //添加root变量:--ax-code-keyword
143
+ theme: {
144
+ 'type': '#61afef', // 蓝色选择器
145
+ 'keyword': '#d19a66', // 橙色属性名
146
+ 'string': '#98c379', // 绿色属性值
147
+ 'op': '#abb2bf' // 灰色符号
148
+ },
149
+ internalCss: `
150
+ .ax-css-string { color: var(--ax-code-string); }
151
+ .ax-css-string::first-letter { color: var(--ax-code-c); }
152
+ `
153
+ });
154
+ Coax.register('js', {
155
+ rules: [
156
+ { name: 'comment', reg: /\/\/[^\n]*|\/\*[\s\S]*?\*\// },
157
+ { name: 'string', reg: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/ },
158
+ { name: 'keyword', reg: /\b(async|await|break|case|catch|class|const|continue|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|this|throw|try|typeof|var|while|with|yield|let|static)\b/ },
159
+ { name: 'builtin', reg: /\b(console|window|document|Math|JSON|true|false|null|undefined|Object|Array|Promise)\b/ },
160
+ { name: 'number', reg: /\b\d+\b/ },
161
+ { name: 'func', reg: /\b[a-zA-Z_]\w*(?=\s*\()/ },
162
+ { name: 'op', reg: /[+\-*/%=<>!&|^~]+/ }
163
+ ],
164
+ /* theme: {
165
+ 'keyword': '#c678dd',
166
+ 'func': '#61afef',
167
+ 'builtin': '#e5c07b'
168
+ } */
169
+ });
170
+ Coax.register('ts', {
171
+ rules: [
172
+ { name: 'comment', reg: /\/\/[^\n]*|\/\*[\s\S]*?\*\// },
173
+ { name: 'string', reg: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/ },
174
+ { name: 'decorator', reg: /@[a-zA-Z_]\w*/ },
175
+ { name: 'keyword', reg: /\b(abstract|as|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|package|private|protected|public|readonly|return|set|static|super|switch|this|throw|try|type|typeof|var|while|with|yield)\b/ },
176
+ { name: 'builtin', reg: /\b(any|boolean|never|number|string|symbol|unknown|void|undefined|null|boolean|true|false|console|window|document)\b/ },
177
+ { name: 'type', reg: /\b[A-Z]\w*\b/ },
178
+ { name: 'number', reg: /\b\d+\b/ },
179
+ { name: 'func', reg: /\b[a-zA-Z_]\w*(?=\s*\()/ },
180
+ { name: 'op', reg: /(\?\.|![:\.]|[+\-*/%=<>!&|^~]+)/ }
181
+ ],
182
+ /* theme: {
183
+ 'decorator': '#e06c75',
184
+ 'type': '#4dbed9',
185
+ 'builtin': '#d19a66',
186
+ 'keyword': '#c678dd'
187
+ },
188
+ internalCss: `
189
+ .ax-ts-type { font-weight: bold; }
190
+ ` */
191
+ });
192
+ export {};
package/src/Coax.ts ADDED
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Last modified: 2026/01/04 15:50:55
3
+ */
4
+
5
+
6
+ // Define the structure for the language configuration
7
+ export interface LanguageConfig {
8
+ rules: { name: string, reg: RegExp }[]; // Array of syntax highlighting rules
9
+ theme?: Record<string, string>; // Optional theme with color values
10
+ internalCss?: string; // Optional internal CSS for language-specific styles
11
+ cssPrefix?: string; // Optional CSS prefix for class names
12
+ }
13
+
14
+ class Coax extends HTMLElement {
15
+ // A static Map to hold the configuration for different languages
16
+ static languages = new Map();
17
+ // Raw code as text from the HTML content
18
+ private rawCode: string;
19
+
20
+ constructor() {
21
+ super();
22
+ // Attach a Shadow DOM to the custom element
23
+ this.attachShadow({ mode: 'open' });
24
+ // Remove leading/trailing whitespace from the raw code content
25
+ this.rawCode = this.textContent?.replace(/^\s*\n|\n\s*$/g, '') || '';
26
+ }
27
+ /**
28
+ * Registers a new language with a set of syntax highlighting rules.
29
+ * @param name - The name of the programming language.
30
+ * @param config - Configuration for the language, including rules, theme, and optional CSS.
31
+ */
32
+ static register(name: string, { rules, theme = {}, internalCss = '', cssPrefix = '' }: LanguageConfig): void {
33
+ // Store the language configuration in the static map
34
+ this.languages.set(name, { rules, theme, internalCss, cssPrefix });
35
+ // Render the highlighted code for all elements with the registered language
36
+ document.querySelectorAll('ax-code').forEach(el => {
37
+ if (el.getAttribute('lang') === name) (el as any).render();
38
+ });
39
+ }
40
+ // Called when the element is connected to the DOM
41
+ connectedCallback() { this.render(); }
42
+
43
+ // Observed attributes for changes
44
+ static get observedAttributes() { return ['lang', 'height', 'max-height']; }
45
+
46
+ /**
47
+ * Called when any of the observed attributes change.
48
+ */
49
+ attributeChangedCallback() {
50
+ this.render();
51
+ }
52
+ /**
53
+ * Renders the highlighted code within the shadow DOM.
54
+ */
55
+ render() {
56
+ // Get language name, fallback to 'js' if not provided
57
+ const lang = this.getAttribute('lang') || 'js',
58
+ // Get the language configuration
59
+ config = Coax.languages.get(lang),
60
+ // Default to language name if no prefix is set
61
+ cssPrefix = config?.cssPrefix || lang,
62
+ height = this.getAttribute('height'),
63
+ maxHeight = this.getAttribute('max-height');
64
+
65
+ let highlightedCode = '',
66
+ dynamicStyles = '';
67
+
68
+ if (config) {
69
+
70
+ //Generate the highlighted HTML by applying the syntax rules
71
+ const combinedRegex = new RegExp(config.rules.map((r: any) => `(${r.reg.source})`).join('|'), 'g'),
72
+ escaped = this.rawCode.replace(/[&<>]/g, m => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[m] as string));
73
+ // Replace code with highlighted syntax
74
+ highlightedCode = escaped.replace(combinedRegex, (match, ...args) => {
75
+ const index = args.findIndex(val => val !== undefined);
76
+ return index !== -1 && config.rules[index] ? `<span class="ax-${cssPrefix}-${config.rules[index].name}">${match}</span>` : match;
77
+ });
78
+
79
+ //Generate dynamic CSS classes for each syntax rule
80
+ // 为 rules 中的每一个 name 生成类似 .hl-name { color: var(--ax-code-name); }
81
+ dynamicStyles = config.rules.map((rule: any) => `
82
+ .ax-${cssPrefix}-${rule.name} { color: var(--ax-${cssPrefix}-${rule.name}); }
83
+ `).join('\n');
84
+ } else {
85
+ // If no config, display raw code without highlighting
86
+ highlightedCode = this.rawCode;
87
+ }
88
+
89
+ //Generate CSS theme variables if a theme is provided
90
+ const themeVars = config?.theme
91
+ ? Object.entries(config.theme).map(([k, v]) => `--ax-${cssPrefix}-${k}: ${v};`).join('\n')
92
+ : '';
93
+ // Set the inner HTML of the shadow root, including styles and highlighted code
94
+ (this.shadowRoot as any).innerHTML = `
95
+ <style>
96
+ :host {
97
+ ${themeVars}
98
+
99
+ font-size: var(--ax-code-fs,14px);
100
+ display: block;
101
+ padding: var(--ax-code-p,1em);
102
+ box-sizing:border-box;
103
+ line-height: var(--ax-code-lh,1.5);
104
+ background-color:var(--ax-code-bg,rgba(0,0,0,0.02));
105
+ color:var(--ax-code-c,#333);
106
+ border:var(--ax-code-bw,1px) solid var(--ax-code-bc,rgba(0,0,0,0.08));
107
+ height:${height || 'var(--ax-code-h,auto)'};
108
+ max-height:${maxHeight || 'var(--ax-code-mh,500px)'};
109
+ overflow:auto;
110
+ transition: border-color 0.3s ease,color 0.3s ease;
111
+ border-radius: var(--ax-code-r,9px);
112
+ }
113
+ pre,code{
114
+ font-family:"Consolas", "Monaco", "Andale Mono", "Ubuntu Mono", "monospace", "microsoft yahei", "Microsoft JhengHei", "Yu Mincho", "simsun";
115
+ margin:0;
116
+ padding:0;
117
+ }
118
+
119
+
120
+ /* Dynamically generated styles for syntax highlighting */
121
+ ${dynamicStyles}
122
+
123
+ /* Inject additional CSS specific to the language if provided */
124
+ ${config?.internalCss || ''}
125
+ </style>
126
+ <pre><code>${highlightedCode}</code></pre>`;
127
+ }
128
+ }
129
+
130
+ customElements.define('ax-code', Coax);
131
+
132
+
133
+ Coax.register('html', {
134
+ rules: [
135
+ { name: 'comment', reg: /&lt;!--[\s\S]*?--&gt;/ },
136
+ { name: 'doctype', reg: /&lt;!DOCTYPE[\s\S]*?&gt;/i },
137
+ // 匹配标签名: <div, </div
138
+ { name: 'tag', reg: /&lt;\/?[a-zA-Z0-9]+/ },
139
+ // 匹配属性名: class=
140
+ { name: 'attr', reg: /[a-zA-Z-]+(?=\s*=\s*)/ },
141
+ // 匹配属性值: "value"
142
+ { name: 'string', reg: /(['"])(?:\\.|[^\\])*?\1/ },
143
+ // 匹配标签闭合: >, />
144
+ { name: 'bracket', reg: /\/?&gt;/ }
145
+ ],
146
+ //添加root变量:--ax-html-keyword
147
+ /* theme: {
148
+ 'tag': '#e06c75', // 红色
149
+ 'attr': '#d19a66', // 橙色
150
+ 'bracket': '#abb2bf', // 灰色
151
+ 'doctype': '#56b6c2' // 青色
152
+ } */
153
+ });
154
+
155
+ Coax.register('css', {
156
+ rules: [
157
+ { name: 'comment', reg: /\/\*[\s\S]*?\*\// },
158
+ { name: 'value', reg: /(?:'|")(?:\\.|[^\\'"\b])*?(?:'|")/ },
159
+ { name: 'func', reg: /[a-z-]+\(?=/ },
160
+ { name: 'property', reg: /[a-z-]+(?=\s*:)/ },
161
+ { name: 'selector', reg: /[.#a-z0-9, \n\t>:+()_-]+(?=\s*\{)/i },
162
+ { name: 'unit', reg: /(?<=\d)(px|em|rem|%|vh|vw|ms|s|deg)/ },
163
+ { name: 'number', reg: /\b\d+(\.\d+)?\b/ },
164
+ { name: 'punct', reg: /[{}();:]/ }
165
+ ],
166
+ //添加root变量:--ax-code-keyword
167
+ theme: {
168
+ 'type': '#61afef', // 蓝色选择器
169
+ 'keyword': '#d19a66', // 橙色属性名
170
+ 'string': '#98c379', // 绿色属性值
171
+ 'op': '#abb2bf' // 灰色符号
172
+ },
173
+ internalCss: `
174
+ .ax-css-string { color: var(--ax-code-string); }
175
+ .ax-css-string::first-letter { color: var(--ax-code-c); }
176
+ `
177
+ });
178
+
179
+ Coax.register('js', {
180
+ rules: [
181
+ { name: 'comment', reg: /\/\/[^\n]*|\/\*[\s\S]*?\*\// },
182
+ { name: 'string', reg: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/ },
183
+ { name: 'keyword', reg: /\b(async|await|break|case|catch|class|const|continue|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|this|throw|try|typeof|var|while|with|yield|let|static)\b/ },
184
+ { name: 'builtin', reg: /\b(console|window|document|Math|JSON|true|false|null|undefined|Object|Array|Promise)\b/ },
185
+ { name: 'number', reg: /\b\d+\b/ },
186
+ { name: 'func', reg: /\b[a-zA-Z_]\w*(?=\s*\()/ },
187
+ { name: 'op', reg: /[+\-*/%=<>!&|^~]+/ }
188
+ ],
189
+ /* theme: {
190
+ 'keyword': '#c678dd',
191
+ 'func': '#61afef',
192
+ 'builtin': '#e5c07b'
193
+ } */
194
+ });
195
+
196
+ Coax.register('ts', {
197
+ rules: [
198
+ { name: 'comment', reg: /\/\/[^\n]*|\/\*[\s\S]*?\*\// },
199
+ { name: 'string', reg: /(?:'|"|`)(?:\\.|[^\\'"\b])*?(?:'|"|`)/ },
200
+ { name: 'decorator', reg: /@[a-zA-Z_]\w*/ },
201
+ { name: 'keyword', reg: /\b(abstract|as|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|package|private|protected|public|readonly|return|set|static|super|switch|this|throw|try|type|typeof|var|while|with|yield)\b/ },
202
+ { name: 'builtin', reg: /\b(any|boolean|never|number|string|symbol|unknown|void|undefined|null|boolean|true|false|console|window|document)\b/ },
203
+ { name: 'type', reg: /\b[A-Z]\w*\b/ },
204
+ { name: 'number', reg: /\b\d+\b/ },
205
+ { name: 'func', reg: /\b[a-zA-Z_]\w*(?=\s*\()/ },
206
+ { name: 'op', reg: /(\?\.|![:\.]|[+\-*/%=<>!&|^~]+)/ }
207
+ ],
208
+ /* theme: {
209
+ 'decorator': '#e06c75',
210
+ 'type': '#4dbed9',
211
+ 'builtin': '#d19a66',
212
+ 'keyword': '#c678dd'
213
+ },
214
+ internalCss: `
215
+ .ax-ts-type { font-weight: bold; }
216
+ ` */
217
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+ /* Projects */
5
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
+ /* Language and Environment */
12
+ "target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
+ //"lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
15
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
16
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
20
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
21
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
22
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24
+ /* Modules */
25
+ "module": "es2020", /* Specify what module code is generated. */
26
+ // "rootDir": "./", /* Specify the root folder within your source files. */
27
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
28
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
30
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
31
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
32
+ "types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
33
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
34
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
35
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
36
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
37
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
38
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
39
+ // "resolveJsonModule": true, /* Enable importing .json files. */
40
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
41
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
42
+ /* JavaScript Support */
43
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
44
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
45
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
52
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
53
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
54
+ "removeComments": false, /* Disable emitting comments. */
55
+ // "noEmit": true, /* Disable emitting files from a compilation. */
56
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
57
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
58
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
59
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
60
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+ /* Interop Constraints */
71
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
72
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
73
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
+ /* Type Checking */
78
+ "strict": true, /* Enable all strict type-checking options. */
79
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
80
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
81
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
82
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
83
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
84
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
85
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
86
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
87
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
88
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
89
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
90
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
91
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
92
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
93
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
94
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
95
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
96
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
97
+ /* Completeness */
98
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
99
+ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
100
+ },
101
+ // "include": [
102
+ //"src/",
103
+ //"types/",
104
+ //], /*Only compile files in the 'src/scripts' directory 仅编译'src/scripts'目录中的文件*/
105
+ "exclude": [
106
+ "node_modules"
107
+ ],
108
+ }