aboutsummaryrefslogtreecommitdiff
path: root/doc/docs
diff options
context:
space:
mode:
authorDania Rifki <atomicnumberphi@gmail.com>2026-03-25 23:22:29 +0800
committerLi Jin <dragon-fly@qq.com>2026-03-25 23:39:00 +0800
commitffdbbbd3e286d7440af411b475c5a13d49897898 (patch)
tree93e868287b83b6e736c7caa37c3a0479c668ab08 /doc/docs
parente15bd04ae6e5d7d7d31b3aa54a23d402349f3145 (diff)
downloadyuescript-ffdbbbd3e286d7440af411b475c5a13d49897898.tar.gz
yuescript-ffdbbbd3e286d7440af411b475c5a13d49897898.tar.bz2
yuescript-ffdbbbd3e286d7440af411b475c5a13d49897898.zip
Code Cleanup
Also Bump Dependencies
Diffstat (limited to 'doc/docs')
-rw-r--r--doc/docs/.vitepress/config.mts1
-rwxr-xr-xdoc/docs/.vitepress/theme/components/CompilerModal.vue2
-rwxr-xr-xdoc/docs/.vitepress/theme/components/YueCompiler.vue285
-rwxr-xr-xdoc/docs/.vitepress/theme/components/YueDisplay.vue8
4 files changed, 117 insertions, 179 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts
index 1ebc5cc..5dfb741 100644
--- a/doc/docs/.vitepress/config.mts
+++ b/doc/docs/.vitepress/config.mts
@@ -537,6 +537,7 @@ export default defineConfig({
537 var s = document.createElement('script'); 537 var s = document.createElement('script');
538 s.src = '${withBase("/js/yuescript.js")}'; 538 s.src = '${withBase("/js/yuescript.js")}';
539 s.async = true; 539 s.async = true;
540 s.onerror = loadStub;
540 document.head.appendChild(s); 541 document.head.appendChild(s);
541})();`, 542})();`,
542 ], 543 ],
diff --git a/doc/docs/.vitepress/theme/components/CompilerModal.vue b/doc/docs/.vitepress/theme/components/CompilerModal.vue
index 19d5830..62fcd95 100755
--- a/doc/docs/.vitepress/theme/components/CompilerModal.vue
+++ b/doc/docs/.vitepress/theme/components/CompilerModal.vue
@@ -60,7 +60,7 @@ export default {
60 width: min(90vw, 1100px); 60 width: min(90vw, 1100px);
61 max-height: 90vh; 61 max-height: 90vh;
62 overflow: auto; 62 overflow: auto;
63 background: #ffffff; 63 background: var(--vp-c-bg);
64 box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); 64 box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
65} 65}
66</style> 66</style>
diff --git a/doc/docs/.vitepress/theme/components/YueCompiler.vue b/doc/docs/.vitepress/theme/components/YueCompiler.vue
index afbf018..4477f22 100755
--- a/doc/docs/.vitepress/theme/components/YueCompiler.vue
+++ b/doc/docs/.vitepress/theme/components/YueCompiler.vue
@@ -41,165 +41,96 @@ import { history, indentWithTab } from "@codemirror/commands";
41import { defaultKeymap, historyKeymap } from "@codemirror/commands"; 41import { defaultKeymap, historyKeymap } from "@codemirror/commands";
42import { simpleMode } from "@codemirror/legacy-modes/mode/simple-mode"; 42import { simpleMode } from "@codemirror/legacy-modes/mode/simple-mode";
43 43
44/* shikijs/themes/light-plus: editor.background #FFFFFF, editor.foreground #000000 */ 44function createEditorTheme({ bg, fg, gutterColor, selectionBg, cursorColor, matchingBracketBg, dark }) {
45const lightPlusTheme = EditorView.theme( 45 return EditorView.theme(
46 { 46 {
47 "&": { 47 "&": {
48 height: "100%", 48 height: "100%",
49 backgroundColor: "#FFFFFF", 49 backgroundColor: bg,
50 color: "#000000", 50 color: fg,
51 fontSize: "14px", 51 fontSize: "14px",
52 }, 52 },
53 "&.cm-focused": { 53 "&.cm-focused": { outline: "none" },
54 outline: "none", 54 ".cm-content": {
55 }, 55 fontFamily:
56 ".cm-content": { 56 "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace",
57 fontFamily: 57 lineHeight: "1.375",
58 "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace", 58 },
59 lineHeight: "1.375", 59 ".cm-gutters": {
60 }, 60 backgroundColor: bg,
61 ".cm-gutters": { 61 color: gutterColor,
62 backgroundColor: "#FFFFFF", 62 borderRight: "none",
63 color: "#6e6e6e", 63 },
64 borderRight: "none", 64 ".cm-activeLine": { backgroundColor: "transparent" },
65 }, 65 ".cm-activeLineGutter": { backgroundColor: "transparent" },
66 ".cm-activeLine": { 66 ".cm-selectionBackground": { backgroundColor: selectionBg },
67 backgroundColor: "transparent", 67 "&.cm-focused .cm-selectionBackground": { backgroundColor: selectionBg },
68 }, 68 ".cm-cursor": { borderLeftColor: cursorColor },
69 ".cm-activeLineGutter": { 69 ".cm-matchingBracket": { backgroundColor: matchingBracketBg },
70 backgroundColor: "transparent", 70 },
71 }, 71 { dark },
72 ".cm-selectionBackground": { 72 );
73 backgroundColor: "#add6ff", 73}
74 },
75 "&.cm-focused .cm-selectionBackground": {
76 backgroundColor: "#add6ff",
77 },
78 ".cm-cursor": {
79 borderLeftColor: "#000000",
80 },
81 ".cm-matchingBracket": {
82 backgroundColor: "#c9def5",
83 },
84 },
85 { dark: false },
86);
87 74
88/* shikijs/themes/dark-plus: editor.background #1E1E1E, editor.foreground #D4D4D4 */ 75const lightPlusTheme = createEditorTheme({
89const darkPlusTheme = EditorView.theme( 76 bg: "#FFFFFF", fg: "#000000", gutterColor: "#6e6e6e",
90 { 77 selectionBg: "#add6ff", cursorColor: "#000000", matchingBracketBg: "#c9def5", dark: false,
91 "&": { 78});
92 height: "100%", 79
93 backgroundColor: "#1E1E1E", 80const darkPlusTheme = createEditorTheme({
94 color: "#D4D4D4", 81 bg: "#1E1E1E", fg: "#D4D4D4", gutterColor: "#858585",
95 fontSize: "14px", 82 selectionBg: "#264f78", cursorColor: "#aeafad", matchingBracketBg: "#3a3d41", dark: true,
96 }, 83});
97 "&.cm-focused": {
98 outline: "none",
99 },
100 ".cm-content": {
101 fontFamily:
102 "ui-monospace, 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace",
103 lineHeight: "1.375",
104 },
105 ".cm-gutters": {
106 backgroundColor: "#1E1E1E",
107 color: "#858585",
108 borderRight: "none",
109 },
110 ".cm-activeLine": {
111 backgroundColor: "transparent",
112 },
113 ".cm-activeLineGutter": {
114 backgroundColor: "transparent",
115 },
116 ".cm-selectionBackground": {
117 backgroundColor: "#264f78",
118 },
119 "&.cm-focused .cm-selectionBackground": {
120 backgroundColor: "#264f78",
121 },
122 ".cm-cursor": {
123 borderLeftColor: "#aeafad",
124 },
125 ".cm-matchingBracket": {
126 backgroundColor: "#3a3d41",
127 },
128 },
129 { dark: true },
130);
131 84
132/* shikijs/themes/light-plus tokenColors */ 85function createHighlightStyle(c) {
133const lightPlusHighlightStyle = HighlightStyle.define( 86 return HighlightStyle.define(
134 [ 87 [
135 { tag: tags.comment, color: "#008000" }, 88 { tag: tags.comment, color: c.comment },
136 { tag: tags.keyword, color: "#AF00DB" }, 89 { tag: tags.keyword, color: c.keyword },
137 { tag: [tags.operator, tags.punctuation], color: "#000000" }, 90 { tag: [tags.operator, tags.punctuation], color: c.punctuation },
138 { tag: [tags.string, tags.special(tags.string)], color: "#a31515" }, 91 { tag: [tags.string, tags.special(tags.string)], color: c.string },
139 { tag: tags.regexp, color: "#811f3f" }, 92 { tag: tags.regexp, color: c.regexp },
140 { tag: [tags.number, tags.bool, tags.null], color: "#098658" }, 93 { tag: [tags.number, tags.bool, tags.null], color: c.number },
141 { tag: tags.function(tags.variableName), color: "#795e26" }, 94 { tag: tags.function(tags.variableName), color: c.function },
142 { tag: tags.typeName, color: "#267f99" }, 95 { tag: tags.typeName, color: c.type },
143 { tag: tags.className, color: "#267f99" }, 96 { tag: tags.className, color: c.type },
144 { tag: tags.propertyName, color: "#001080" }, 97 { tag: tags.propertyName, color: c.property },
145 { tag: tags.tagName, color: "#800000" }, 98 { tag: tags.tagName, color: c.tag },
146 { tag: tags.attributeName, color: "#e50000" }, 99 { tag: tags.attributeName, color: c.attribute },
147 { tag: tags.meta, color: "#666666" }, 100 { tag: tags.meta, color: c.meta },
148 { tag: tags.invalid, color: "#cd3131" }, 101 { tag: tags.invalid, color: c.invalid },
149 // Additional tags for YueScript - ensure all token types have styles 102 { tag: tags.variableName, color: c.property },
150 { tag: tags.variableName, color: "#001080" }, 103 { tag: tags.constant(tags.name), color: c.number },
151 { tag: tags.constant(tags.name), color: "#098658" }, 104 { tag: tags.constant(tags.variableName), color: c.number },
152 { tag: tags.constant(tags.variableName), color: "#098658" }, 105 { tag: tags.constant, color: c.number },
153 { tag: tags.constant, color: "#098658" }, 106 { tag: tags.definition(tags.variableName), color: c.property },
154 { tag: tags.definition(tags.variableName), color: "#001080" }, 107 { tag: tags.modifier, color: c.keyword },
155 { tag: tags.modifier, color: "#AF00DB" }, 108 { tag: tags.namespace, color: c.type },
156 { tag: tags.namespace, color: "#267f99" }, 109 { tag: tags.labelName, color: c.function },
157 { tag: tags.labelName, color: "#795e26" }, 110 { tag: tags.character, color: c.number },
158 { tag: tags.character, color: "#098658" }, 111 { tag: tags.literal, color: c.number },
159 { tag: tags.literal, color: "#098658" }, 112 { tag: tags.bracket, color: c.punctuation },
160 { tag: tags.bracket, color: "#000000" }, 113 { tag: tags.squareBracket, color: c.punctuation },
161 { tag: tags.squareBracket, color: "#000000" }, 114 { tag: tags.paren, color: c.punctuation },
162 { tag: tags.paren, color: "#000000" }, 115 { tag: tags.brace, color: c.punctuation },
163 { tag: tags.brace, color: "#000000" }, 116 ],
164 ], 117 { fallback: true },
165 { fallback: true }, 118 );
166); 119}
120
121const lightPlusHighlightStyle = createHighlightStyle({
122 comment: "#008000", keyword: "#AF00DB", punctuation: "#000000",
123 string: "#a31515", regexp: "#811f3f", number: "#098658",
124 function: "#795e26", type: "#267f99", property: "#001080",
125 tag: "#800000", attribute: "#e50000", meta: "#666666", invalid: "#cd3131",
126});
167 127
168/* shikijs/themes/dark-plus tokenColors */ 128const darkPlusHighlightStyle = createHighlightStyle({
169const darkPlusHighlightStyle = HighlightStyle.define( 129 comment: "#6a9955", keyword: "#C586C0", punctuation: "#d4d4d4",
170 [ 130 string: "#ce9178", regexp: "#d16969", number: "#b5cea8",
171 { tag: tags.comment, color: "#6a9955" }, 131 function: "#dcdcaa", type: "#4ec9b0", property: "#9cdcfe",
172 { tag: tags.keyword, color: "#C586C0" }, 132 tag: "#569cd6", attribute: "#9cdcfe", meta: "#d4d4d4", invalid: "#f44747",
173 { tag: [tags.operator, tags.punctuation], color: "#d4d4d4" }, 133});
174 { tag: [tags.string, tags.special(tags.string)], color: "#ce9178" },
175 { tag: tags.regexp, color: "#d16969" },
176 { tag: [tags.number, tags.bool, tags.null], color: "#b5cea8" },
177 { tag: tags.function(tags.variableName), color: "#dcdcaa" },
178 { tag: tags.typeName, color: "#4ec9b0" },
179 { tag: tags.className, color: "#4ec9b0" },
180 { tag: tags.propertyName, color: "#9cdcfe" },
181 { tag: tags.tagName, color: "#569cd6" },
182 { tag: tags.attributeName, color: "#9cdcfe" },
183 { tag: tags.meta, color: "#d4d4d4" },
184 { tag: tags.invalid, color: "#f44747" },
185 // Additional tags for YueScript - ensure all token types have styles
186 { tag: tags.variableName, color: "#9cdcfe" },
187 { tag: tags.constant(tags.name), color: "#b5cea8" },
188 { tag: tags.constant(tags.variableName), color: "#b5cea8" },
189 { tag: tags.constant, color: "#b5cea8" },
190 { tag: tags.definition(tags.variableName), color: "#9cdcfe" },
191 { tag: tags.modifier, color: "#C586C0" },
192 { tag: tags.namespace, color: "#4ec9b0" },
193 { tag: tags.labelName, color: "#dcdcaa" },
194 { tag: tags.character, color: "#b5cea8" },
195 { tag: tags.literal, color: "#b5cea8" },
196 { tag: tags.bracket, color: "#d4d4d4" },
197 { tag: tags.squareBracket, color: "#d4d4d4" },
198 { tag: tags.paren, color: "#d4d4d4" },
199 { tag: tags.brace, color: "#d4d4d4" },
200 ],
201 { fallback: true },
202);
203 134
204export default { 135export default {
205 props: { 136 props: {
@@ -229,6 +160,7 @@ export default {
229 themeCompartment: null, 160 themeCompartment: null,
230 highlightCompartment: null, 161 highlightCompartment: null,
231 themeObserver: null, 162 themeObserver: null,
163 _onYueReady: null,
232 }; 164 };
233 }, 165 },
234 computed: { 166 computed: {
@@ -244,7 +176,7 @@ export default {
244 window.addEventListener("resize", this.handleResize); 176 window.addEventListener("resize", this.handleResize);
245 this.observeTheme(); 177 this.observeTheme();
246 178
247 const initialCode = this.text !== "" ? this.text : ""; 179 const initialCode = this.text;
248 this.code = initialCode; 180 this.code = initialCode;
249 this.codeChanged(initialCode); 181 this.codeChanged(initialCode);
250 this.initEditor(initialCode); 182 this.initEditor(initialCode);
@@ -252,21 +184,26 @@ export default {
252 this.focusEditorToEnd(); 184 this.focusEditorToEnd();
253 }); 185 });
254 186
255 const check = ((self) => { 187 const onYueReady = () => {
256 return () => { 188 if (window.yue) {
257 if (window.yue) { 189 this.info = window.yue.version();
258 self.info = window.yue.version(); 190 this.readonly = false;
259 self.readonly = false; 191 this.refreshEditorReadOnly();
260 this.refreshEditorReadOnly(); 192 }
261 } else { 193 };
262 setTimeout(check, 100); 194 if (window.yue) {
263 } 195 onYueReady();
264 }; 196 } else {
265 })(this); 197 this._onYueReady = onYueReady;
266 check(); 198 window.addEventListener("yue:ready", onYueReady, { once: true });
199 }
267 }, 200 },
268 beforeUnmount() { 201 beforeUnmount() {
269 window.removeEventListener("resize", this.handleResize); 202 window.removeEventListener("resize", this.handleResize);
203 if (this._onYueReady) {
204 window.removeEventListener("yue:ready", this._onYueReady);
205 this._onYueReady = null;
206 }
270 if (this.editorView) { 207 if (this.editorView) {
271 this.editorView.destroy(); 208 this.editorView.destroy();
272 this.editorView = null; 209 this.editorView = null;
@@ -673,7 +610,7 @@ export default {
673 overflow-wrap: break-word; 610 overflow-wrap: break-word;
674 width: calc(100% - 120px); 611 width: calc(100% - 120px);
675 height: 55px; 612 height: 55px;
676 border-color: #b7ae8f; 613 border-color: var(--vp-button-brand-bg);
677 border-radius: 4px; 614 border-radius: 4px;
678 border-width: 1px; 615 border-width: 1px;
679 border-style: solid; 616 border-style: solid;
@@ -722,20 +659,20 @@ export default {
722 border: none; 659 border: none;
723 display: inline-block; 660 display: inline-block;
724 font-size: 1.2rem; 661 font-size: 1.2rem;
725 color: #fff; 662 color: var(--vp-button-brand-text);
726 background-color: #b7ae8f; 663 background-color: var(--vp-button-brand-bg);
727 text-decoration: none; 664 text-decoration: none;
728 padding: 0.8rem 1.6rem; 665 padding: 0.8rem 1.6rem;
729 border-radius: 4px; 666 border-radius: 4px;
730 transition: background-color 0.1s ease; 667 transition: background-color 0.1s ease;
731 box-sizing: border-box; 668 box-sizing: border-box;
732 border-bottom: 1px solid #aaa07b; 669 border-bottom: 1px solid var(--vp-button-brand-border);
733 margin-top: 10px; 670 margin-top: 10px;
734 margin-right: 5px; 671 margin-right: 5px;
735} 672}
736 673
737.button:hover { 674.button:hover {
738 background-color: #beb69a; 675 background-color: var(--vp-button-brand-hover-bg);
739} 676}
740 677
741.button:focus, 678.button:focus,
diff --git a/doc/docs/.vitepress/theme/components/YueDisplay.vue b/doc/docs/.vitepress/theme/components/YueDisplay.vue
index b270f21..56e57de 100755
--- a/doc/docs/.vitepress/theme/components/YueDisplay.vue
+++ b/doc/docs/.vitepress/theme/components/YueDisplay.vue
@@ -28,18 +28,18 @@ export default {
28 border: none; 28 border: none;
29 display: inline-block; 29 display: inline-block;
30 font-size: 16px; 30 font-size: 16px;
31 color: #fff; 31 color: var(--vp-button-brand-text);
32 background-color: #b7ae8f; 32 background-color: var(--vp-button-brand-bg);
33 text-decoration: none; 33 text-decoration: none;
34 padding: 0.4rem 0.8rem; 34 padding: 0.4rem 0.8rem;
35 border-radius: 4px; 35 border-radius: 4px;
36 transition: background-color 0.1s ease; 36 transition: background-color 0.1s ease;
37 box-sizing: border-box; 37 box-sizing: border-box;
38 border-bottom: 1px solid #aaa07b; 38 border-bottom: 1px solid var(--vp-button-brand-border);
39 margin-bottom: 1em; 39 margin-bottom: 1em;
40} 40}
41.button:hover { 41.button:hover {
42 background-color: #beb69a; 42 background-color: var(--vp-button-brand-hover-bg);
43} 43}
44.button:focus, 44.button:focus,
45.button:active:focus, 45.button:active:focus,