-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,291 additions
and
10,920 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VUE_APP_TL_PACKAGE_PATH_URL=https://raw.githubusercontent.com/teal-language/tl/master/?.lua | ||
VITE_TL_PACKAGE_PATH_URL=https://raw.githubusercontent.com/teal-language/tl/master/?.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true | ||
node: true, | ||
es2022: true | ||
}, | ||
extends: [ | ||
'plugin:vue/essential', | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as fengari from 'fengari-web' | ||
import TealError from '@/TealError' | ||
|
||
const tl = ` | ||
package.path = "${import.meta.env.VITE_TL_PACKAGE_PATH_URL}" | ||
os = { | ||
getenv = function(var) | ||
if var == "TL_DEBUG" then | ||
return nil | ||
else | ||
return '' | ||
end | ||
end | ||
} | ||
local tl = require('tl') | ||
local env = tl.init_env(false, false, true) | ||
local output, result = tl.gen(%input%, env) | ||
return { output, result.syntax_errors, result.type_errors } | ||
` | ||
|
||
const convertErrorArray = (tbl) => { | ||
if (tbl == null) { | ||
return null | ||
} | ||
|
||
let array: [TealError] = [] | ||
let i = 1 | ||
while (tbl.has(i)) { | ||
let obj = tbl.get(i) | ||
let error: TealError = { | ||
y: obj.get('y'), | ||
x: obj.get('x'), | ||
msg: obj.get('msg') | ||
} | ||
array[i - 1] = error; | ||
i++; | ||
} | ||
|
||
return array | ||
} | ||
|
||
onmessage = (msg) => { | ||
if (msg.data[0] == "compile") { | ||
const newValue = msg.data[1] | ||
|
||
try { | ||
const out = fengari.load(tl.replace('%input%', JSON.stringify(newValue)))() | ||
|
||
const output = out.get(1) || null | ||
const syntaxErrors = convertErrorArray(out.get(2)) | ||
const typeErrors = convertErrorArray(out.get(3)) | ||
|
||
postMessage(["compiled", output, syntaxErrors, typeErrors]) | ||
} catch (err) { | ||
postMessage(["error", err]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type TealError = { | ||
y: number | ||
x: number | ||
msg: string | ||
} | ||
|
||
export default TealError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
] | ||
}, | ||
"lib": [ | ||
"webworker", | ||
"esnext", | ||
"dom", | ||
"dom.iterable", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// vite.config.js | ||
|
||
import { defineConfig } from 'vite' | ||
import { createVuePlugin as vue } from "vite-plugin-vue2"; | ||
|
||
const path = require("path"); | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
build: { | ||
commonjsOptions: { | ||
transformMixedEsModules: true, | ||
}, | ||
}, | ||
resolve: { | ||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], | ||
alias: { | ||
"@": path.resolve(__dirname, "./src"), | ||
}, | ||
} | ||
}) |
Oops, something went wrong.