Skip to content

Commit

Permalink
Back out monaco changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr committed Dec 8, 2023
1 parent 6866807 commit a9630f9
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 211 deletions.
2 changes: 1 addition & 1 deletion apps/zui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
setupFiles: ["./src/test/unit/setup/before-env.ts"],
setupFilesAfterEnv: ["./src/test/unit/setup/after-env.ts"],
testEnvironmentOptions: {
testURL: "http://localhost:3000/?name=search&id=test-1",
testURL: "http://localhost:4567/?name=search&id=test-1",
},
globalSetup: "./src/test/unit/setup/global.ts",
modulePaths: ["<rootDir>"],
Expand Down
8 changes: 4 additions & 4 deletions apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"start": "node scripts/start",
"start:main": "yarn build:main --watch",
"start:renderer": "next dev",
"start:renderer": "next dev -p 4567",
"start:electron": "nodemon --watch dist ../../node_modules/electron/cli.js .",
"watch-code": "run-p start:main start:renderer",
"build": "run-p -l 'build:**'",
Expand Down Expand Up @@ -42,7 +42,7 @@
"@brimdata/zed-js": "workspace:*",
"@brimdata/zed-node": "workspace:*",
"@js-joda/core": "^3.2.0",
"@monaco-editor/react": "^4.5.1",
"@monaco-editor/react": "^4.6.0",
"@reduxjs/toolkit": "^1.9.3",
"@swc/cli": "^0.1.55",
"@swc/core": "^1.2.144",
Expand Down Expand Up @@ -80,7 +80,7 @@
"chrono-node": "^2.5.0",
"classnames": "^2.2.6",
"commander": "^2.20.3",
"cross-fetch": "^3.1.6",
"cross-fetch": "^3.1.6",
"d3": "^6.7.0",
"date-fns": "^2.16.1",
"decompress": "^4.2.1",
Expand Down Expand Up @@ -117,7 +117,7 @@
"memoize-one": "^6.0.0",
"moment": "^2.27.0",
"moment-timezone": "^0.5.31",
"mousetrap": "^1.6.5",
"mousetrap": "^1.6.5",
"msw": "^0.36.8",
"next": "^13.3.0",
"node-fetch": "^2.6.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/zui/src/app/query-home/search-area/zed-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function ZedEditor(props: {
minimap: {enabled: false},
renderLineHighlightOnlyWhenFocus: true,
renderControlCharacters: false,
fontSize: "14px",
fontSize: 14,
fontFamily: "var(--mono-font)",
fontVariations: "inherit",
}}
Expand Down
185 changes: 185 additions & 0 deletions apps/zui/src/core/zed-syntax.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
const primitiveTypes = [
"uint8",
"uint16",
"uint32",
"uint64",
"int8",
"int16",
"int32",
"int64",
"float16",
"float32",
"float64",
"bool",
"string",
"duration",
"time",
"bytes",
"ip",
"net",
"type",
"null",
]

const keywords = ["this", "const", "from", "file", "func", "op", "type"]

const builtinOps = [
"assert",
"combine",
"cut",
"drop",
"file",
"fork",
"from",
"fuse",
"get",
"head",
"join",
"load",
"merge",
"over",
"pass",
"put",
"rename",
"sample",
"search",
"sort",
"summarize",
"switch",
"tail",
"uniq",
"where",
"yield",
]

const builtinFuncs = [
"abs",
"base64",
"bucket",
"cast",
"ceil",
"cidr_match",
"compare",
"coalesce",
"crop",
"error",
"every",
"fields",
"fill",
"flatten",
"floor",
"grep",
"has",
"hex",
"has_error",
"is",
"is_error",
"join",
"kind",
"ksuid",
"len",
"levenshtein",
"log",
"lower",
"missing",
"nameof",
"nest_dotted",
"network_of",
"now",
"order",
"parse_uri",
"parse_zson",
"pow",
"quiet",
"regexp",
"regexp_replace",
"replace",
"round",
"rune_len",
"shape",
"split",
"sqrt",
"trim",
"typename",
"typeof",
"typeunder",
"under",
"unflatten",
"upper",
]

const builtinAggFuncs = [
"AND",
"OR",
"and",
"any",
"avg",
"collect",
"count",
"dcount",
"fuse",
"map",
"max",
"min",
"or",
"sum",
"union",
]

const operators = ["+", "-", "*", "/", ">", ">=", "<", "<=", "=", ":="]

const symbols = /[+\-*/><=:]+/

const identifier = /[a-zA-Z][\w$]*/

const identifierRule = [
identifier,
{
cases: {
"@keywords": "keyword",
"@builtinOps": "keyword",
"@builtinFuncs": "keyword",
"@builtinAggFuncs": "keyword",
"@primitiveTypes": "keyword",
"@operators": "operators",
"@default": "variable",
},
},
]

const operatorRule = [
symbols,
{
cases: {
"@operators": "operator",
"#default": "",
},
},
]

const integerRule = [/\d+/, "number"]
const floatRule = [/\d*\.\d+/, "number.float"]
const stringRule = [/("[^"]*")|('[^']*')/, "string"]
const commentRule = [/\/\/.*/, "comment"]
const bracketRule = [/[{}()[]]/, "@brackets"]

export const tokens = {
keywords,
operators,
primitiveTypes,
builtinAggFuncs,
builtinFuncs,
builtinOps,
symbols,
tokenizer: {
root: [
identifierRule,
commentRule,
bracketRule,
operatorRule,
integerRule,
floatRule,
stringRule,
] as any,
},
}
Empty file.
2 changes: 1 addition & 1 deletion apps/zui/src/electron/windows/zui-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export abstract class ZuiWindow {
load() {
this.beforeLoad()
const url = env.isDevelopment
? `http://localhost:3000${this.path}?id=${this.id}&name=${this.name}`
? `http://localhost:4567${this.path}?id=${this.id}&name=${this.name}`
: `file://${this.path}.html?id=${this.id}&name=${this.name}`
return this.ref.loadURL(url)
}
Expand Down
Loading

0 comments on commit a9630f9

Please sign in to comment.