@0xchain/monaco 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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # monaco
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build monaco` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test monaco` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,15 @@
1
+ import { EditorProps } from '@monaco-editor/react';
2
+ interface MonacoProps extends EditorProps {
3
+ tables?: Array<{
4
+ table: string;
5
+ fields: Array<{
6
+ fieldName: string;
7
+ fieldType: string;
8
+ fieldComment: string;
9
+ }>;
10
+ }>;
11
+ theme?: string;
12
+ }
13
+ export default function Monaco({ tables, theme, ...props }: MonacoProps): import("react").JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAWxD,UAAU,WAAY,SAAQ,WAAW;IACvC,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,KAAK,CAAC;YACZ,SAAS,EAAE,MAAM,CAAC;YAClB,SAAS,EAAE,MAAM,CAAC;YAClB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,+BA4DtE"}
package/dist/index.js ADDED
@@ -0,0 +1,136 @@
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import g, { loader as E, useMonaco as f } from "@monaco-editor/react";
3
+ import { createHighlighter as T } from "shiki";
4
+ import { shikiToMonaco as p } from "@shikijs/monaco";
5
+ import { useRef as d, useMemo as N, useEffect as m } from "react";
6
+ const h = async (n) => {
7
+ const i = await T({
8
+ themes: ["catppuccin-latte", "tokyo-night"],
9
+ langs: ["sql"]
10
+ });
11
+ n.languages.register({ id: "sql" }), p(i, n);
12
+ };
13
+ function C(n, i) {
14
+ const u = [
15
+ "SELECT",
16
+ "FROM",
17
+ "WHERE",
18
+ "GROUP",
19
+ "BY",
20
+ "ORDER",
21
+ "HAVING",
22
+ "JOIN",
23
+ "LEFT",
24
+ "RIGHT",
25
+ "INNER",
26
+ "OUTER",
27
+ "ON",
28
+ "AS",
29
+ "INSERT",
30
+ "UPDATE",
31
+ "DELETE",
32
+ "CREATE",
33
+ "ALTER",
34
+ "DROP",
35
+ "TABLE",
36
+ "DATABASE",
37
+ "INDEX",
38
+ "VIEW",
39
+ "TRIGGER",
40
+ "PROCEDURE",
41
+ "FUNCTION",
42
+ "UNION",
43
+ "ALL",
44
+ "DISTINCT",
45
+ "LIMIT",
46
+ "OFFSET"
47
+ ];
48
+ n.languages.registerCompletionItemProvider("sql", {
49
+ provideCompletionItems: (o, s) => {
50
+ const r = o.getWordUntilPosition(s), a = {
51
+ startLineNumber: s.lineNumber,
52
+ endLineNumber: s.lineNumber,
53
+ startColumn: r.startColumn,
54
+ endColumn: r.endColumn
55
+ }, l = [];
56
+ return i.forEach((e) => {
57
+ l.push({
58
+ label: e.table,
59
+ kind: n.languages.CompletionItemKind.Class,
60
+ detail: "Table",
61
+ documentation: `Table Name: ${e.table}`,
62
+ insertText: e.table,
63
+ range: a
64
+ }), e.fields.forEach((t) => {
65
+ l.push({
66
+ label: `${e.table}.${t.fieldName}`,
67
+ kind: n.languages.CompletionItemKind.Field,
68
+ detail: `${t.fieldType}${t.fieldComment ? ` - ${t.fieldComment}` : ""}`,
69
+ documentation: `Field: ${t.fieldName}
70
+ Type: ${t.fieldType}
71
+ ${t.fieldComment ? `Description: ${t.fieldComment}` : ""}`,
72
+ insertText: `${e.table}.${t.fieldName}`,
73
+ range: a
74
+ });
75
+ });
76
+ }), u.forEach((e) => {
77
+ l.push({
78
+ label: e,
79
+ kind: n.languages.CompletionItemKind.Keyword,
80
+ insertText: e,
81
+ range: a
82
+ });
83
+ }), {
84
+ suggestions: l
85
+ };
86
+ }
87
+ });
88
+ }
89
+ E.config({
90
+ paths: {
91
+ vs: `${process.env.NEXT_PUBLIC_CDN_URL}/common/monaco/0.52.2/min/vs`
92
+ }
93
+ });
94
+ function $({ tables: n, theme: i, ...u }) {
95
+ const o = f(), s = d(null), r = d(null), a = N(() => i === "dark" ? "tokyo-night" : "catppuccin-latte", [i]);
96
+ return m(() => {
97
+ o && h(o);
98
+ }, [o]), m(() => {
99
+ o && n && C(o, n);
100
+ }, [o, n]), m(() => {
101
+ r.current && r.current && new ResizeObserver(() => {
102
+ var t;
103
+ (t = r.current) == null || t.layout({});
104
+ }).observe(r.current);
105
+ }, [o]), /* @__PURE__ */ c("div", { className: "h-full w-full", ref: s, children: /* @__PURE__ */ c(
106
+ g,
107
+ {
108
+ ...u,
109
+ loading: "",
110
+ language: "sql",
111
+ theme: a,
112
+ onMount: (e) => {
113
+ r.current = e;
114
+ },
115
+ options: {
116
+ ...u.options,
117
+ minimap: {
118
+ enabled: !1
119
+ },
120
+ contextmenu: !1,
121
+ suggestOnTriggerCharacters: !0,
122
+ quickSuggestions: !0,
123
+ automaticLayout: !0,
124
+ fontSize: 14,
125
+ lineNumbers: "on",
126
+ roundedSelection: !1,
127
+ scrollBeyondLastLine: !1,
128
+ cursorStyle: "line",
129
+ tabSize: 2
130
+ }
131
+ }
132
+ ) });
133
+ }
134
+ export {
135
+ $ as default
136
+ };
@@ -0,0 +1,13 @@
1
+ import type * as MonacoTypes from 'monaco-editor/esm/vs/editor/editor.api';
2
+ interface TableField {
3
+ fieldName: string;
4
+ fieldType: string;
5
+ fieldComment: string;
6
+ }
7
+ interface Table {
8
+ table: string;
9
+ fields: TableField[];
10
+ }
11
+ export default function setupSQLLanguage(monaco: typeof MonacoTypes, tables: Table[]): void;
12
+ export {};
13
+ //# sourceMappingURL=sqlLanguage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlLanguage.d.ts","sourceRoot":"","sources":["../../../src/module/suggestion/sqlLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,WAAW,MAAM,wCAAwC,CAAC;AAE3E,UAAU,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,MAAM,EAAE,OAAO,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,QAiEnF"}
@@ -0,0 +1,3 @@
1
+ declare const create: (monaco: any) => Promise<void>;
2
+ export { create };
3
+ //# sourceMappingURL=shiki.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shiki.d.ts","sourceRoot":"","sources":["../../../src/module/textmate/shiki.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,GAAU,QAAQ,GAAG,kBAQhC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@0xchain/monaco",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "!**/*.tsbuildinfo"
19
+ ],
20
+ "devDependencies": {
21
+ "rollup-plugin-preserve-use-client": "3.0.1"
22
+ },
23
+ "dependencies": {
24
+ "@monaco-editor/react": "4.7.0",
25
+ "@shikijs/monaco": "3.12.2",
26
+ "monaco-editor": "0.52.2",
27
+ "react": "19.1.1",
28
+ "shiki": "3.12.2"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ }
33
+ }