@joinezco/codeblock 0.0.8

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 (81) hide show
  1. package/LICENSE +661 -0
  2. package/dist/assets/clike-C8IJ2oj_.js +1 -0
  3. package/dist/assets/cmake-BQqOBYOt.js +1 -0
  4. package/dist/assets/dockerfile-C_y-rIpk.js +1 -0
  5. package/dist/assets/fs.worker-BwEqZcql.ts +109 -0
  6. package/dist/assets/go-CTD25R5P.js +1 -0
  7. package/dist/assets/haskell-BWDZoCOh.js +1 -0
  8. package/dist/assets/index-9HdhmM_Y.js +1 -0
  9. package/dist/assets/index-C-QhPFHP.js +3 -0
  10. package/dist/assets/index-C3BnE2cG.js +222 -0
  11. package/dist/assets/index-CGx5MZO7.js +6 -0
  12. package/dist/assets/index-CIuq3uTk.js +1 -0
  13. package/dist/assets/index-CXFONXS8.js +1 -0
  14. package/dist/assets/index-D5Z27j1C.js +1 -0
  15. package/dist/assets/index-DWOBdRjn.js +1 -0
  16. package/dist/assets/index-Dvu-FFzd.js +1 -0
  17. package/dist/assets/index-Dx_VuNNd.js +1 -0
  18. package/dist/assets/index-I0dlv-r3.js +1 -0
  19. package/dist/assets/index-MGle_v2x.js +1 -0
  20. package/dist/assets/index-N-GE7HTU.js +1 -0
  21. package/dist/assets/index-aEsF5o-7.js +2 -0
  22. package/dist/assets/index-as7ELo0J.js +1 -0
  23. package/dist/assets/index-gUUzXNuP.js +1 -0
  24. package/dist/assets/index-pGm0qkrJ.js +13 -0
  25. package/dist/assets/javascript.worker-C1zGArKk.js +527 -0
  26. package/dist/assets/lua-BgMRiT3U.js +1 -0
  27. package/dist/assets/perl-CdXCOZ3F.js +1 -0
  28. package/dist/assets/process-Dw9K5EnD.js +1357 -0
  29. package/dist/assets/properties-C78fOPTZ.js +1 -0
  30. package/dist/assets/ruby-B2Rjki9n.js +1 -0
  31. package/dist/assets/shell-CjFT_Tl9.js +1 -0
  32. package/dist/assets/swift-BzpIVaGY.js +1 -0
  33. package/dist/assets/toml-BXUEaScT.js +1 -0
  34. package/dist/assets/vb-CmGdzxic.js +1 -0
  35. package/dist/e2e/example.spec.d.ts +5 -0
  36. package/dist/e2e/example.spec.js +44 -0
  37. package/dist/editor.d.ts +53 -0
  38. package/dist/editor.js +248 -0
  39. package/dist/index.d.ts +6 -0
  40. package/dist/index.html +16 -0
  41. package/dist/index.js +6 -0
  42. package/dist/lsps/index.d.ts +96 -0
  43. package/dist/lsps/index.js +198 -0
  44. package/dist/lsps/typescript.d.ts +55 -0
  45. package/dist/lsps/typescript.js +48 -0
  46. package/dist/panels/toolbar.d.ts +20 -0
  47. package/dist/panels/toolbar.js +453 -0
  48. package/dist/panels/toolbar.test.d.ts +1 -0
  49. package/dist/panels/toolbar.test.js +146 -0
  50. package/dist/resources/config.json +13 -0
  51. package/dist/rpc/serde.d.ts +11 -0
  52. package/dist/rpc/serde.js +49 -0
  53. package/dist/rpc/transport.d.ts +11 -0
  54. package/dist/rpc/transport.js +38 -0
  55. package/dist/snapshot.bin +0 -0
  56. package/dist/styles.css +7 -0
  57. package/dist/themes/index.d.ts +1 -0
  58. package/dist/themes/index.js +169 -0
  59. package/dist/themes/util.d.ts +24 -0
  60. package/dist/themes/util.js +63 -0
  61. package/dist/themes/vscode.d.ts +6 -0
  62. package/dist/themes/vscode.js +187 -0
  63. package/dist/types.d.ts +64 -0
  64. package/dist/types.js +1 -0
  65. package/dist/utils/fs.d.ts +29 -0
  66. package/dist/utils/fs.js +310 -0
  67. package/dist/utils/indent.d.ts +1 -0
  68. package/dist/utils/indent.js +38 -0
  69. package/dist/utils/index.d.ts +2 -0
  70. package/dist/utils/index.js +2 -0
  71. package/dist/utils/lsp.d.ts +26 -0
  72. package/dist/utils/lsp.js +74 -0
  73. package/dist/utils/search.d.ts +30 -0
  74. package/dist/utils/search.js +68 -0
  75. package/dist/utils/snapshot.d.ts +60 -0
  76. package/dist/utils/snapshot.js +299 -0
  77. package/dist/workers/fs.worker.d.ts +11 -0
  78. package/dist/workers/fs.worker.js +93 -0
  79. package/dist/workers/javascript.worker.d.ts +1 -0
  80. package/dist/workers/javascript.worker.js +20 -0
  81. package/package.json +95 -0
@@ -0,0 +1,38 @@
1
+ import { Transport } from "@open-rpc/client-js/build/transports/Transport";
2
+ import { getNotifications } from "@open-rpc/client-js/src/Request";
3
+ export default class MessagePortTransport extends Transport {
4
+ port;
5
+ postMessageID;
6
+ constructor(port) {
7
+ super();
8
+ this.port = port;
9
+ this.postMessageID = `post-message-transport-${Math.random()}`;
10
+ }
11
+ messageHandler = (ev) => {
12
+ console.debug("LSP <<-", ev.data);
13
+ if (!ev.data.result && ev.data.method !== 'textDocument/publishDiagnostics') {
14
+ console.debug(ev.data);
15
+ // this.port.postMessage({ jsonrpc: '2.0', id: ev.data.id, result: null })
16
+ }
17
+ else {
18
+ this.transportRequestManager.resolveResponse(JSON.stringify(ev.data));
19
+ }
20
+ };
21
+ connect() {
22
+ return new Promise(async (resolve) => {
23
+ this.port.addEventListener("message", this.messageHandler);
24
+ resolve();
25
+ });
26
+ }
27
+ async sendData(data) {
28
+ console.debug("LSP ->>", data);
29
+ const prom = this.transportRequestManager.addRequest(data, null);
30
+ const notifications = getNotifications(data);
31
+ if (this.port) {
32
+ this.port.postMessage(data.request);
33
+ this.transportRequestManager.settlePendingRequest(notifications);
34
+ }
35
+ return prom;
36
+ }
37
+ close() { }
38
+ }
Binary file
@@ -0,0 +1,7 @@
1
+ html {
2
+ /* background-color: #1e1e1e; */
3
+ }
4
+
5
+ body {
6
+ margin: 0;
7
+ }
@@ -0,0 +1 @@
1
+ export declare const codeblockTheme: import("@codemirror/state").Extension;
@@ -0,0 +1,169 @@
1
+ import { EditorView } from '@codemirror/view';
2
+ export const codeblockTheme = EditorView.theme({
3
+ "&:not(.cm-focused)": {
4
+ '& .cm-activeLine, & .cm-activeLineGutter': {
5
+ color: 'inherit',
6
+ backgroundColor: "transparent"
7
+ }
8
+ },
9
+ '.cm-toolbar-input': {
10
+ fontFamily: 'var(--cm-font-family)',
11
+ lineHeight: 1.4,
12
+ border: 'none',
13
+ background: 'transparent',
14
+ outline: 'none',
15
+ fontSize: '16px',
16
+ color: 'var(--cm-toolbar-color)',
17
+ padding: '0 2px 0 6px',
18
+ width: '100%',
19
+ flex: 1,
20
+ },
21
+ '.cm-toolbar-input-container': {
22
+ position: 'relative',
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ flex: 1,
26
+ },
27
+ '.cm-toolbar-panel': {
28
+ padding: 0,
29
+ background: 'var(--cm-toolbar-background)',
30
+ display: 'flex',
31
+ alignItems: 'center',
32
+ },
33
+ '.cm-command-result > span': {
34
+ color: 'var(--cm-command-result-color)'
35
+ },
36
+ '.cm-search-result': {
37
+ color: 'var(--cm-search-result-color)',
38
+ display: 'flex',
39
+ cursor: 'pointer',
40
+ '&.cm-command-result': {
41
+ color: 'var(--cm-command-result-color)'
42
+ },
43
+ '& > .cm-search-result-icon-container': {
44
+ width: 'var(--cm-gutter-width)',
45
+ '& > .cm-search-result-icon': {
46
+ fontSize: '16px',
47
+ textAlign: 'right',
48
+ boxSizing: 'border-box',
49
+ padding: '0 3px 0 5px',
50
+ width: 'var(--cm-gutter-lineno-width)',
51
+ }
52
+ },
53
+ '&:hover': {
54
+ '& div': {
55
+ color: 'var(--cm-search-result-color-hover)',
56
+ },
57
+ backgroundColor: 'var(--cm-search-result-bg-hover)',
58
+ },
59
+ '&.selected': {
60
+ '& div': {
61
+ color: 'var(--cm-search-result-color-selected)',
62
+ },
63
+ backgroundColor: 'var(--cm-search-result-select-bg)',
64
+ },
65
+ '& > .cm-search-result-label': {
66
+ flex: 1,
67
+ padding: '0 2px 0 6px',
68
+ },
69
+ },
70
+ '.cm-toolbar-state-icon-container': {
71
+ width: 'var(--cm-gutter-width)',
72
+ },
73
+ '.cm-toolbar-state-icon': {
74
+ fontSize: '16px',
75
+ textAlign: 'right',
76
+ boxSizing: 'border-box',
77
+ padding: '0 3px 0 5px',
78
+ color: 'var(--cm-foreground)',
79
+ width: 'var(--cm-gutter-lineno-width)'
80
+ },
81
+ '.cm-content': {
82
+ padding: 0,
83
+ },
84
+ '.cm-tooltip': {
85
+ display: 'flex',
86
+ flexDirection: 'column',
87
+ fontFamily: 'var(--cm-font-family)',
88
+ boxShadow: '-12px 12px 1px rgba(0,0,0,0.3)',
89
+ fontSize: '1rem',
90
+ maxWidth: 'min(calc(100% - 2rem), 62ch)',
91
+ border: '2px solid var(--cm-tooltip-border)',
92
+ overflow: 'auto',
93
+ background: 'var(--cm-tooltip-background)',
94
+ color: 'var(--cm-tooltip-color)',
95
+ },
96
+ '.cm-tooltip a': {
97
+ color: 'var(--cm-link)',
98
+ },
99
+ '.cm-tooltip-section:not(:first-child)': {
100
+ borderTop: 'none',
101
+ },
102
+ '.cm-tooltip-lint': {
103
+ order: -1,
104
+ },
105
+ '.cm-diagnostic': {
106
+ padding: '3px 6px',
107
+ whiteSpace: 'pre-wrap',
108
+ marginLeft: 0,
109
+ borderLeft: 'none',
110
+ },
111
+ '.cm-diagnostic-info': {
112
+ backgroundColor: 'var(--cm-diagnostic-info-bg)',
113
+ color: 'var(--cm-diagnostic-info-color)',
114
+ },
115
+ '.cm-diagnostic-error': {
116
+ borderLeft: 'none',
117
+ backgroundColor: 'var(--cm-diagnostic-error-bg)',
118
+ color: 'var(--cm-diagnostic-error-color)',
119
+ },
120
+ '.cm-diagnosticSource': {
121
+ display: 'none',
122
+ },
123
+ '.documentation': {
124
+ padding: '2px',
125
+ },
126
+ '.documentation > *': {
127
+ margin: 0,
128
+ padding: '0.25rem 6px',
129
+ fontSize: '1rem',
130
+ },
131
+ '.documentation > p > code': {
132
+ backgroundColor: 'var(--cm-comment-bg)',
133
+ padding: '2px 4px',
134
+ margin: '2px 0',
135
+ display: 'inline-block',
136
+ },
137
+ '.documentation > pre > code': {
138
+ whiteSpace: 'break-spaces',
139
+ },
140
+ '.cm-diagnosticAction': {
141
+ display: 'none',
142
+ },
143
+ '.cm-diagnosticText div': {
144
+ display: 'flex',
145
+ height: 'fit-content',
146
+ },
147
+ '.cm-diagnosticText p': {
148
+ margin: 0,
149
+ },
150
+ '.cm-search-results': {
151
+ position: 'absolute',
152
+ top: '100%',
153
+ margin: 0,
154
+ padding: 0,
155
+ background: 'var(--cm-toolbar-background)',
156
+ fontFamily: 'var(--cm-font-family)',
157
+ fontSize: '1rem',
158
+ listStyleType: 'none',
159
+ width: '100%',
160
+ maxHeight: '25vh',
161
+ overflowY: 'auto',
162
+ },
163
+ '.cm-gutters': {
164
+ borderRight: 'none',
165
+ },
166
+ '.cm-panels-top': {
167
+ borderBottom: 'none'
168
+ }
169
+ });
@@ -0,0 +1,24 @@
1
+ import { Extension } from "@codemirror/state";
2
+ import { type TagStyle } from "@codemirror/language";
3
+ import type { StyleSpec } from "style-mod";
4
+ export interface CreateThemeOptions {
5
+ theme: "light" | "dark";
6
+ settings: Settings;
7
+ styles: TagStyle[];
8
+ }
9
+ export interface Settings {
10
+ background?: string;
11
+ backgroundImage?: string;
12
+ foreground?: string;
13
+ caret?: string;
14
+ selection?: string;
15
+ selectionMatch?: string;
16
+ lineHighlight?: string;
17
+ gutterBackground?: string;
18
+ gutterForeground?: string;
19
+ gutterActiveForeground?: string;
20
+ gutterBorder?: string;
21
+ fontFamily?: string;
22
+ fontSize?: StyleSpec["fontSize"];
23
+ }
24
+ export declare function createTheme({ theme, settings, styles, }: CreateThemeOptions): Extension;
@@ -0,0 +1,63 @@
1
+ import { EditorView } from "@codemirror/view";
2
+ import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
3
+ export function createTheme({ theme, settings = {}, styles = [], }) {
4
+ const themeOptions = {
5
+ ".cm-gutters": {},
6
+ };
7
+ const baseStyle = {};
8
+ if (settings.background)
9
+ baseStyle.backgroundColor = settings.background;
10
+ if (settings.backgroundImage)
11
+ baseStyle.backgroundImage = settings.backgroundImage;
12
+ if (settings.foreground)
13
+ baseStyle.color = settings.foreground;
14
+ if (settings.fontSize)
15
+ baseStyle.fontSize = settings.fontSize;
16
+ if (Object.keys(baseStyle).length > 0) {
17
+ themeOptions["&"] = baseStyle;
18
+ }
19
+ if (settings.fontFamily) {
20
+ themeOptions["&.cm-editor .cm-scroller"] = {
21
+ fontFamily: settings.fontFamily,
22
+ };
23
+ }
24
+ if (settings.gutterBackground) {
25
+ themeOptions[".cm-gutters"].backgroundColor = settings.gutterBackground;
26
+ }
27
+ if (settings.gutterForeground) {
28
+ themeOptions[".cm-gutters"].color = settings.gutterForeground;
29
+ }
30
+ if (settings.gutterBorder) {
31
+ themeOptions[".cm-gutters"].borderRightColor = settings.gutterBorder;
32
+ }
33
+ if (settings.caret) {
34
+ themeOptions[".cm-content"] = { caretColor: settings.caret };
35
+ themeOptions[".cm-cursor, .cm-dropCursor"] = {
36
+ borderLeftColor: settings.caret,
37
+ };
38
+ }
39
+ const activeLineGutterStyle = {};
40
+ if (settings.gutterActiveForeground) {
41
+ activeLineGutterStyle.color = settings.gutterActiveForeground;
42
+ }
43
+ if (settings.lineHighlight) {
44
+ themeOptions[".cm-activeLine"] = {
45
+ backgroundColor: settings.lineHighlight,
46
+ };
47
+ activeLineGutterStyle.backgroundColor = settings.lineHighlight;
48
+ }
49
+ themeOptions[".cm-activeLineGutter"] = activeLineGutterStyle;
50
+ if (settings.selection) {
51
+ themeOptions["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"] = { background: `${settings.selection} !important` };
52
+ }
53
+ if (settings.selectionMatch) {
54
+ themeOptions["& .cm-selectionMatch"] = {
55
+ backgroundColor: settings.selectionMatch,
56
+ };
57
+ }
58
+ const themeExtension = EditorView.theme(themeOptions, {
59
+ dark: theme === "dark",
60
+ });
61
+ const highlightStyle = HighlightStyle.define(styles);
62
+ return [themeExtension, syntaxHighlighting(highlightStyle)];
63
+ }
@@ -0,0 +1,6 @@
1
+ import { type CreateThemeOptions } from "./util";
2
+ import { StyleModule } from "style-mod";
3
+ export declare const variableSettings: CreateThemeOptions["settings"];
4
+ export declare const variableStyles: CreateThemeOptions["styles"];
5
+ export declare const vscodeLightDark: import("@codemirror/state").Extension;
6
+ export declare const vscodeStyleMod: StyleModule;
@@ -0,0 +1,187 @@
1
+ import { tags as t } from "@lezer/highlight";
2
+ import { createTheme } from "./util";
3
+ import { StyleModule } from "style-mod";
4
+ export const variableSettings = {
5
+ background: "var(--cm-background)",
6
+ foreground: "var(--cm-foreground)",
7
+ caret: "var(--cm-caret)",
8
+ selection: "var(--cm-selection)",
9
+ selectionMatch: "var(--cm-selection-match)",
10
+ lineHighlight: "var(--cm-line-highlight)",
11
+ gutterBackground: "var(--cm-gutter-background)",
12
+ gutterForeground: "var(--cm-gutter-foreground)",
13
+ gutterActiveForeground: "var(--cm-gutter-active-foreground)",
14
+ fontFamily: "var(--cm-font-family)",
15
+ };
16
+ export const variableStyles = [
17
+ {
18
+ tag: [
19
+ t.keyword,
20
+ t.operatorKeyword,
21
+ t.modifier,
22
+ t.color,
23
+ t.constant(t.name),
24
+ t.standard(t.name),
25
+ t.standard(t.tagName),
26
+ t.special(t.brace),
27
+ t.atom,
28
+ t.bool,
29
+ t.special(t.variableName),
30
+ ],
31
+ color: "var(--cm-keyword)",
32
+ },
33
+ { tag: [t.controlKeyword, t.moduleKeyword], color: "var(--cm-control)" },
34
+ {
35
+ tag: [
36
+ t.name,
37
+ t.deleted,
38
+ t.character,
39
+ t.macroName,
40
+ t.propertyName,
41
+ t.variableName,
42
+ t.labelName,
43
+ t.definition(t.name),
44
+ ],
45
+ color: "var(--cm-name)",
46
+ },
47
+ { tag: t.heading, fontWeight: "bold", color: "var(--cm-heading)" },
48
+ {
49
+ tag: [
50
+ t.typeName,
51
+ t.className,
52
+ t.tagName,
53
+ t.number,
54
+ t.changed,
55
+ t.annotation,
56
+ t.self,
57
+ t.namespace,
58
+ ],
59
+ color: "var(--cm-type)",
60
+ },
61
+ { tag: [t.function(t.variableName), t.function(t.propertyName)], color: "var(--cm-function)" },
62
+ { tag: [t.number], color: "var(--cm-number)" },
63
+ {
64
+ tag: [t.operator, t.punctuation, t.separator, t.url, t.escape, t.regexp],
65
+ color: "var(--cm-operator)",
66
+ },
67
+ { tag: [t.regexp], color: "var(--cm-regexp)" },
68
+ {
69
+ tag: [t.special(t.string), t.processingInstruction, t.string, t.inserted],
70
+ color: "var(--cm-string)",
71
+ },
72
+ { tag: [t.angleBracket], color: "var(--cm-angle-bracket)" },
73
+ { tag: t.strong, fontWeight: "bold" },
74
+ { tag: t.emphasis, fontStyle: "italic" },
75
+ { tag: t.strikethrough, textDecoration: "line-through" },
76
+ { tag: [t.meta, t.comment], color: "var(--cm-comment)" },
77
+ { tag: t.link, color: "var(--cm-link)", textDecoration: "underline" },
78
+ { tag: t.invalid, color: "var(--cm-invalid)" },
79
+ ];
80
+ function vscodeLightDarkTheme(options) {
81
+ const { theme = "light", settings = {}, styles = [] } = options || {};
82
+ return createTheme({
83
+ theme,
84
+ settings: {
85
+ ...variableSettings,
86
+ ...settings,
87
+ },
88
+ styles: [...variableStyles, ...styles],
89
+ });
90
+ }
91
+ export const vscodeLightDark = vscodeLightDarkTheme();
92
+ const darkModeStyles = {
93
+ "--cm-background": "#1e1e1e",
94
+ "--cm-foreground": "#9cdcfe",
95
+ "--cm-caret": "#c6c6c6",
96
+ "--cm-selection": "#6199ff2f",
97
+ "--cm-selection-match": "#72a1ff59",
98
+ "--cm-line-highlight": "#ffffff0f",
99
+ "--cm-gutter-background": "#1e1e1e",
100
+ "--cm-gutter-foreground": "#838383",
101
+ "--cm-gutter-active-foreground": "#ffffff",
102
+ "--cm-keyword": "#569cd6",
103
+ "--cm-control": "#c586c0",
104
+ "--cm-name": "#9cdcfe",
105
+ "--cm-heading": "#9cdcfe",
106
+ "--cm-type": "#4ec9b0",
107
+ "--cm-function": "#dcdcaa",
108
+ "--cm-number": "#b5cea8",
109
+ "--cm-operator": "#d4d4d4",
110
+ "--cm-regexp": "#d16969",
111
+ "--cm-string": "#ce9178",
112
+ "--cm-angle-bracket": "#808080",
113
+ "--cm-comment": "#6a9955",
114
+ "--cm-link": "#4078f2",
115
+ "--cm-invalid": "#ff0000",
116
+ "--cm-search-result-color": "var(--cm-angle-bracket)",
117
+ "--cm-search-result-color-hover": "#ffffff",
118
+ "--cm-command-result-color": "var(--cm-search-result-color-hover)",
119
+ "--cm-toolbar-background": "var(--cm-toolbar-bg-dark)",
120
+ "--cm-toolbar-color": "var(--cm-toolbar-color-dark)",
121
+ "--cm-toolbar-foreground": "#ffffff",
122
+ "--cm-tooltip-color": "var(--cm-gutter-active-foreground)",
123
+ "--cm-tooltip-background": "var(--cm-toolbar-background)",
124
+ "--cm-tooltip-border": "#000000",
125
+ "--cm-diagnostic-error-bg": "#d11",
126
+ "--cm-comment-bg": "rgba(0,0,0,0.32)",
127
+ };
128
+ export const vscodeStyleMod = new StyleModule({
129
+ ":root, .cm-editor[data-theme='light'], [data-theme='light'] .cm-editor": {
130
+ /* Shared */
131
+ "--cm-font-family": 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
132
+ /* Defaults to light theme */
133
+ "--cm-background": "#ffffff",
134
+ "--cm-foreground": "#383a42",
135
+ "--cm-caret": "#000000",
136
+ "--cm-selection": "#add6ff",
137
+ "--cm-selection-match": "#a8ac94",
138
+ "--cm-line-highlight": "#99999914",
139
+ "--cm-gutter-background": "#ffffff",
140
+ "--cm-gutter-foreground": "#237893",
141
+ "--cm-gutter-active-foreground": "#0b216f",
142
+ /* Syntax colors */
143
+ "--cm-keyword": "#0000ff",
144
+ "--cm-control": "#af00db",
145
+ "--cm-name": "#0070c1",
146
+ "--cm-heading": "#0070c1",
147
+ "--cm-type": "#267f99",
148
+ "--cm-function": "#795e26",
149
+ "--cm-number": "#098658",
150
+ "--cm-operator": "#383a42",
151
+ "--cm-regexp": "#af00db",
152
+ "--cm-string": "#a31515",
153
+ "--cm-angle-bracket": "#383a42",
154
+ "--cm-comment": "#008000",
155
+ "--cm-link": "#4078f2",
156
+ "--cm-invalid": "#e45649",
157
+ /* Additional UI colors */
158
+ "--cm-search-result-color": "#838383",
159
+ "--cm-search-result-color-hover": "var(--cm-toolbar-color)",
160
+ "--cm-search-result-bg-hover": "#2490e94f",
161
+ "--cm-search-result-color-selected": "#ffffff",
162
+ "--cm-search-result-select-bg": "#2490e9",
163
+ "--cm-command-result-color": "var(--cm-toolbar-color)",
164
+ "--cm-toolbar-bg-light": "#f3f3f3",
165
+ "--cm-toolbar-bg-dark": "#2a2a2f",
166
+ "--cm-toolbar-color-light": "#000000",
167
+ "--cm-toolbar-color-dark": "#ffffff",
168
+ "--cm-toolbar-background": "var(--cm-toolbar-bg-light)",
169
+ "--cm-toolbar-color": "var(--cm-toolbar-color-light)",
170
+ "--cm-toolbar-foreground": "var(--cm-foreground)",
171
+ "--cm-tooltip-color": "var(--cm-foreground)",
172
+ "--cm-tooltip-background": "#ffffff",
173
+ "--cm-tooltip-border": "#000000",
174
+ "--cm-diagnostic-info-color": "white",
175
+ "--cm-diagnostic-info-bg": "#545454",
176
+ // "--cm-diagnostic-info-color": "#000000",
177
+ // "--cm-diagnostic-info-bg": "#f3f3f3",
178
+ "--cm-diagnostic-error-color": "white",
179
+ "--cm-diagnostic-error-bg": "#e45649",
180
+ "--cm-comment-bg": "rgba(0,0,0,0.1)",
181
+ },
182
+ ":root[data-theme='dark'], .cm-editor[data-theme='dark'], [data-theme='dark'] .cm-editor": darkModeStyles,
183
+ /* Dark-mode override */
184
+ "@media (prefers-color-scheme: dark)": {
185
+ ":root": darkModeStyles,
186
+ }
187
+ });
@@ -0,0 +1,64 @@
1
+ import { CborUint8Array } from "@jsonjoy.com/json-pack/lib/cbor/types";
2
+ import { FileType } from "@volar/language-service";
3
+ import { SnapshotNode } from "@joinezco/memfs/snapshot";
4
+ import { FsApi } from "@joinezco/memfs/node/types";
5
+ export interface VfsInterface {
6
+ /**
7
+ * Reads the entire contents of a file asynchronously
8
+ * @param path A path to a file
9
+ */
10
+ readFile: (path: string) => Promise<string>;
11
+ /**
12
+ * Writes data to a file asynchronously
13
+ * @param path A path to a file
14
+ * @param data The data to write
15
+ */
16
+ writeFile: (path: string, data: string) => Promise<void>;
17
+ /**
18
+ * Watch for changes to a file or directory
19
+ * @param path A path to a file/directory
20
+ * @param options Configuration options for watching
21
+ */
22
+ watch: (path: string, options: {
23
+ signal: AbortSignal;
24
+ }) => AsyncGenerator<{
25
+ eventType: 'rename' | 'change';
26
+ filename: string;
27
+ }>;
28
+ /**
29
+ * Creates a directory asynchronously
30
+ * @param path A path to a directory, URL, or parent FileSystemDirectoryHandle
31
+ * @param options Configuration options for directory creation
32
+ */
33
+ mkdir: (path: string, options: {
34
+ recursive: boolean;
35
+ }) => Promise<void>;
36
+ readDir: (path: string) => Promise<[string, FileType][]>;
37
+ /**
38
+ * Checks whether a given file or folder exists
39
+ * @param path A path to a file or folder
40
+ * @returns A promise that resolves to true if the file or folder exists, false otherwise
41
+ */
42
+ exists: (path: string) => Promise<boolean>;
43
+ stat: (path: string) => Promise<any | undefined>;
44
+ }
45
+ export type FsMountOptions = {
46
+ mount: (args: {
47
+ buffer: ArrayBuffer;
48
+ }) => Promise<MountResult>;
49
+ mountFromUrl?: (args: {
50
+ url: string;
51
+ mountPoint?: string;
52
+ }) => Promise<MountResult>;
53
+ };
54
+ export type MountArgs = {
55
+ buffer?: CborUint8Array<SnapshotNode>;
56
+ mountPoint?: string;
57
+ };
58
+ export type MountFromUrlArgs = {
59
+ url: string;
60
+ mountPoint?: string;
61
+ };
62
+ export type MountResult = {
63
+ fs: FsApi;
64
+ };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import { VfsInterface } from "../types";
2
+ import { FileSystem, FileType } from '@volar/language-service';
3
+ import { URI } from 'vscode-uri';
4
+ import { CborUint8Array } from "@jsonjoy.com/json-pack/lib/cbor/types";
5
+ import { SnapshotNode } from "@joinezco/memfs/snapshot";
6
+ import { promises } from "node:fs";
7
+ import type { FsApi } from "@joinezco/memfs/node/types";
8
+ import { TopLevelFs } from "@joinezco/jswasi/filesystem";
9
+ export declare namespace Vfs {
10
+ const fromJswasiFs: (jswasiFs: TopLevelFs) => Promise<VfsInterface>;
11
+ const fromMemfs: (fs: FsApi) => VfsInterface;
12
+ const fromNodelike: (fs: typeof promises) => VfsInterface;
13
+ /**
14
+ * Create a filesystem worker with optional snapshot data.
15
+ *
16
+ * @param bufferOrUrl - Either a snapshot buffer or URL to a snapshot file.
17
+ * If a URL is provided, it will be loaded directly in the worker
18
+ * for better performance with large files.
19
+ */
20
+ const worker: (bufferOrUrl?: CborUint8Array<SnapshotNode> | string) => Promise<VfsInterface>;
21
+ function walk(fs: VfsInterface, path: string): AsyncIterable<string>;
22
+ }
23
+ export declare class VolarFs implements FileSystem {
24
+ #private;
25
+ constructor(fs: VfsInterface);
26
+ stat(uri: URI): Promise<any>;
27
+ readDirectory(uri: URI): Promise<[string, FileType][]>;
28
+ readFile(uri: URI): Promise<string>;
29
+ }