Resolve "Monaco Playground Typing and Rollup Bundles"

This commit is contained in:
2025-07-13 06:17:53 +00:00
committed by Jim Hamill
parent 50fb4020b6
commit aa3967a060
14 changed files with 572 additions and 225 deletions
+197 -116
View File
@@ -332,6 +332,7 @@
"version": "7.25.9",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",
"integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -341,6 +342,7 @@
"version": "7.25.9",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",
"integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -350,6 +352,7 @@
"version": "7.26.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz",
"integrity": "sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.26.3"
@@ -365,6 +368,7 @@
"version": "7.26.3",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz",
"integrity": "sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.25.9",
@@ -1475,6 +1479,7 @@
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
"integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
"dev": true,
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
@@ -1658,6 +1663,15 @@
"langium": "3.0.0"
}
},
"node_modules/@monaco-editor/loader": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.5.0.tgz",
"integrity": "sha512-hKoGSM+7aAc7eRTRjpqAZucPmoNOC4UUbknb/VNoTkEIkCPhqV8LfbsgM1webRM7S/z21eHEx9Fkwx8Z/C/+Xw==",
"license": "MIT",
"dependencies": {
"state-local": "^1.0.6"
}
},
"node_modules/@monsterbitar/isomorphic-ws": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@monsterbitar/isomorphic-ws/-/isomorphic-ws-5.3.1.tgz",
@@ -2550,9 +2564,9 @@
}
},
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.28.1.tgz",
"integrity": "sha512-2aZp8AES04KI2dy3Ss6/MDjXbwBzj+i0GqKtWXgw2/Ma6E4jJvujryO6gJAghIRVz7Vwr9Gtl/8na3nDUKpraQ==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.45.0.tgz",
"integrity": "sha512-2o/FgACbji4tW1dzXOqAV15Eu7DdgbKsF2QKcxfG4xbh5iwU7yr5RRP5/U+0asQliSYv5M4o7BevlGIoSL0LXg==",
"cpu": [
"arm"
],
@@ -2564,9 +2578,9 @@
]
},
"node_modules/@rollup/rollup-android-arm64": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.28.1.tgz",
"integrity": "sha512-EbkK285O+1YMrg57xVA+Dp0tDBRB93/BZKph9XhMjezf6F4TpYjaUSuPt5J0fZXlSag0LmZAsTmdGGqPp4pQFA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.45.0.tgz",
"integrity": "sha512-PSZ0SvMOjEAxwZeTx32eI/j5xSYtDCRxGu5k9zvzoY77xUNssZM+WV6HYBLROpY5CkXsbQjvz40fBb7WPwDqtQ==",
"cpu": [
"arm64"
],
@@ -2578,9 +2592,9 @@
]
},
"node_modules/@rollup/rollup-darwin-arm64": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.28.1.tgz",
"integrity": "sha512-prduvrMKU6NzMq6nxzQw445zXgaDBbMQvmKSJaxpaZ5R1QDM8w+eGxo6Y/jhT/cLoCvnZI42oEqf9KQNYz1fqQ==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.45.0.tgz",
"integrity": "sha512-BA4yPIPssPB2aRAWzmqzQ3y2/KotkLyZukVB7j3psK/U3nVJdceo6qr9pLM2xN6iRP/wKfxEbOb1yrlZH6sYZg==",
"cpu": [
"arm64"
],
@@ -2592,9 +2606,9 @@
]
},
"node_modules/@rollup/rollup-darwin-x64": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.28.1.tgz",
"integrity": "sha512-WsvbOunsUk0wccO/TV4o7IKgloJ942hVFK1CLatwv6TJspcCZb9umQkPdvB7FihmdxgaKR5JyxDjWpCOp4uZlQ==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.45.0.tgz",
"integrity": "sha512-Pr2o0lvTwsiG4HCr43Zy9xXrHspyMvsvEw4FwKYqhli4FuLE5FjcZzuQ4cfPe0iUFCvSQG6lACI0xj74FDZKRA==",
"cpu": [
"x64"
],
@@ -2606,9 +2620,9 @@
]
},
"node_modules/@rollup/rollup-freebsd-arm64": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.28.1.tgz",
"integrity": "sha512-HTDPdY1caUcU4qK23FeeGxCdJF64cKkqajU0iBnTVxS8F7H/7BewvYoG+va1KPSL63kQ1PGNyiwKOfReavzvNA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.45.0.tgz",
"integrity": "sha512-lYE8LkE5h4a/+6VnnLiL14zWMPnx6wNbDG23GcYFpRW1V9hYWHAw9lBZ6ZUIrOaoK7NliF1sdwYGiVmziUF4vA==",
"cpu": [
"arm64"
],
@@ -2620,9 +2634,9 @@
]
},
"node_modules/@rollup/rollup-freebsd-x64": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.28.1.tgz",
"integrity": "sha512-m/uYasxkUevcFTeRSM9TeLyPe2QDuqtjkeoTpP9SW0XxUWfcYrGDMkO/m2tTw+4NMAF9P2fU3Mw4ahNvo7QmsQ==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.45.0.tgz",
"integrity": "sha512-PVQWZK9sbzpvqC9Q0GlehNNSVHR+4m7+wET+7FgSnKG3ci5nAMgGmr9mGBXzAuE5SvguCKJ6mHL6vq1JaJ/gvw==",
"cpu": [
"x64"
],
@@ -2634,9 +2648,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.28.1.tgz",
"integrity": "sha512-QAg11ZIt6mcmzpNE6JZBpKfJaKkqTm1A9+y9O+frdZJEuhQxiugM05gnCWiANHj4RmbgeVJpTdmKRmH/a+0QbA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.45.0.tgz",
"integrity": "sha512-hLrmRl53prCcD+YXTfNvXd776HTxNh8wPAMllusQ+amcQmtgo3V5i/nkhPN6FakW+QVLoUUr2AsbtIRPFU3xIA==",
"cpu": [
"arm"
],
@@ -2648,9 +2662,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.28.1.tgz",
"integrity": "sha512-dRP9PEBfolq1dmMcFqbEPSd9VlRuVWEGSmbxVEfiq2cs2jlZAl0YNxFzAQS2OrQmsLBLAATDMb3Z6MFv5vOcXg==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.45.0.tgz",
"integrity": "sha512-XBKGSYcrkdiRRjl+8XvrUR3AosXU0NvF7VuqMsm7s5nRy+nt58ZMB19Jdp1RdqewLcaYnpk8zeVs/4MlLZEJxw==",
"cpu": [
"arm"
],
@@ -2662,9 +2676,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm64-gnu": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.28.1.tgz",
"integrity": "sha512-uGr8khxO+CKT4XU8ZUH1TTEUtlktK6Kgtv0+6bIFSeiSlnGJHG1tSFSjm41uQ9sAO/5ULx9mWOz70jYLyv1QkA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.45.0.tgz",
"integrity": "sha512-fRvZZPUiBz7NztBE/2QnCS5AtqLVhXmUOPj9IHlfGEXkapgImf4W9+FSkL8cWqoAjozyUzqFmSc4zh2ooaeF6g==",
"cpu": [
"arm64"
],
@@ -2676,9 +2690,9 @@
]
},
"node_modules/@rollup/rollup-linux-arm64-musl": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.28.1.tgz",
"integrity": "sha512-QF54q8MYGAqMLrX2t7tNpi01nvq5RI59UBNx+3+37zoKX5KViPo/gk2QLhsuqok05sSCRluj0D00LzCwBikb0A==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.45.0.tgz",
"integrity": "sha512-Btv2WRZOcUGi8XU80XwIvzTg4U6+l6D0V6sZTrZx214nrwxw5nAi8hysaXj/mctyClWgesyuxbeLylCBNauimg==",
"cpu": [
"arm64"
],
@@ -2690,9 +2704,9 @@
]
},
"node_modules/@rollup/rollup-linux-loongarch64-gnu": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.28.1.tgz",
"integrity": "sha512-vPul4uodvWvLhRco2w0GcyZcdyBfpfDRgNKU+p35AWEbJ/HPs1tOUrkSueVbBS0RQHAf/A+nNtDpvw95PeVKOA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.45.0.tgz",
"integrity": "sha512-Li0emNnwtUZdLwHjQPBxn4VWztcrw/h7mgLyHiEI5Z0MhpeFGlzaiBHpSNVOMB/xucjXTTcO+dhv469Djr16KA==",
"cpu": [
"loong64"
],
@@ -2704,9 +2718,9 @@
]
},
"node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.28.1.tgz",
"integrity": "sha512-pTnTdBuC2+pt1Rmm2SV7JWRqzhYpEILML4PKODqLz+C7Ou2apEV52h19CR7es+u04KlqplggmN9sqZlekg3R1A==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.45.0.tgz",
"integrity": "sha512-sB8+pfkYx2kvpDCfd63d5ScYT0Fz1LO6jIb2zLZvmK9ob2D8DeVqrmBDE0iDK8KlBVmsTNzrjr3G1xV4eUZhSw==",
"cpu": [
"ppc64"
],
@@ -2718,9 +2732,23 @@
]
},
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.28.1.tgz",
"integrity": "sha512-vWXy1Nfg7TPBSuAncfInmAI/WZDd5vOklyLJDdIRKABcZWojNDY0NJwruY2AcnCLnRJKSaBgf/GiJfauu8cQZA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.45.0.tgz",
"integrity": "sha512-5GQ6PFhh7E6jQm70p1aW05G2cap5zMOvO0se5JMecHeAdj5ZhWEHbJ4hiKpfi1nnnEdTauDXxPgXae/mqjow9w==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-riscv64-musl": {
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.45.0.tgz",
"integrity": "sha512-N/euLsBd1rekWcuduakTo/dJw6U6sBP3eUq+RXM9RNfPuWTvG2w/WObDkIvJ2KChy6oxZmOSC08Ak2OJA0UiAA==",
"cpu": [
"riscv64"
],
@@ -2732,9 +2760,9 @@
]
},
"node_modules/@rollup/rollup-linux-s390x-gnu": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.28.1.tgz",
"integrity": "sha512-/yqC2Y53oZjb0yz8PVuGOQQNOTwxcizudunl/tFs1aLvObTclTwZ0JhXF2XcPT/zuaymemCDSuuUPXJJyqeDOg==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.45.0.tgz",
"integrity": "sha512-2l9sA7d7QdikL0xQwNMO3xURBUNEWyHVHfAsHsUdq+E/pgLTUcCE+gih5PCdmyHmfTDeXUWVhqL0WZzg0nua3g==",
"cpu": [
"s390x"
],
@@ -2746,9 +2774,9 @@
]
},
"node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.28.1.tgz",
"integrity": "sha512-fzgeABz7rrAlKYB0y2kSEiURrI0691CSL0+KXwKwhxvj92VULEDQLpBYLHpF49MSiPG4sq5CK3qHMnb9tlCjBw==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.45.0.tgz",
"integrity": "sha512-XZdD3fEEQcwG2KrJDdEQu7NrHonPxxaV0/w2HpvINBdcqebz1aL+0vM2WFJq4DeiAVT6F5SUQas65HY5JDqoPw==",
"cpu": [
"x64"
],
@@ -2760,9 +2788,9 @@
]
},
"node_modules/@rollup/rollup-linux-x64-musl": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.28.1.tgz",
"integrity": "sha512-xQTDVzSGiMlSshpJCtudbWyRfLaNiVPXt1WgdWTwWz9n0U12cI2ZVtWe/Jgwyv/6wjL7b66uu61Vg0POWVfz4g==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.45.0.tgz",
"integrity": "sha512-7ayfgvtmmWgKWBkCGg5+xTQ0r5V1owVm67zTrsEY1008L5ro7mCyGYORomARt/OquB9KY7LpxVBZes+oSniAAQ==",
"cpu": [
"x64"
],
@@ -2774,9 +2802,9 @@
]
},
"node_modules/@rollup/rollup-win32-arm64-msvc": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.28.1.tgz",
"integrity": "sha512-wSXmDRVupJstFP7elGMgv+2HqXelQhuNf+IS4V+nUpNVi/GUiBgDmfwD0UGN3pcAnWsgKG3I52wMOBnk1VHr/A==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.45.0.tgz",
"integrity": "sha512-B+IJgcBnE2bm93jEW5kHisqvPITs4ddLOROAcOc/diBgrEiQJJ6Qcjby75rFSmH5eMGrqJryUgJDhrfj942apQ==",
"cpu": [
"arm64"
],
@@ -2788,9 +2816,9 @@
]
},
"node_modules/@rollup/rollup-win32-ia32-msvc": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.28.1.tgz",
"integrity": "sha512-ZkyTJ/9vkgrE/Rk9vhMXhf8l9D+eAhbAVbsGsXKy2ohmJaWg0LPQLnIxRdRp/bKyr8tXuPlXhIoGlEB5XpJnGA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.45.0.tgz",
"integrity": "sha512-+CXwwG66g0/FpWOnP/v1HnrGVSOygK/osUbu3wPRy8ECXjoYKjRAyfxYpDQOfghC5qPJYLPH0oN4MCOjwgdMug==",
"cpu": [
"ia32"
],
@@ -2802,9 +2830,9 @@
]
},
"node_modules/@rollup/rollup-win32-x64-msvc": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.28.1.tgz",
"integrity": "sha512-ZvK2jBafvttJjoIdKm/Q/Bh7IJ1Ose9IBOwpOXcOvW3ikGTQGmKDgxTC6oCAzW6PynbkKP8+um1du81XJHZ0JA==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.45.0.tgz",
"integrity": "sha512-SRf1cytG7wqcHVLrBc9VtPK4pU5wxiB/lNIkNmW2ApKXIg+RpqwHfsaEK+e7eH4A1BpI6BX/aBWXxZCIrJg3uA==",
"cpu": [
"x64"
],
@@ -3439,9 +3467,9 @@
}
},
"node_modules/@types/estree": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==",
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
"dev": true,
"license": "MIT"
},
@@ -3941,6 +3969,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz",
"integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.25.3",
@@ -3954,6 +3983,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz",
"integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/compiler-core": "3.5.13",
@@ -3964,6 +3994,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz",
"integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.25.3",
@@ -3981,6 +4012,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz",
"integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/compiler-dom": "3.5.13",
@@ -4027,6 +4059,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz",
"integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/shared": "3.5.13"
@@ -4036,6 +4069,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz",
"integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.5.13",
@@ -4046,6 +4080,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz",
"integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.5.13",
@@ -4058,6 +4093,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz",
"integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/compiler-ssr": "3.5.13",
@@ -4071,6 +4107,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz",
"integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==",
"dev": true,
"license": "MIT"
},
"node_modules/@vueuse/core": {
@@ -4351,13 +4388,6 @@
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/ace-builds": {
"version": "1.39.1",
"resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.39.1.tgz",
"integrity": "sha512-HcJbBzx8qY66t9gZo/sQu7pi0wO/CFLdYn1LxQO1WQTfIkMfyc7LRnBpsp/oNCSSU/LL83jXHN1fqyOTuIhUjg==",
"license": "BSD-3-Clause",
"peer": true
},
"node_modules/acorn": {
"version": "8.14.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz",
@@ -5518,6 +5548,7 @@
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
"dev": true,
"license": "MIT"
},
"node_modules/cytoscape": {
@@ -6618,6 +6649,23 @@
"url": "https://dotenvx.com"
}
},
"node_modules/dts-bundle-generator": {
"version": "9.5.1",
"resolved": "https://registry.npmjs.org/dts-bundle-generator/-/dts-bundle-generator-9.5.1.tgz",
"integrity": "sha512-DxpJOb2FNnEyOzMkG11sxO2dmxPjthoVWxfKqWYJ/bI/rT1rvTMktF5EKjAYrRZu6Z6t3NhOUZ0sZ5ZXevOfbA==",
"dev": true,
"license": "MIT",
"dependencies": {
"typescript": ">=5.0.2",
"yargs": "^17.6.0"
},
"bin": {
"dts-bundle-generator": "dist/bin/dts-bundle-generator.js"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/duplexer": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz",
@@ -6727,6 +6775,7 @@
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
"dev": true,
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
@@ -7122,6 +7171,7 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
"dev": true,
"license": "MIT"
},
"node_modules/esutils": {
@@ -7576,9 +7626,9 @@
"license": "MIT"
},
"node_modules/fs-extra": {
"version": "11.2.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
"integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==",
"version": "11.3.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.0.tgz",
"integrity": "sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -9452,6 +9502,7 @@
"version": "0.30.17",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz",
"integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.0"
@@ -10389,6 +10440,12 @@
"node": "*"
}
},
"node_modules/monaco-editor": {
"version": "0.52.2",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.52.2.tgz",
"integrity": "sha512-GEQWEZmfkOGLdd3XK8ryrfWz3AIP8YymVXiPHEdewrUq7mh0qrKrfHLNCXcbB6sTnMLnOZ3ztSiKcciFUkIJwQ==",
"license": "MIT"
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -10491,6 +10548,7 @@
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
"dev": true,
"funding": [
{
"type": "github",
@@ -11409,6 +11467,7 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"dev": true,
"license": "ISC"
},
"node_modules/picomatch": {
@@ -11561,6 +11620,7 @@
"version": "8.4.49",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz",
"integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==",
"dev": true,
"funding": [
{
"type": "opencollective",
@@ -12317,12 +12377,6 @@
"node": ">=10.13.0"
}
},
"node_modules/resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
"integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==",
"license": "MIT"
},
"node_modules/resolve": {
"version": "1.22.9",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.9.tgz",
@@ -12498,13 +12552,13 @@
"license": "Unlicense"
},
"node_modules/rollup": {
"version": "4.28.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.28.1.tgz",
"integrity": "sha512-61fXYl/qNVinKmGSTHAZ6Yy8I3YIJC/r2m9feHo6SwVAVcLT5MPwOUFe7EuURA/4m0NR8lXG4BBXuo/IZEsjMg==",
"version": "4.45.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.45.0.tgz",
"integrity": "sha512-WLjEcJRIo7i3WDDgOIJqVI2d+lAC3EwvOGy+Xfq6hs+GQuAA4Di/H72xmXkOhrIWFg2PFYSKZYfH0f4vfKXN4A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.6"
"@types/estree": "1.0.8"
},
"bin": {
"rollup": "dist/bin/rollup"
@@ -12514,28 +12568,52 @@
"npm": ">=8.0.0"
},
"optionalDependencies": {
"@rollup/rollup-android-arm-eabi": "4.28.1",
"@rollup/rollup-android-arm64": "4.28.1",
"@rollup/rollup-darwin-arm64": "4.28.1",
"@rollup/rollup-darwin-x64": "4.28.1",
"@rollup/rollup-freebsd-arm64": "4.28.1",
"@rollup/rollup-freebsd-x64": "4.28.1",
"@rollup/rollup-linux-arm-gnueabihf": "4.28.1",
"@rollup/rollup-linux-arm-musleabihf": "4.28.1",
"@rollup/rollup-linux-arm64-gnu": "4.28.1",
"@rollup/rollup-linux-arm64-musl": "4.28.1",
"@rollup/rollup-linux-loongarch64-gnu": "4.28.1",
"@rollup/rollup-linux-powerpc64le-gnu": "4.28.1",
"@rollup/rollup-linux-riscv64-gnu": "4.28.1",
"@rollup/rollup-linux-s390x-gnu": "4.28.1",
"@rollup/rollup-linux-x64-gnu": "4.28.1",
"@rollup/rollup-linux-x64-musl": "4.28.1",
"@rollup/rollup-win32-arm64-msvc": "4.28.1",
"@rollup/rollup-win32-ia32-msvc": "4.28.1",
"@rollup/rollup-win32-x64-msvc": "4.28.1",
"@rollup/rollup-android-arm-eabi": "4.45.0",
"@rollup/rollup-android-arm64": "4.45.0",
"@rollup/rollup-darwin-arm64": "4.45.0",
"@rollup/rollup-darwin-x64": "4.45.0",
"@rollup/rollup-freebsd-arm64": "4.45.0",
"@rollup/rollup-freebsd-x64": "4.45.0",
"@rollup/rollup-linux-arm-gnueabihf": "4.45.0",
"@rollup/rollup-linux-arm-musleabihf": "4.45.0",
"@rollup/rollup-linux-arm64-gnu": "4.45.0",
"@rollup/rollup-linux-arm64-musl": "4.45.0",
"@rollup/rollup-linux-loongarch64-gnu": "4.45.0",
"@rollup/rollup-linux-powerpc64le-gnu": "4.45.0",
"@rollup/rollup-linux-riscv64-gnu": "4.45.0",
"@rollup/rollup-linux-riscv64-musl": "4.45.0",
"@rollup/rollup-linux-s390x-gnu": "4.45.0",
"@rollup/rollup-linux-x64-gnu": "4.45.0",
"@rollup/rollup-linux-x64-musl": "4.45.0",
"@rollup/rollup-win32-arm64-msvc": "4.45.0",
"@rollup/rollup-win32-ia32-msvc": "4.45.0",
"@rollup/rollup-win32-x64-msvc": "4.45.0",
"fsevents": "~2.3.2"
}
},
"node_modules/rollup-plugin-dts": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-6.2.1.tgz",
"integrity": "sha512-sR3CxYUl7i2CHa0O7bA45mCrgADyAQ0tVtGSqi3yvH28M+eg1+g5d7kQ9hLvEz5dorK3XVsH5L2jwHLQf72DzA==",
"dev": true,
"license": "LGPL-3.0-only",
"dependencies": {
"magic-string": "^0.30.17"
},
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/Swatinem"
},
"optionalDependencies": {
"@babel/code-frame": "^7.26.2"
},
"peerDependencies": {
"rollup": "^3.29.4 || ^4",
"typescript": "^4.5 || ^5.0"
}
},
"node_modules/roughjs": {
"version": "4.6.6",
"resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz",
@@ -12887,6 +12965,7 @@
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
@@ -12999,6 +13078,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/state-local": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz",
"integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==",
"license": "MIT"
},
"node_modules/std-env": {
"version": "3.8.0",
"resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz",
@@ -13764,7 +13849,7 @@
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
"devOptional": true,
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
@@ -14310,6 +14395,7 @@
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz",
"integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@vue/compiler-dom": "3.5.13",
@@ -14327,19 +14413,6 @@
}
}
},
"node_modules/vue3-ace-editor": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/vue3-ace-editor/-/vue3-ace-editor-2.2.4.tgz",
"integrity": "sha512-FZkEyfpbH068BwjhMyNROxfEI8135Sc+x8ouxkMdCNkuj/Tuw83VP/gStFQqZHqljyX9/VfMTCdTqtOnJZGN8g==",
"license": "MIT",
"dependencies": {
"resize-observer-polyfill": "^1.5.1"
},
"peerDependencies": {
"ace-builds": "*",
"vue": "^3"
}
},
"node_modules/walk-up-path": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-3.0.1.tgz",
@@ -14729,9 +14802,10 @@
"version": "0.0.1",
"license": "ISC",
"dependencies": {
"@monaco-editor/loader": "^1.5.0",
"@xocash/primitives": "*",
"@xocash/stack": "*",
"vue3-ace-editor": "^2.2.4"
"monaco-editor": "^0.52.2"
},
"devDependencies": {
"typedoc": "^0.27.5",
@@ -14749,7 +14823,11 @@
"packages/primitives": {
"name": "@xocash/primitives",
"version": "0.0.1",
"license": "ISC"
"license": "ISC",
"devDependencies": {
"rollup": "^4.45.0",
"rollup-plugin-dts": "^6.2.1"
}
},
"packages/stack": {
"name": "@xocash/stack",
@@ -14766,7 +14844,10 @@
"zod": "^3.24.2"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.12"
"@types/better-sqlite3": "^7.6.12",
"dts-bundle-generator": "^9.5.1",
"rollup": "^4.45.0",
"rollup-plugin-dts": "^6.2.1"
}
}
}
+2 -1
View File
@@ -14,9 +14,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"@monaco-editor/loader": "^1.5.0",
"@xocash/primitives": "*",
"@xocash/stack": "*",
"vue3-ace-editor": "^2.2.4"
"monaco-editor": "^0.52.2"
},
"devDependencies": {
"typedoc": "^0.27.5",
@@ -0,0 +1,140 @@
<template>
<div class="code-editor">
<div ref="editorContainer" class="code-editor" />
<slot />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue';
import loader, { Monaco } from '@monaco-editor/loader';
import { ImportedLib } from '../utils/useXOCashLibs';
export type CodeEditorProps = {
// List of .d.ts files to import into the editor.
libs?: Record<string, ImportedLib>;
// Color scheme of the editor
isDark?: boolean;
}
const props = withDefaults(defineProps<CodeEditorProps>(), {
libs: () => ({}),
isDark: false,
});
const code = defineModel<string>();
const monacoInstance = ref<Monaco | null>(null);
const editorContainer = ref<HTMLElement | null>(null);
const emit = defineEmits<{
(e: 'execute'): void;
}>();
watch(() => props.libs, async () => {
updateEditorTypes();
});
function updateEditorTypes() {
monacoInstance.value?.languages.typescript.typescriptDefaults.setExtraLibs(
Object.entries(props.libs).map(([name, content]) => {
// Dont add the library if it is empty
if (!content) return null;
const moduleContent = `declare module "${name}" { ${content.libTypes} }`;
return { uri: `inmemory://model/${name}.d.ts`, content: moduleContent };
}).filter((lib) => lib !== null)
);
}
onMounted(() => {
// Load Monaco Editor
loader.init().then((monaco) => {
monacoInstance.value = monaco;
// Throw if our editor container is not found
if (!editorContainer.value) {
throw new Error('Editor container not found');
}
// Disable unnecessary validations
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false,
diagnosticCodesToIgnore: [ 1375 ] // Ignore "top-level await" error
});
// Add our typescript compiler options
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ESNext,
allowNonTsExtensions: true,
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
module: monaco.languages.typescript.ModuleKind.ESNext,
noEmit: true,
lib: ["esnext", "dom"],
checkJs: true,
isolatedModules: true,
allowSyntheticDefaultImports: true
});
// Enable eager mode. Tries to move LSP on worker thread
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
// Add extra libs to the editor
updateEditorTypes();
// Define a theme to change the background color of the editor
monaco.editor.defineTheme('xo-sandbox', {
base: props.isDark ? 'vs-dark' : 'vs',
inherit: true,
rules: [],
colors: {
"editor.background": props.isDark ? '#161618' : '#f5f5f5'
}
});
// Create our editor into the container
const editor = monaco.editor.create(editorContainer.value, {
value: code.value,
language: 'typescript',
theme: 'xo-sandbox',
automaticLayout: true,
scrollBeyondLastLine: false,
suggest: {
showClasses: true,
showFunctions: true,
showVariables: true,
showModules: true,
showProperties: true,
showWords: true,
},
});
// Add control + S keybinding to execute code
editor.addAction({
id: `execute-code`,
label: 'Execute Code',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS],
run: () => {
emit('execute')
}
});
// Update the code value when the editor content changes
editor.onDidChangeModelContent(() => {
code.value = editor.getValue();
});
});
})
</script>
<style scoped>
.code-editor {
height: 100%;
width: 100%;
}
</style>
@@ -1,19 +1,7 @@
<template>
<div class="code-sandbox" :style="sandboxStyle">
<div class="editor-container" :style="editorContainerStyle">
<v-ace-editor
v-model:value="code"
:style="editorStyle"
lang="javascript"
:theme="isDark ? 'github_dark' : 'github'"
@init="editorInit"
:options="{
showGutter: true,
minLines: 1,
showPrintMargin: false
}"
@keydown="handleExecuteHotkey"
/>
<code-editor v-model="code" @execute="executeCode" :style="editorStyle" :libs="libs" :is-dark="isDark"/>
<div class="editor-buttons">
<button v-if="!hideRunButton" @click="executeCode" class="primary-button">Run Code</button>
</div>
@@ -52,45 +40,36 @@
<script setup lang="ts">
import { useData } from 'vitepress';
import { ref, onMounted, onBeforeUnmount, computed } from 'vue';
import { VAceEditor } from 'vue3-ace-editor';
import ace from 'ace-builds';
import 'ace-builds/src-noconflict/theme-github';
import 'ace-builds/src-noconflict/theme-github_dark';
import 'ace-builds/src-noconflict/mode-javascript';
import { ref, onMounted, onBeforeUnmount, computed, version } from 'vue';
// Import the iframe HTML template
// NOTE: Having this in an external file is many-fold neater than stashing it all in here.
import iframeTemplateHtml from './CodeSandboxTemplate.html?raw';
import CodeEditor from './CodeEditor.vue';
import { ImportedLib, useXOCashLibs } from '../utils/useXOCashLibs';
const { isDark } = useData();
const xocashLibs = useXOCashLibs();
export type CodeSandboxProps = {
enableNetwork?: boolean;
fullHeight?: boolean;
height?: string;
editorHeight?: string;
outputHeight?: string;
hideRunButton?: boolean;
libs?: Record<string, ImportedLib>;
}
// Define props for the component
const props = defineProps({
enableNetwork: {
type: Boolean,
default: true
},
fullHeight: {
type: Boolean,
default: false
},
height: {
type: String,
default: 'auto'
},
editorHeight: {
type: String,
default: 'auto'
},
outputHeight: {
type: String,
default: 'auto'
},
hideRunButton: {
type: Boolean,
default: false,
}
const props = withDefaults(defineProps<CodeSandboxProps>(), {
enableNetwork: true,
fullHeight: false,
height: 'auto',
editorHeight: 'auto',
outputHeight: 'auto',
hideRunButton: false,
libs: (): Record<string, ImportedLib> => ({}),
});
// Define types for console logs
@@ -100,7 +79,8 @@ interface ConsoleLog {
}
// Define share URL base
const SHARE_BASE_URL = 'https://stack.xo.cash/playground.html';
// const SHARE_BASE_URL = 'https://stack.xo.cash/playground.html';
const SHARE_BASE_URL = 'http://localhost:5173/playground.html';
// Define a unique ID to pass into the IFrame.
// NOTE: We do this so that we can reliably identify where the postMessage came from.
@@ -111,7 +91,6 @@ const thisSandboxID = generateSandboxId();
const codeRef = ref(null);
const code = ref<string>('');
const logs = ref<ConsoleLog[]>([]);
const theme = ref('github_dark');
const showLogs = ref(false);
const sandboxIframe = ref<HTMLIFrameElement | null>(null);
@@ -169,14 +148,6 @@ const clearLogs = () => {
logs.value = [];
};
function editorInit(editor: any) {
editor.session.setTabSize(2);
editor.renderer.setScrollMargin(5, 5, 0, 0);
// Make sure the editor properly reflects its container size
editor.renderer.updateFull();
}
// Generate a shareable URL with the current code
const shareCode = () => {
try {
@@ -185,7 +156,13 @@ const shareCode = () => {
const base64Code = btoa(unescape(encodeURIComponent(code.value)));
// Generate the shareable URL with the Base64 encoded content in the hash fragment
const shareUrl = `${SHARE_BASE_URL}#code=${encodeURIComponent(base64Code)}`;
const baseURL = `${SHARE_BASE_URL}#code=${encodeURIComponent(base64Code)}`;
const url = new URL(baseURL);
url.searchParams.set('version', xocashLibs['@xocash/stack'].selectedVersion);
const shareUrl = url.toString();
// Check URL length - hash fragments can be longer, but still have limits
if (shareUrl.length > 10000) {
@@ -252,8 +229,20 @@ const executeCode = () => {
sandboxIframe.value.sandbox.add('allow-popups');
}
let embeddedCode = code.value;
// Replace our imported libs with the actual version.
Object.entries(props.libs).forEach(([lib, { selectedVersion }]) => {
const libUrl = `https://cdn.jsdelivr.net/npm/${lib}@${selectedVersion}/+esm`;
// Only replace in import statements to avoid replacing other occurrences
const importRegex = new RegExp(`import\\s+.+\\s+from\\s+['"]${lib.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, 'g');
embeddedCode = embeddedCode.replace(importRegex, (match) => {
return match.replace(lib, libUrl);
});
});
// Create the HTML content
const iframeContent = createIframeContent(thisSandboxID, code.value);
const iframeContent = createIframeContent(thisSandboxID, embeddedCode);
// Create a Blob containing the HTML content
const blob = new Blob([iframeContent], { type: 'text/html' });
@@ -305,30 +294,6 @@ const handleMessage = (event: MessageEvent) => {
}
};
// Platform detection for keyboard shortcuts
const isMac = computed(() => {
// Modern browsers
if ('userAgentData' in navigator) {
return (navigator as any).userAgentData.platform === 'macOS';
}
// Legacy browsers
return /Mac|iPod|iPhone|iPad/.test(navigator.platform);
});
// Handle keyboard shortcuts for code execution
const handleExecuteHotkey = (event: KeyboardEvent) => {
// Check if the save hotkey was pressed
const isSaveShortcut = event.key.toLowerCase() === 's' &&
(isMac.value ? event.metaKey : event.ctrlKey);
// If the save hotkey was pressed, then execute the code
if (isSaveShortcut) {
event.preventDefault();
executeCode();
}
};
// Lifecycle hooks
onMounted(() => {
// Check if there's code in the URL hash fragment
@@ -366,6 +331,15 @@ onMounted(() => {
// No code in hash or query, load from slot
loadCodeFromSlot();
}
}
// Get the selected version from the url if it exists
const urlParams = new URLSearchParams(window.location.search);
const versionParam = urlParams.get('version');
if (versionParam) {
xocashLibs['@xocash/stack'].selectedVersion = versionParam;
}
// Add event listener for messages from the iframe
@@ -104,19 +104,9 @@
<!-- Module script for ESM support -->
<script type="module">
// Helper function to handle both dynamic and static imports
async function runUserCode() {
try {
// Execute the user code
__userCode__;
} catch (error) {
console.error(error.message);
}
}
runUserCode().catch((error) => {
console.error('Error in user code execution:', error.message);
});
// Execute user code directly at top level to support ES6 imports
// Error handling is managed by global error handlers above
__userCode__;
</script>
</body>
</html>
@@ -6,6 +6,9 @@
<img class="dark-only" src="/logo-dark.svg" alt="XO Stack Logo">
XO Stack - Playground
</div>
<select class="version-select" v-model="xocashLibs['@xocash/stack'].selectedVersion">
<option v-for="version in xocashLibs['@xocash/stack'].versions" :key="version" :value="version">{{ version }}</option>
</select>
<div class="button-container">
<button class="primary-button" @click="shareCode">Share</button>
<button class="primary-button" @click="executeCode">Run Code</button>
@@ -18,6 +21,8 @@
outputHeight="20%"
fullHeight
hideRunButton
:libs="libs"
:isDark="isDark"
>
<slot></slot>
</CodeSandbox>
@@ -25,21 +30,28 @@
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { ref, computed } from 'vue';
import { useData } from 'vitepress';
import CodeSandbox from '@theme/components/CodeSandbox.vue'
import { useXOCashLibs } from '../utils/useXOCashLibs';
import CodeSandbox from './CodeSandbox.vue'
const xocashLibs = useXOCashLibs();
const libs = computed(() => {
return { ...xocashLibs }
});
const { isDark } = useData();
const sandbox = ref<InstanceType<typeof CodeSandbox> | null>(null);
async function executeCode() {
sandbox.value.executeCode();
sandbox.value?.executeCode();
}
async function shareCode() {
sandbox.value.shareCode()
sandbox.value?.shareCode()
}
</script>
@@ -101,4 +113,14 @@ display: flex; align-items: center;
.console-output {
white-space: pre-wrap;
}
.version-select {
margin-right: 10px;
background-color: var(--vp-c-bg);
color: var(--vp-c-text-1);
border: 1px solid var(--vp-c-border);
border-radius: 4px;
padding: 4px 8px;
font-size: 14px;
font-family: var(--vp-font-family-base);
}
</style>
@@ -0,0 +1,72 @@
import { watch, onMounted, reactive } from 'vue';
export type ImportedLib = {
versions: string[];
selectedVersion: string;
libTypes: string;
};
export type XOCashLibs = {
'@xocash/stack': ImportedLib;
'@xocash/primitives': ImportedLib;
}
const xocashLibs = reactive<XOCashLibs>({
'@xocash/stack': {
versions: [],
selectedVersion: '',
libTypes: '',
},
'@xocash/primitives': {
versions: [],
selectedVersion: '',
libTypes: '',
},
});
export const useXOCashLibs = (): XOCashLibs => {
// Get versions from npm registry
const getVersions = async (): Promise<string[]> => {
const response = await fetch('https://registry.npmjs.org/@xocash/stack');
const data = await response.json();
const versions = Object.keys(data.versions);
return versions;
};
const getTypes = async (packageName: string, version: string) => {
const response = await fetch(
`https://cdn.jsdelivr.net/npm/${packageName}@${version}/dist/types-bundled.d.ts`,
);
const content = await response.text();
return content;
};
// Update the types file when the selected version changes.
watch(
() => xocashLibs['@xocash/stack'].selectedVersion,
async (newVersion) => {
const stackTypes = await getTypes('@xocash/stack', newVersion);
const primitivesTypes = await getTypes('@xocash/primitives', newVersion);
// Only set the types file if the selected version has not been changed while fetching the types.
if (xocashLibs['@xocash/stack'].selectedVersion === newVersion) {
xocashLibs['@xocash/stack'].libTypes = stackTypes;
xocashLibs['@xocash/primitives'].libTypes = primitivesTypes;
}
},
);
// Fetch the versions and set the selected version when the component is mounted.
onMounted(async () => {
xocashLibs['@xocash/stack'].versions = await getVersions();
xocashLibs['@xocash/stack'].selectedVersion =
xocashLibs['@xocash/stack'].versions[xocashLibs['@xocash/stack'].versions.length - 1];
});
return xocashLibs;
};
+1 -1
View File
@@ -14,7 +14,7 @@ import Playground from '@theme/components/Playground.vue'
```
// Import the Electrum Blockchain Adapter from XO Stack.
const { BlockchainElectrum } = await import('https://cdn.jsdelivr.net/npm/@xocash/stack@0.0.2-development.95/+esm');
import { BlockchainElectrum } from '@xocash/stack';
// Instantiate and start the Electrum Blockchain Adapter.
const blockchain = new BlockchainElectrum();
+30 -6
View File
@@ -4,6 +4,9 @@ aside: false
<script lang="ts" setup>
import CodeSandbox from '@theme/components/CodeSandbox.vue'
import { useXOCashLibs } from '@theme/utils/useXOCashLibs';
const xocashLibs = useXOCashLibs();
</script>
# Sandbox
@@ -20,10 +23,17 @@ This'll be very useful for:
The below is Address mess.
<!-- NOTE: It is absolutely crucial you leave a blank line before and after the backticks! Otherwise, you'll end up with errors.-->
<CodeSandbox>
<CodeSandbox
:libs="xocashLibs"
height="50em"
editorHeight="30em"
outputHeight="20em"
fullHeight
>
```
const { Address } = await import('https://cdn.jsdelivr.net/npm/@xocash/stack@0.0.2-development.95/+esm');
import { Address } from '@xocash/stack';
const lockscriptHex = Address.from('bitcoincash:qr2084lauctzarqk20kqlhef8gyneqhceqy75wvw8q').toLockscriptHex();
@@ -43,10 +53,17 @@ console.info('yep');
We can have more than one per page too. For example:
<!-- NOTE: It is absolutely crucial you leave a blank line before and after the backticks! Otherwise, you'll end up with errors.-->
<CodeSandbox>
<CodeSandbox
:libs="xocashLibs"
height="50em"
editorHeight="30em"
outputHeight="20em"
fullHeight
>
```
const { BlockchainElectrum } = await import('https://cdn.jsdelivr.net/npm/@xocash/stack@0.0.2-development.95/+esm');
import { BlockchainElectrum } from '@xocash/stack';
const blockchain = new BlockchainElectrum();
@@ -64,10 +81,17 @@ console.log('Transaction Hex', tx.toHex());
The below demonstrates instantiating a wallet.
<!-- NOTE: It is absolutely crucial you leave a blank line before and after the backticks! Otherwise, you'll end up with errors.-->
<CodeSandbox>
<CodeSandbox
:libs="xocashLibs"
height="50em"
editorHeight="30em"
outputHeight="20em"
fullHeight
>
```
const { BlockchainElectrum, WalletP2PKH } = await import('https://cdn.jsdelivr.net/npm/@xocash/stack@0.0.2-development.95/+esm');
import { BlockchainElectrum, WalletP2PKH } from '@xocash/stack';
const wallet = WalletP2PKH.generateRandom({
blockchain: new BlockchainElectrum
+6 -2
View File
@@ -11,7 +11,7 @@
],
"scripts": {
"build": "tsc --build --clean && tsc --build && npm run build:types",
"build:types": "tsc --emitDeclarationOnly --outFile dist/types-bundled.d.ts",
"build:types": "rollup -c",
"format": "prettier --write \"**/*.{js,ts,md,json}\" --ignore-path .gitignore",
"madge": "npx madge --circular ./src/index.ts",
"test": "vitest --run",
@@ -21,5 +21,9 @@
},
"author": "",
"license": "ISC",
"gitHead": "2d550cef4b179b17110363512ee0fde54a5da79a"
"gitHead": "2d550cef4b179b17110363512ee0fde54a5da79a",
"devDependencies": {
"rollup": "^4.45.0",
"rollup-plugin-dts": "^6.2.1"
}
}
+11
View File
@@ -0,0 +1,11 @@
import dts from 'rollup-plugin-dts';
import { defineConfig } from 'rollup';
export default defineConfig({
input: 'dist/index.d.ts',
output: {
file: 'dist/types-bundled.d.ts',
format: 'es',
},
plugins: [dts()],
});
+14
View File
@@ -0,0 +1,14 @@
{
"compilationOptions": {
"followSymlinks": true
},
"entries": [
{
"filePath": "./src/index.ts",
"outFile": "./dist/types-bundled.d.ts",
"libraries": {
"inlinedLibraries": ["@xocash/primitives"]
}
}
]
}
+5 -2
View File
@@ -22,7 +22,7 @@
"scripts": {
"bench": "vitest bench",
"build": "tsc --build --clean && tsc --build && npm run build:types",
"build:types": "tsc --emitDeclarationOnly --outFile dist/types-bundled.d.ts",
"build:types": "rollup -c rollup.config.js",
"format": "prettier --write \"**/*.{js,ts,md,json}\" --ignore-path .gitignore",
"madge": "npx madge --circular ./src/index.ts",
"prepublishOnly": "npm run build",
@@ -44,6 +44,9 @@
"zod": "^3.24.2"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.12"
"@types/better-sqlite3": "^7.6.12",
"dts-bundle-generator": "^9.5.1",
"rollup": "^4.45.0",
"rollup-plugin-dts": "^6.2.1"
}
}
+11
View File
@@ -0,0 +1,11 @@
import dts from 'rollup-plugin-dts';
import { defineConfig } from 'rollup';
export default defineConfig({
input: 'dist/index.d.ts',
output: {
file: 'dist/types-bundled.d.ts',
format: 'es'
},
plugins: [dts()],
});