basic working cm6 editor

This commit is contained in:
ojack
2023-07-19 18:23:25 +02:00
parent 2bf5be0eba
commit 4b34fd697f
17 changed files with 979 additions and 4 deletions

341
package-lock.json generated
View File

@@ -1,19 +1,24 @@
{ {
"name": "hydra-web-editor", "name": "hydra-web-editor",
"version": "1.4.2", "version": "1.5.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "hydra-web-editor", "name": "hydra-web-editor",
"version": "1.4.2", "version": "1.5.0",
"license": "AGPL", "license": "AGPL",
"dependencies": { "dependencies": {
"@codemirror/lang-javascript": "^6.1.9",
"@codemirror/theme-one-dark": "^6.1.2",
"@lezer/highlight": "^1.1.6",
"@management/cm-evaluate": "^0.1.0",
"acorn": "^8.7.0", "acorn": "^8.7.0",
"astravel": "^0.5.0", "astravel": "^0.5.0",
"astring": "^1.4.0", "astring": "^1.4.0",
"choo": "^7.1.0", "choo": "^7.1.0",
"choo-devtools": "^3.0.4", "choo-devtools": "^3.0.4",
"codemirror": "^6.0.1",
"codemirror-minified": "^5.65.0", "codemirror-minified": "^5.65.0",
"hydra-synth": "^1.3.27", "hydra-synth": "^1.3.27",
"i18next": "^21.6.13", "i18next": "^21.6.13",
@@ -559,6 +564,107 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@codemirror/autocomplete": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.9.0.tgz",
"integrity": "sha512-Fbwm0V/Wn3BkEJZRhr0hi5BhCo5a7eBL6LYaliPjOSwCyfOpnjXY59HruSxOUNV+1OYer0Tgx1zRNQttjXyDog==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.6.0",
"@lezer/common": "^1.0.0"
},
"peerDependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0"
}
},
"node_modules/@codemirror/commands": {
"version": "6.2.4",
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.2.4.tgz",
"integrity": "sha512-42lmDqVH0ttfilLShReLXsDfASKLXzfyC36bzwcqzox9PlHulMcsUOfHXNo2X2aFMVNUoQ7j+d4q5bnfseYoOA==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0"
}
},
"node_modules/@codemirror/lang-javascript": {
"version": "6.1.9",
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.1.9.tgz",
"integrity": "sha512-z3jdkcqOEBT2txn2a87A0jSy6Te3679wg/U8QzMeftFt+4KA6QooMwfdFzJiuC3L6fXKfTXZcDocoaxMYfGz0w==",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.6.0",
"@codemirror/lint": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/javascript": "^1.0.0"
}
},
"node_modules/@codemirror/language": {
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.8.0.tgz",
"integrity": "sha512-r1paAyWOZkfY0RaYEZj3Kul+MiQTEbDvYqf8gPGaRvNneHXCmfSaAVFjwRUPlgxS8yflMxw2CTu6uCMp8R8A2g==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0",
"style-mod": "^4.0.0"
}
},
"node_modules/@codemirror/lint": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.4.0.tgz",
"integrity": "sha512-6VZ44Ysh/Zn07xrGkdtNfmHCbGSHZzFBdzWi0pbd7chAQ/iUcpLGX99NYRZTa7Ugqg4kEHCqiHhcZnH0gLIgSg==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"
}
},
"node_modules/@codemirror/search": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.0.tgz",
"integrity": "sha512-64/M40YeJPToKvGO6p3fijo2vwUEj4nACEAXElCaYQ50HrXSvRaK+NHEhSh73WFBGdvIdhrV+lL9PdJy2RfCYA==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"
}
},
"node_modules/@codemirror/state": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.2.1.tgz",
"integrity": "sha512-RupHSZ8+OjNT38zU9fKH2sv+Dnlr8Eb8sl4NOnnqz95mCFTZUaiRP8Xv5MeeaG0px2b8Bnfe7YGwCV3nsBhbuw=="
},
"node_modules/@codemirror/theme-one-dark": {
"version": "6.1.2",
"resolved": "https://registry.npmjs.org/@codemirror/theme-one-dark/-/theme-one-dark-6.1.2.tgz",
"integrity": "sha512-F+sH0X16j/qFLMAfbciKTxVOwkdAS336b7AXTKOZhy8BR3eH/RelsnLgLFINrpST63mmN2OuwUt0W2ndUgYwUA==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/highlight": "^1.0.0"
}
},
"node_modules/@codemirror/view": {
"version": "6.15.3",
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.15.3.tgz",
"integrity": "sha512-chNgR8H7Ipx7AZUt0+Kknk7BCow/ron3mHd1VZdM7hQXiI79+UlWqcxpCiexTxZQ+iSkqndk3HHAclJOcjSuog==",
"dependencies": {
"@codemirror/state": "^6.1.4",
"style-mod": "^4.0.0",
"w3c-keyname": "^2.2.4"
}
},
"node_modules/@esbuild/android-arm": { "node_modules/@esbuild/android-arm": {
"version": "0.18.12", "version": "0.18.12",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.12.tgz", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.12.tgz",
@@ -975,6 +1081,45 @@
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
"dev": true "dev": true
}, },
"node_modules/@lezer/common": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.3.tgz",
"integrity": "sha512-JH4wAXCgUOcCGNekQPLhVeUtIqjH0yPBs7vvUdSjyQama9618IOKFJwkv2kcqdhF0my8hQEgCTEJU0GIgnahvA=="
},
"node_modules/@lezer/highlight": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.6.tgz",
"integrity": "sha512-cmSJYa2us+r3SePpRCjN5ymCqCPv+zyXmDl0ciWtVaNiORT/MxM7ZgOMQZADD0o51qOaOg24qc/zBViOIwAjJg==",
"dependencies": {
"@lezer/common": "^1.0.0"
}
},
"node_modules/@lezer/javascript": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.4.tgz",
"integrity": "sha512-0BiBjpEcrt2IXrIzEAsdTLylrVhGHRqVQL3baTBx1sf4qewjIvhG1/pTUumu7W/7YR0AASjLQOQxFmo5EvNmzQ==",
"dependencies": {
"@lezer/highlight": "^1.1.3",
"@lezer/lr": "^1.3.0"
}
},
"node_modules/@lezer/lr": {
"version": "1.3.9",
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.9.tgz",
"integrity": "sha512-XPz6dzuTHlnsbA5M2DZgjflNQ+9Hi5Swhic0RULdp3oOs3rh6bqGZolosVqN/fQIT8uNiepzINJDnS39oweTHQ==",
"dependencies": {
"@lezer/common": "^1.0.0"
}
},
"node_modules/@management/cm-evaluate": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@management/cm-evaluate/-/cm-evaluate-0.1.0.tgz",
"integrity": "sha512-hjqNjdDUcqpI7kp5yYArWWWZF3XgN35gaezmManAzhU+hYOOuuodPFMEgGfbzcUj/yag2k3eQBf/D3FgOFeXzQ==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"node_modules/abbrev": { "node_modules/abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -1907,6 +2052,20 @@
"node": ">=0.8" "node": ">=0.8"
} }
}, },
"node_modules/codemirror": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz",
"integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/commands": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/lint": "^6.0.0",
"@codemirror/search": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"node_modules/codemirror-minified": { "node_modules/codemirror-minified": {
"version": "5.65.9", "version": "5.65.9",
"resolved": "https://registry.npmjs.org/codemirror-minified/-/codemirror-minified-5.65.9.tgz", "resolved": "https://registry.npmjs.org/codemirror-minified/-/codemirror-minified-5.65.9.tgz",
@@ -2091,6 +2250,11 @@
"sha.js": "^2.4.8" "sha.js": "^2.4.8"
} }
}, },
"node_modules/crelt": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
},
"node_modules/cross-fetch": { "node_modules/cross-fetch": {
"version": "3.1.5", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
@@ -5014,6 +5178,11 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/style-mod": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.0.3.tgz",
"integrity": "sha512-78Jv8kYJdjbvRwwijtCevYADfsI0lGzYJe4mMFdceO8l75DFFDoqBhR1jVDicDRRaX4//g1u9wKeo+ztc2h1Rw=="
},
"node_modules/subarg": { "node_modules/subarg": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
@@ -5461,6 +5630,11 @@
"integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==",
"dev": true "dev": true
}, },
"node_modules/w3c-keyname": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
},
"node_modules/watchify": { "node_modules/watchify": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/watchify/-/watchify-4.0.0.tgz", "resolved": "https://registry.npmjs.org/watchify/-/watchify-4.0.0.tgz",
@@ -6111,6 +6285,101 @@
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
} }
}, },
"@codemirror/autocomplete": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.9.0.tgz",
"integrity": "sha512-Fbwm0V/Wn3BkEJZRhr0hi5BhCo5a7eBL6LYaliPjOSwCyfOpnjXY59HruSxOUNV+1OYer0Tgx1zRNQttjXyDog==",
"requires": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.6.0",
"@lezer/common": "^1.0.0"
}
},
"@codemirror/commands": {
"version": "6.2.4",
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.2.4.tgz",
"integrity": "sha512-42lmDqVH0ttfilLShReLXsDfASKLXzfyC36bzwcqzox9PlHulMcsUOfHXNo2X2aFMVNUoQ7j+d4q5bnfseYoOA==",
"requires": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0"
}
},
"@codemirror/lang-javascript": {
"version": "6.1.9",
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.1.9.tgz",
"integrity": "sha512-z3jdkcqOEBT2txn2a87A0jSy6Te3679wg/U8QzMeftFt+4KA6QooMwfdFzJiuC3L6fXKfTXZcDocoaxMYfGz0w==",
"requires": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.6.0",
"@codemirror/lint": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/javascript": "^1.0.0"
}
},
"@codemirror/language": {
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.8.0.tgz",
"integrity": "sha512-r1paAyWOZkfY0RaYEZj3Kul+MiQTEbDvYqf8gPGaRvNneHXCmfSaAVFjwRUPlgxS8yflMxw2CTu6uCMp8R8A2g==",
"requires": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0",
"style-mod": "^4.0.0"
}
},
"@codemirror/lint": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.4.0.tgz",
"integrity": "sha512-6VZ44Ysh/Zn07xrGkdtNfmHCbGSHZzFBdzWi0pbd7chAQ/iUcpLGX99NYRZTa7Ugqg4kEHCqiHhcZnH0gLIgSg==",
"requires": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"
}
},
"@codemirror/search": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.0.tgz",
"integrity": "sha512-64/M40YeJPToKvGO6p3fijo2vwUEj4nACEAXElCaYQ50HrXSvRaK+NHEhSh73WFBGdvIdhrV+lL9PdJy2RfCYA==",
"requires": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"
}
},
"@codemirror/state": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.2.1.tgz",
"integrity": "sha512-RupHSZ8+OjNT38zU9fKH2sv+Dnlr8Eb8sl4NOnnqz95mCFTZUaiRP8Xv5MeeaG0px2b8Bnfe7YGwCV3nsBhbuw=="
},
"@codemirror/theme-one-dark": {
"version": "6.1.2",
"resolved": "https://registry.npmjs.org/@codemirror/theme-one-dark/-/theme-one-dark-6.1.2.tgz",
"integrity": "sha512-F+sH0X16j/qFLMAfbciKTxVOwkdAS336b7AXTKOZhy8BR3eH/RelsnLgLFINrpST63mmN2OuwUt0W2ndUgYwUA==",
"requires": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/highlight": "^1.0.0"
}
},
"@codemirror/view": {
"version": "6.15.3",
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.15.3.tgz",
"integrity": "sha512-chNgR8H7Ipx7AZUt0+Kknk7BCow/ron3mHd1VZdM7hQXiI79+UlWqcxpCiexTxZQ+iSkqndk3HHAclJOcjSuog==",
"requires": {
"@codemirror/state": "^6.1.4",
"style-mod": "^4.0.0",
"w3c-keyname": "^2.2.4"
}
},
"@esbuild/android-arm": { "@esbuild/android-arm": {
"version": "0.18.12", "version": "0.18.12",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.12.tgz", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.12.tgz",
@@ -6322,6 +6591,45 @@
} }
} }
}, },
"@lezer/common": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.3.tgz",
"integrity": "sha512-JH4wAXCgUOcCGNekQPLhVeUtIqjH0yPBs7vvUdSjyQama9618IOKFJwkv2kcqdhF0my8hQEgCTEJU0GIgnahvA=="
},
"@lezer/highlight": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.6.tgz",
"integrity": "sha512-cmSJYa2us+r3SePpRCjN5ymCqCPv+zyXmDl0ciWtVaNiORT/MxM7ZgOMQZADD0o51qOaOg24qc/zBViOIwAjJg==",
"requires": {
"@lezer/common": "^1.0.0"
}
},
"@lezer/javascript": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.4.tgz",
"integrity": "sha512-0BiBjpEcrt2IXrIzEAsdTLylrVhGHRqVQL3baTBx1sf4qewjIvhG1/pTUumu7W/7YR0AASjLQOQxFmo5EvNmzQ==",
"requires": {
"@lezer/highlight": "^1.1.3",
"@lezer/lr": "^1.3.0"
}
},
"@lezer/lr": {
"version": "1.3.9",
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.9.tgz",
"integrity": "sha512-XPz6dzuTHlnsbA5M2DZgjflNQ+9Hi5Swhic0RULdp3oOs3rh6bqGZolosVqN/fQIT8uNiepzINJDnS39oweTHQ==",
"requires": {
"@lezer/common": "^1.0.0"
}
},
"@management/cm-evaluate": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@management/cm-evaluate/-/cm-evaluate-0.1.0.tgz",
"integrity": "sha512-hjqNjdDUcqpI7kp5yYArWWWZF3XgN35gaezmManAzhU+hYOOuuodPFMEgGfbzcUj/yag2k3eQBf/D3FgOFeXzQ==",
"requires": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"abbrev": { "abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -7097,6 +7405,20 @@
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==" "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="
}, },
"codemirror": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz",
"integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==",
"requires": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/commands": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/lint": "^6.0.0",
"@codemirror/search": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"codemirror-minified": { "codemirror-minified": {
"version": "5.65.9", "version": "5.65.9",
"resolved": "https://registry.npmjs.org/codemirror-minified/-/codemirror-minified-5.65.9.tgz", "resolved": "https://registry.npmjs.org/codemirror-minified/-/codemirror-minified-5.65.9.tgz",
@@ -7269,6 +7591,11 @@
"sha.js": "^2.4.8" "sha.js": "^2.4.8"
} }
}, },
"crelt": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
},
"cross-fetch": { "cross-fetch": {
"version": "3.1.5", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
@@ -9615,6 +9942,11 @@
"ansi-regex": "^5.0.1" "ansi-regex": "^5.0.1"
} }
}, },
"style-mod": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.0.3.tgz",
"integrity": "sha512-78Jv8kYJdjbvRwwijtCevYADfsI0lGzYJe4mMFdceO8l75DFFDoqBhR1jVDicDRRaX4//g1u9wKeo+ztc2h1Rw=="
},
"subarg": { "subarg": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
@@ -9921,6 +10253,11 @@
"integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==",
"dev": true "dev": true
}, },
"w3c-keyname": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
},
"watchify": { "watchify": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/watchify/-/watchify-4.0.0.tgz", "resolved": "https://registry.npmjs.org/watchify/-/watchify-4.0.0.tgz",

View File

@@ -12,11 +12,16 @@
"author": "", "author": "",
"license": "AGPL", "license": "AGPL",
"dependencies": { "dependencies": {
"@codemirror/lang-javascript": "^6.1.9",
"@codemirror/theme-one-dark": "^6.1.2",
"@lezer/highlight": "^1.1.6",
"@management/cm-evaluate": "^0.1.0",
"acorn": "^8.7.0", "acorn": "^8.7.0",
"astravel": "^0.5.0", "astravel": "^0.5.0",
"astring": "^1.4.0", "astring": "^1.4.0",
"choo": "^7.1.0", "choo": "^7.1.0",
"choo-devtools": "^3.0.4", "choo-devtools": "^3.0.4",
"codemirror": "^6.0.1",
"codemirror-minified": "^5.65.0", "codemirror-minified": "^5.65.0",
"hydra-synth": "^1.3.27", "hydra-synth": "^1.3.27",
"i18next": "^21.6.13", "i18next": "^21.6.13",

View File

@@ -2,7 +2,7 @@ import repl from '../views/editor/repl.js'
// console.log('ENVIRONMENT IS', process.env.NODE_ENV) // console.log('ENVIRONMENT IS', process.env.NODE_ENV)
export default function store(state, emitter) { export default function store(state, emitter) {
state.showInfo = true state.showInfo = false
state.showUI = true state.showUI = true
state.showExtensions = false state.showExtensions = false

54
src/views/EditorCm6.js Normal file
View File

@@ -0,0 +1,54 @@
import html from 'choo/html'
import Component from 'choo/component'
// import HydraEditor from './editor/editor.js'
import HydraEditor from './cm6-editor/editor.js'
import log from './editor/log.js'
export default class Editor extends Component {
constructor (id, state, emit) {
super(id)
this.local = state.components[id] = {}
state.editor = this // hacky way fo sharing editor to rest of app
this.emit = emit
}
load (element) {
log.init(this.logElement)
this.editor = new HydraEditor(this.textEl, this.emit)
this.editor.on("*", (e, args) => {
this.emit(e, args)
})
// hacky, maybe not necessary
// this.innerText = document.getElementsByClassName('CodeMirror')[0]
this.textEl.style.transition = 'opacity 0.5s'
}
hide() {
this.textEl.style.opacity = 0
}
show() {
this.textEl.style.opacity = 1
this.textEl.style.pointerEvents = 'all'
}
update (state) {
if(state.showInfo === true && state.showExtensions === false || state.showUI === false) {
this.hide()
} else {
this.show()
}
return false
}
createElement ({ width = window.innerWidth, height = window.innerHeight} = {}) {
this.textEl = html` <div></div>`
this.logElement = html`<div class="console cm-s-tomorrow-night-eighties"></div>`
return html`<div id="editor-container" style="display:flex;flex-direction:column;">
<div style="position:relative;flex:auto;padding:15px">${this.textEl}</div>
${this.logElement}
</div>`
}
}

View File

@@ -3,6 +3,7 @@
import html from 'choo/html' import html from 'choo/html'
import Component from 'choo/component' import Component from 'choo/component'
import HydraEditor from './editor/editor.js' import HydraEditor from './editor/editor.js'
// import HydraEditor from './editor-cm6/editor.js'
import log from './editor/log.js' import log from './editor/log.js'
export default class Editor extends Component { export default class Editor extends Component {

View File

@@ -0,0 +1,33 @@
import { getLine, getBlock, getSelection, getAll } from './flash-code/flashKeymaps.js'
import hydraKeys from './_____keymap-config.js'
// let evalLinter = new Compartment
export default Object.entries(hydraKeys).map(([key, val]) => ({
key: key,
run: (view) => {
console.log('called event', val, view)
let text = ''
if (val === 'editor:evalLine') {
text = getLine(view)
} else if (val === 'editor:evalBlock') {
text = getBlock(view)
} else if (val === 'editor:evalAll') {
text = getAll(view)
} else if (val === 'hideAll') {
// self.toggle()
} else if (val === 'editor:formatCode') {
// console.log('format code!')
// self.formatCode()
} else if (val == 'editor:saveToLocalStorage') {
// this.emit('editor:save', this.cm.state.doc.toString())
}
// self.emit(val, text)
// setTimeout(() => {
// view.dispatch({
// effects: evalLinter.reconfigure(linter(jsLinter()))
// })
// forceLinting(self.cm)
//}, 100)
}
}))

View File

@@ -0,0 +1,15 @@
export default {
'Ctrl-Enter': 'editor:evalLine',
'Ctrl-/': 'editor:toggleComment',
'Alt-Enter': 'editor:evalBlock',
'Shift-Ctrl-Enter': 'editor:evalAll',
'Shift-Ctrl-g': 'gallery:shareSketch',
'Shift-Ctrl-f': 'editor:formatCode',
'Shift-Ctrl-d': 'editor:formatCode',
'Shift-Ctrl-l': 'gallery:saveToURL',
'Shift-Ctrl-h': 'hideAll',
'Shift-Ctrl-s': 'screencap',
'Ctrl--': 'editor:zoomOut',
'Ctrl-=': 'editor:zoomIn',
'Ctrl-S': 'editor:saveToLocalStorage'
}

View File

@@ -0,0 +1,105 @@
import {keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor,
rectangularSelection, crosshairCursor,
lineNumbers, highlightActiveLineGutter} from "@codemirror/view"
import { EditorState} from "@codemirror/state"
import {defaultHighlightStyle, syntaxHighlighting, indentOnInput, bracketMatching,
foldGutter, foldKeymap} from "@codemirror/language"
import {defaultKeymap, history, historyKeymap} from "@codemirror/commands"
import {searchKeymap, highlightSelectionMatches} from "@codemirror/search"
import {autocompletion, completionKeymap, closeBrackets, closeBracketsKeymap} from "@codemirror/autocomplete"
import {lintKeymap} from "@codemirror/lint"
import { oneDark, oneDarkHighlightStyle } from '@codemirror/theme-one-dark';
import { hydraSyntaxStyle, hydraEditorTheme } from "./hydra-cm6-theme.js";
import { flashTheme } from './flash-code/flashTheme.js';
import { flash } from './flash-code'
// (The superfluous function calls around the list of extensions work
// around current limitations in tree-shaking software.)
/// This is an extension value that just pulls together a number of
/// extensions that you might want in a basic editor. It is meant as a
/// convenient helper to quickly set up CodeMirror without installing
/// and importing a lot of separate packages.
///
/// Specifically, it includes...
///
/// - [the default command bindings](#commands.defaultKeymap)
/// - [line numbers](#view.lineNumbers)
/// - [special character highlighting](#view.highlightSpecialChars)
/// - [the undo history](#commands.history)
/// - [a fold gutter](#language.foldGutter)
/// - [custom selection drawing](#view.drawSelection)
/// - [drop cursor](#view.dropCursor)
/// - [multiple selections](#state.EditorState^allowMultipleSelections)
/// - [reindentation on input](#language.indentOnInput)
/// - [the default highlight style](#language.defaultHighlightStyle) (as fallback)
/// - [bracket matching](#language.bracketMatching)
/// - [bracket closing](#autocomplete.closeBrackets)
/// - [autocompletion](#autocomplete.autocompletion)
/// - [rectangular selection](#view.rectangularSelection) and [crosshair cursor](#view.crosshairCursor)
/// - [active line highlighting](#view.highlightActiveLine)
/// - [active line gutter highlighting](#view.highlightActiveLineGutter)
/// - [selection match highlighting](#search.highlightSelectionMatches)
/// - [search](#search.searchKeymap)
/// - [linting](#lint.lintKeymap)
///
/// (You'll probably want to add some language package to your setup
/// too.)
///
/// This extension does not allow customization. The idea is that,
/// once you decide you want to configure your editor more precisely,
/// you take this package's source (which is just a bunch of imports
/// and an array literal), copy it into your own code, and adjust it
/// as desired.
export const hydraSetup = (() => [
// lineNumbers(),
highlightActiveLineGutter(),
highlightSpecialChars(),
history(),
// foldGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
indentOnInput(),
syntaxHighlighting(hydraSyntaxStyle),
syntaxHighlighting(oneDarkHighlightStyle, {fallback: true}),
bracketMatching(),
closeBrackets(),
autocompletion(),
rectangularSelection(),
crosshairCursor(),
// highlightActiveLine(),
flash(),
highlightSelectionMatches(),
keymap.of([
...closeBracketsKeymap,
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap
]),
flashTheme,
oneDark,
hydraEditorTheme
])()
/// A minimal set of extensions to create a functional editor. Only
/// includes [the default keymap](#commands.defaultKeymap), [undo
/// history](#commands.history), [special character
/// highlighting](#view.highlightSpecialChars), [custom selection
/// drawing](#view.drawSelection), and [default highlight
/// style](#language.defaultHighlightStyle).
export const minimalSetup = (() => [
highlightSpecialChars(),
history(),
drawSelection(),
syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
keymap.of([
...defaultKeymap,
...historyKeymap,
])
])()
export {EditorView} from "@codemirror/view"

View File

@@ -0,0 +1,87 @@
/* eslint-disable no-eval */
import {EditorView, basicSetup} from "codemirror"
import { placeholder, keymap } from "@codemirror/view"
import { hydraSetup } from "./editor-setup.js"
import {javascript} from "@codemirror/lang-javascript"
import EventEmitter from 'nanobus'
import { hydraEval as evaluation } from "./hydra-eval.js";
export default class Editor extends EventEmitter {
constructor(parent, emit) {
super()
console.log("*** Editor class created");
var self = this
let view = new EditorView({
extensions: [
hydraSetup,
javascript(),
placeholder('//'),
evaluation((code) => {
console.log('EVALUATED')
emit('repl: eval', code)
// @todo !! need access to current vie in order to pass info to linter
// view.dispatch({
// effects: evalLinter.reconfigure(linter(jsLinter()))
// })
}),
],
parent: parent,
})
console.warn('loading editor')
}
clear() {
}
setValue(val) {
}
getValue() {
}
formatCode() {
}
addCodeToTop(code = '') {
}
// hide() {
// console.log('hiding')
// var l = document.getElementsByClassName('CodeMirror')[0]
// var m = document.getElementById('modal-header')
// l.style.opacity = 0
// m.style.opacity = 0
// this.isShowing = false
// }
// show() {
// var l = document.getElementsByClassName('CodeMirror')[0]
// var m = document.getElementById('modal-header')
// l.style.opacity= 1
// m.style.opacity = 1
// l.style.pointerEvents = 'all'
// this.isShowing = true
// }
toggle() {
}
getLine() {
}
flashCode(start, end) {
}
getCurrentBlock() { // thanks to graham wakefield + gibber
}
}

View File

@@ -0,0 +1,36 @@
import { ViewPlugin, ViewUpdate, Decoration } from "@codemirror/view";
import { Transaction } from "@codemirror/state";
import { flashEffect } from "./flash";
export function flashDecoration() {
const lifespan = 500;
return ViewPlugin.fromClass(
class {
decorations = Decoration.none;
update({ transactions }) {
for (let tr of transactions) {
this.decorations = this.decorations.map(tr.changes);
this.decorations = this.decorations.update({
add: tr.effects
.filter((e) => e.is(flashEffect) && e.value.from !== e.value.to)
.map(({ value: { from, to } }) =>
Decoration.mark({
class: "cm-evaluated",
time: tr.annotation(Transaction.time),
}).range(from, to)
),
sort: true,
filter: (_f, _t, { spec: { time } }) => {
return typeof time === "number" && time + lifespan > Date.now();
},
});
}
}
},
{ decorations: (v) => v.decorations }
);
}

View File

@@ -0,0 +1,18 @@
import { EditorState, StateEffect } from "@codemirror/state";
export const flashEffect = StateEffect.define();
// export type flashHandler = (code) => void;
export function flashAction(action = () => {}) {
return EditorState.transactionExtender.of((tr) => {
for (let effect of tr.effects) {
if (effect.is(flashEffect)) {
let { from, to } = effect.value;
action(tr.newDoc.sliceString(from, to));
}
}
return null;
});
}

View File

@@ -0,0 +1,73 @@
// import { EditorView, KeyBinding } from "@codemirror/view";
import { flashEffect, flashAction } from "./flash";
// import { sendOSC } from "../../client/osc";
// from https://github.com/mindofmatthew/text.management/blob/main/app/codemirror/evaluate/commands.ts
export function getSelection({ state, dispatch }) {
if (state.selection.main.empty) return false;
dispatch({ effects: flashEffect.of(state.selection.main) });
//return true;
let { from, to } = state.selection.main;
let text = state.doc.sliceString(from, to);
return text
// return sendOSC("/tidal/code", text);
}
export function getLine({ state, dispatch }) {
const line = state.doc.lineAt(state.selection.main.from);
dispatch({ effects: flashEffect.of(line) });
//return true;
//TODO: Move this away
let { from, to } = line;
let text = state.doc.sliceString(from, to);
console.log('running get line')
return text
//return sendOSC("/tidal/code", text);
}
export function getAll({ state, view, dispatch }, showHighlight = true) {
// const { from, to } = state.doc.visibleRanges
// console.log('RANGES', state.doc.visibleRanges, state.doc, state, view)
if(showHighlight) dispatch({ effects: flashEffect.of({ from : 0, to: state.doc.length}) });
return state.doc.toString()
}
export function getBlock({ state, dispatch }) {
let { doc, selection } = state;
let { text, number } = state.doc.lineAt(selection.main.from);
if (text.trim().length === 0) return true;
let fromL, toL;
fromL = toL = number;
while (fromL > 1 && doc.line(fromL - 1).text.trim().length > 0) {
fromL -= 1;
}
while (toL < doc.lines && doc.line(toL + 1).text.trim().length > 0) {
toL += 1;
}
let { from } = doc.line(fromL);
let { to } = doc.line(toL);
// console.log('DISPATCHING FLASH EFFECT')
dispatch({ effects: flashEffect.of({ from, to }) });
// dispatch({ effects: flashAction(flashEffect.of({ from, to })) });
//return true;
//TODO: Move this away
text = state.doc.sliceString(from, to);
//return sendOSC("/tidal/code", text);
return text
}
// export const evalKeymap = [
// { key: "Shift-Enter", run: evaluateSelection },
// { key: "Mod-Enter", run: evaluateSelection },
// { key: "Shift-Enter", run: evaluateLine },
// { key: "Ctrl-Enter", run: evaluateLine },
// { key: "Mod-Enter", run: evaluateBlock },
// ];

View File

@@ -0,0 +1,9 @@
import { EditorView } from "@codemirror/view";
export const flashTheme = EditorView.theme({
"@keyframes cm-eval-flash": {
from: { backgroundColor: "#FFFFFF" },
to: { backgroundColor: "#FFFFFF00" },
},
"& .cm-evaluated": { animation: "cm-eval-flash 0.7s" },
});

View File

@@ -0,0 +1,21 @@
import { keymap } from "@codemirror/view";
// import { Extension } from "@codemirror/state";
import { flashAction } from "./flash";
// import { flashKeymap } from "./flashKeymaps";
import { flashDecoration } from "./decoration";
// import { flashTheme } from "./theme";
export * from "./flash";
export * from "./flashKeymaps";
export { flashDecoration } from "./decoration";
// export { evalTheme } from "./theme";
export function flash(action){
return [
flashAction(action),
flashDecoration(),
// evalTheme,
// keymap.of(evalKeymap),
];
}

View File

@@ -0,0 +1,144 @@
import { EditorView } from "@codemirror/view"
import { HighlightStyle } from "@codemirror/language"
import { tags as t } from "@lezer/highlight"
export const hydraSyntaxStyle = HighlightStyle.define([
{
tag: t.keyword,
color: 'white'
},
{ tag: t.name, color: 'pink' },
{
tag: [t.deleted, t.character, t.propertyName, t.macroName],
color: 'white'
},
{
tag: [t.function(t.variableName), t.labelName],
color: 'white'
},
{
tag: [t.color, t.constant(t.name), t.standard(t.name)],
color: '#ff0'
},
{
tag: [t.definition(t.name), t.separator],
color: 'white'
},
])
export const hydraEditorTheme = EditorView.theme({
'&': {
backgroundColor: 'transparent !important',
fontSize: '20px',
// color: 'white',
fontFamily: `'Roboto Mono', monospace`,
// mixBlendMode: 'difference'
},
'& .cm-editor': {
backgroundColor: 'transparent',
},
'& .cm-scroller': {
fontFamily: `'Roboto Mono', monospace`
},
'& .cm-focused': {
background: 'hsla(50,23%,5%,0.6)',
},
'& .cm-line': {
maxWidth: 'fit-content',
background: 'hsla(50,23%,5%,0.6)',
padding: '0px'
/// background: 'rgba(0, 0, 0, 1)'
// background: 'blue'
},
'.ͼo .cm-activeLine': {
backgroundColor: 'hsla(50,23%,5%,0.6)',
// background: 'red',
// color: 'black'
},
'& .ͼo': {
color: 'white'
},
'& .cm-tooltip.cm-tooltip-autocomplete > ul': {
minWidth: '80px',
fontFamily: `'Roboto Mono', monospace`
},
'&.cm-focused': {
outline: 'none',
},
'& .cm-gutters': {
background: 'none'
},
'& .cm-tooltip': {
background: `rgba(0, 0, 0, 0.5)`,
// color: '#abb2bf'
},
'& .cm-tooltip-autocomplete > ul > li[aria-selected]': {
color: 'white',
// color: '#abb2bf',
backgroundColor: 'rgba(255, 0, 0, 0.7)'
},
'.cm-completionInfo': {
// fontFamily: 'monospace',
fontFamily: `'Roboto Mono', monospace`,
fontStyle: 'italic',
// color: '#abb2bf',
padding: '1.5px 9px'
},
'.cm-completionIcon': {
width: '4px',
height: '10px',
opacity: 1,
paddingRight: '0px',
marginRight: '6px'
},
'.cm-completionIcon-src': {
backgroundColor: 'orange',
},
'.cm-completionIcon-coord': {
backgroundColor: 'yellow',
},
'.cm-completionIcon-color': {
backgroundColor: 'lightgreen',
},
'.cm-completionIcon-combine': {
backgroundColor: 'lightblue',
},
'.cm-completionIcon-combineCoord': {
backgroundColor: 'purple',
},
'.cm-completionIcon-src:after': {
content: 'ƒ'
},
// linter styles
'.cm-panels': {
background: 'none',
},
'.cm-panels.cm-panels-bottom': {
border: 'none'
},
'.cm-diagnostic-info': {
border: 'none',
},
'.cm-diagnostic-error': {
background: 'none',
color: 'red'
},
'.cm-panel.cm-panel-lint ul [aria-selected]': {
backgroundColor: 'rgba(0, 0, 0, 0)'
},
'.cm-lint-marker-info': {
content: 'none'
},
'.cm-cursor': {
borderLeft: '4px solid white',
borderRight: '4px solid black'
}
// '.ͼ1 .cm-panel.cm-panel-lint ul [aria-selected]': {
// background: 'none',
// color: 'red'
// }
// // adds word wrapping
// '.cm-content': {
// whiteSpace: 'pre-wrap'
// }
})

View File

@@ -0,0 +1,35 @@
// import { evalAction, evalDecoration, evalEffect, evalTheme, evalLine, evalBlock } from "@management/cm-evaluate";
import { flashAction as evalAction, flashEffect as evalEffect, getLine as evalLine, getBlock as evalBlock } from "./flash-code";
import { keymap } from "@codemirror/view"
// import obj from "@management/cm-evaluate";
function evalAll({ state, dispatch }) {
// const { from, to } = state.doc.visibleRanges
// console.log('RANGES', state.doc.visibleRanges, state.doc, state, view)
dispatch({ effects: evalEffect.of({ from : 0, to: state.doc.length}) });
// return state.doc.toString()
return true
}
const hydraKeymap = [
// { key: "Shift-Enter", run: evaluateSelection },
// { key: "Mod-Enter", run: evaluateSelection },
// 'Ctrl-/': 'editor:toggleComment',
// 'Alt-Enter': 'editor:evalBlock',
// 'Shift-Ctrl-Enter': 'editor:evalAll',
{ key: "Shift-Ctrl-Enter", run: evalAll },
{ key: "Ctrl-Enter", run: evalLine },
{ key: "Alt-Enter", run: evalBlock },
];
// console.log('DEFAULT EXPORT', obj)
export function hydraEval(action) {
return [
evalAction(action),
// evalDecoration(),
// evalTheme,
keymap.of(hydraKeymap),
]
}

View File

@@ -1,7 +1,9 @@
import html from 'choo/html' import html from 'choo/html'
import info from './info.js' import info from './info.js'
import Hydra from './Hydra.js' import Hydra from './Hydra.js'
import Editor from './EditorComponent.js' // import Editor from './EditorComponent.js'
import Editor from './EditorCm6.js'
export default function mainView(state, emit) { export default function mainView(state, emit) {
return html` return html`