Compare commits
33 commits
Author | SHA1 | Date | |
---|---|---|---|
01c3fb2282 | |||
eb09d691fd | |||
68b95e1cfd | |||
ecf79c4462 | |||
953a1fefa2 | |||
3dd32df2c1 | |||
cf200730f7 | |||
fc6a27e58f | |||
6313ac889c | |||
b4c4540f0b | |||
f7d7b1c6d3 | |||
7a1f099b33 | |||
bb3cafb476 | |||
be7905fe1b | |||
7f3580f15a | |||
b1a3ece8f1 | |||
b9cd5a1de9 | |||
2f3c35462b | |||
8ddffdf3d7 | |||
f2e7912f0b | |||
e482f9b0b4 | |||
c3c1736e4d | |||
163240b9b2 | |||
66a9685605 | |||
7c08233e6b | |||
f74cd5b99f | |||
57440fb01f | |||
22f4b9e8f1 | |||
faecd127d2 | |||
f0b7b1ba98 | |||
19b4b86e20 | |||
ac163abd9d | |||
0e7a019308 |
38 changed files with 488 additions and 591 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,5 +1,4 @@
|
||||||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
|
|
||||||
logs
|
logs
|
||||||
|
@ -167,3 +166,5 @@ dist
|
||||||
.yarn/build-state.yml
|
.yarn/build-state.yml
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.\*
|
.pnp.\*
|
||||||
|
|
||||||
|
output_testing/
|
||||||
|
|
|
@ -18,26 +18,26 @@ export function registerValidationChecks(services: JstqlServices) {
|
||||||
* Implementation of custom validations.
|
* Implementation of custom validations.
|
||||||
*/
|
*/
|
||||||
export class JstqlValidator {
|
export class JstqlValidator {
|
||||||
validateWildcards(pair: Case, accept: ValidationAcceptor): void {
|
validateWildcards(case_: Case, accept: ValidationAcceptor): void {
|
||||||
try {
|
try {
|
||||||
let validationResultAplTo = validateWildcardAplTo(
|
let validationResultAplTo = validateWildcardAplTo(
|
||||||
collectWildcard(pair.aplTo.apl_to_code.split(""))
|
collectWildcard(case_.aplTo.apl_to_code.split(""))
|
||||||
);
|
);
|
||||||
if (validationResultAplTo.errors.length != 0) {
|
if (validationResultAplTo.errors.length != 0) {
|
||||||
accept("error", validationResultAplTo.errors.join("\n"), {
|
accept("error", validationResultAplTo.errors.join("\n"), {
|
||||||
node: pair.aplTo,
|
node: case_.aplTo,
|
||||||
property: "apl_to_code",
|
property: "apl_to_code",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let validationResultTraTo = validateWildcardTraTo(
|
let validationResultTraTo = validateWildcardTraTo(
|
||||||
collectWildcard(pair.traTo.transform_to_code.split("")),
|
collectWildcard(case_.traTo.transform_to_code.split("")),
|
||||||
validationResultAplTo.env
|
validationResultAplTo.env
|
||||||
);
|
);
|
||||||
|
|
||||||
if (validationResultTraTo.length != 0) {
|
if (validationResultTraTo.length != 0) {
|
||||||
accept("error", validationResultTraTo.join("\n"), {
|
accept("error", validationResultTraTo.join("\n"), {
|
||||||
node: pair.traTo,
|
node: case_.traTo,
|
||||||
property: "transform_to_code",
|
property: "transform_to_code",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
59
README.md
59
README.md
|
@ -1 +1,58 @@
|
||||||
# didactic-chainsaw
|
# JSTQL JavaScript Transform tool
|
||||||
|
|
||||||
|
This tool is created to transform JavaScript based on definitions written in a custom DSL called JSTQL
|
||||||
|
|
||||||
|
## JSTQL
|
||||||
|
|
||||||
|
This is a DSL created to define proposal transformations using templates. A transformation is defined by two templates, a template of what code snippets to search for **applicable to** and a template of how to transform those snippets **transform to**.
|
||||||
|
|
||||||
|
Examples of definitions for proposals can be found in [dsl_files](./dsl_files/)
|
||||||
|
|
||||||
|
## Running this project
|
||||||
|
|
||||||
|
This project exposes an api in the file [transform/transfrom.ts](./src/transform/transform.ts), which is meant to be used as this library's entry point.
|
||||||
|
|
||||||
|
To run this code as a standalone project, a file [index.ts](./index.ts) exists to facilitate running this project.
|
||||||
|
|
||||||
|
This project is created using TypeScript, and it is recommended to use [Bun](https://bun.sh/) to compile and run it.
|
||||||
|
|
||||||
|
### Building Langium required files
|
||||||
|
|
||||||
|
Firstly, building langium is required, this is done by the following:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# cd into JSTQL
|
||||||
|
cd JSTQL
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
npm i
|
||||||
|
|
||||||
|
# Build langium generated files
|
||||||
|
npm run langium:generate
|
||||||
|
|
||||||
|
# Build final JS source
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running a transformation
|
||||||
|
|
||||||
|
Now we are ready to run this project with the pipeline on a test JS file:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# cd into top level
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
bun i
|
||||||
|
|
||||||
|
# Run an example transformation
|
||||||
|
bun run index.ts dsl_files/pipeline.jstql test_files/test.js
|
||||||
|
```
|
||||||
|
|
||||||
|
### Arguments of index.ts
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
|
||||||
|
- First positional is path to JSTQL
|
||||||
|
- Second positional is path to JS file to transform
|
||||||
|
- -o is optional output path, if not given path is **./out.js**
|
||||||
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -1,19 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Page Title</title>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>Demo site</h1>
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,11 +1,10 @@
|
||||||
proposal DoExpression{
|
proposal DoExpression{
|
||||||
case arrowFunction{
|
case arrowFunction{
|
||||||
applicable to {
|
applicable to {
|
||||||
"() => {
|
"(() => {
|
||||||
<<statements: (Statement && !ReturnStatement)+>>
|
<<statements: (Statement && !ReturnStatement)+>>
|
||||||
return <<returnVal : Expression>>;
|
return <<returnVal : Expression>>;
|
||||||
}
|
})();"
|
||||||
"
|
|
||||||
}
|
}
|
||||||
transform to {
|
transform to {
|
||||||
"(do {
|
"(do {
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
proposal MultiStmt{
|
|
||||||
case Smthn{
|
|
||||||
applicable to{
|
|
||||||
"let <<ident1:Identifier>> = <<funcIdent:Identifier | MemberExpression>>();
|
|
||||||
let <<ident2:Identifier>> = <<expr:Expression>>;
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
transform to {
|
|
||||||
"const ident2 = () => {
|
|
||||||
let <<ident1>> = <<funcIdent>>();
|
|
||||||
return <<expr>>;
|
|
||||||
}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
proposal Pipeline{
|
|
||||||
|
|
||||||
case SingleArgument {
|
|
||||||
applicable to {
|
|
||||||
"<<someFunctionIdent:Identifier || MemberExpression>>(<<otherFunctionIdent:Identifier || MemberExpression>>(<<arggg:Identifier>>));"
|
|
||||||
}
|
|
||||||
|
|
||||||
transform to {
|
|
||||||
"(<<arggg>> |> <<otherFunctionIdent>>(%)) |> <<someFunctionIdent>>(%);"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
proposal Star{
|
|
||||||
case a {
|
|
||||||
applicable to {
|
|
||||||
"let <<ident:Identifier>> = () => {
|
|
||||||
<<statements: Statement>>
|
|
||||||
return <<returnVal : Expression>>;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
}
|
|
||||||
transform to {
|
|
||||||
"let <<ident>> = do {
|
|
||||||
<<statements>>
|
|
||||||
<<returnVal>>
|
|
||||||
}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
19
dsl_files/test.jstql
Normal file
19
dsl_files/test.jstql
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
proposal lol {
|
||||||
|
case a {
|
||||||
|
applicable to {
|
||||||
|
"let <<a: Identifier>> = Iterator.from(<<e: Expression>>);
|
||||||
|
let <<aa: Identifier>> = Iterator.from(<<ee: Expression>>);
|
||||||
|
|
||||||
|
let <<bbbb: Identifier>> = function* () {
|
||||||
|
yield* <<aaa: Identifier>>;
|
||||||
|
yield* <<aaaa: Identifier>>;
|
||||||
|
}();"
|
||||||
|
}
|
||||||
|
transform to {
|
||||||
|
"let <<a>> = Iterator.from(<<e>>);
|
||||||
|
let <<aa>> = Iterator.from(<<ee>>);
|
||||||
|
|
||||||
|
let <<bbbb>> = Iterator.concat(<<aaa>>, <<aaaa>>);"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
proposal test_single_stmt{
|
|
||||||
pair one {
|
|
||||||
applicable to {
|
|
||||||
"let <<aaaa: Identifier >> = <<bbbb: Expression | Identifier>>"
|
|
||||||
}
|
|
||||||
transform to {
|
|
||||||
"let <<aaaa>> = 1 + <<bbbb>>;"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
55
index.ts
Normal file
55
index.ts
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
import {
|
||||||
|
|
||||||
|
transform,
|
||||||
|
} from "./src/transform/transform";
|
||||||
|
import { parseJSTQL } from "./src/langium/langiumRunner";
|
||||||
|
import { parseArgs } from "util";
|
||||||
|
|
||||||
|
const { values: argVals, tokens: positional } = parseArgs({
|
||||||
|
options: {
|
||||||
|
o: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tokens: true,
|
||||||
|
allowPositionals: true,
|
||||||
|
});
|
||||||
|
const main = async () => {
|
||||||
|
//transform(selfHostedTransformExampleMultiStmt, codeFromFile);
|
||||||
|
console.log(positional);
|
||||||
|
console.log(argVals);
|
||||||
|
if (!positional) {
|
||||||
|
throw new Error("Something is wrong with args");
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!positional[0] &&
|
||||||
|
positional[0].kind === "positional" &&
|
||||||
|
!positional[0].value.endsWith(".jstql")
|
||||||
|
) {
|
||||||
|
throw new Error("First positional argument is current JSTQL file");
|
||||||
|
}
|
||||||
|
if (!positional[1] || !positional[1].value.endsWith(".js")) {
|
||||||
|
throw new Error(
|
||||||
|
"Second positional argument is JS code to be transformed"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const jstql_file = positional[0].value;
|
||||||
|
const code_file = positional[1].value;
|
||||||
|
|
||||||
|
let jstqlString = await Bun.file(jstql_file).text();
|
||||||
|
let codeString = await Bun.file(code_file).text();
|
||||||
|
|
||||||
|
let parsedJSTQL = await parseJSTQL(jstqlString);
|
||||||
|
|
||||||
|
for (let proposal of parsedJSTQL) {
|
||||||
|
let [resultString, matches] = transform(proposal.cases, codeString);
|
||||||
|
let path = "./out.js";
|
||||||
|
if (argVals["o"]) {
|
||||||
|
path = argVals["o"];
|
||||||
|
}
|
||||||
|
await Bun.write(path, resultString);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
main();
|
3
out.js
Normal file
3
out.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
let something = Iterator.from([1, 2, 3]);
|
||||||
|
let someOtherThing = Iterator.from([4, 5, 6]);
|
||||||
|
let generate = Iterator.concat(something, someOtherThing);
|
|
@ -1,94 +0,0 @@
|
||||||
function parse() {
|
|
||||||
const input = ("input" |> document.getElementById(%)).value;
|
|
||||||
const data = 32 |> input.slice(%);
|
|
||||||
const compressedData = data |> decode_base64(%);
|
|
||||||
const uncompressed = pako.inflate(compressedData, {
|
|
||||||
to: "string"
|
|
||||||
});
|
|
||||||
const json = uncompressed |> JSON.parse(%);
|
|
||||||
json |> console.log(%);
|
|
||||||
json |> convertToDesktop(%);
|
|
||||||
}
|
|
||||||
function convertToDesktop(json) {
|
|
||||||
const newValues = {
|
|
||||||
crb: false,
|
|
||||||
newClanRaidClassId: 0,
|
|
||||||
newClanRaidClassLevel: 0,
|
|
||||||
pendingImmortalSouls: 0,
|
|
||||||
pendingRaidRubies: 0,
|
|
||||||
immortalSouls: 0,
|
|
||||||
lastPurchaseTime: 0,
|
|
||||||
lastRaidAttemptTimestamp: 0,
|
|
||||||
lastRaidRewardCheckTimestamp: 0,
|
|
||||||
shouldShowHZERoster: false,
|
|
||||||
lastBonusRewardCheckTimestamp: 0
|
|
||||||
};
|
|
||||||
const mappedValues = {
|
|
||||||
rubies: json.rubies / 10 |> Math.round(%)
|
|
||||||
};
|
|
||||||
const pcSpecificValues = {
|
|
||||||
readPatchNumber: "1.0e12",
|
|
||||||
saveOrigin: "pc"
|
|
||||||
};
|
|
||||||
const hash = "7a990d405d2c6fb93aa8fbb0ec1a3b23";
|
|
||||||
const newData = {
|
|
||||||
...newValues,
|
|
||||||
...json,
|
|
||||||
...mappedValues,
|
|
||||||
...pcSpecificValues
|
|
||||||
};
|
|
||||||
const compressed = pako.deflate(newData |> JSON.stringify(%), {
|
|
||||||
to: "string"
|
|
||||||
});
|
|
||||||
const base64 = compressed |> btoa(%);
|
|
||||||
const finalSaveString = hash + base64;
|
|
||||||
("output_output" |> document.getElementById(%)).innerText = finalSaveString;
|
|
||||||
showOutput();
|
|
||||||
}
|
|
||||||
function showOutput() {
|
|
||||||
("outputs" |> document.getElementById(%)).style.visibility = "visible";
|
|
||||||
}
|
|
||||||
function copyOutput() {
|
|
||||||
const output = "output_output" |> document.getElementById(%);
|
|
||||||
output.disabled = false;
|
|
||||||
output.focus();
|
|
||||||
output.select();
|
|
||||||
"copy" |> document.execCommand(%);
|
|
||||||
output.disabled = true;
|
|
||||||
const successElement = "copy_success_msg" |> document.getElementById(%);
|
|
||||||
successElement.style.visibility = "visible";
|
|
||||||
setTimeout(() => successElement.style.visibility = "hidden", 4000);
|
|
||||||
}
|
|
||||||
function decode_base64(s) {
|
|
||||||
let e = {},
|
|
||||||
i,
|
|
||||||
k,
|
|
||||||
v = [],
|
|
||||||
r = "",
|
|
||||||
w = String.fromCharCode;
|
|
||||||
let n = [[65, 91], [97, 123], [48, 58], [43, 44], [47, 48]];
|
|
||||||
for (z in n) {
|
|
||||||
for (i = n[z][0]; i < n[z][1]; i++) {
|
|
||||||
i |> w(%) |> v.push(%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < 64; i++) {
|
|
||||||
e[v[i]] = i;
|
|
||||||
}
|
|
||||||
for (i = 0; i < s.length; i += 72) {
|
|
||||||
let b = 0,
|
|
||||||
c,
|
|
||||||
x,
|
|
||||||
l = 0,
|
|
||||||
o = s.substring(i, i + 72);
|
|
||||||
for (x = 0; x < o.length; x++) {
|
|
||||||
c = e[x |> o.charAt(%)];
|
|
||||||
b = (b << 6) + c;
|
|
||||||
l += 6;
|
|
||||||
while (l >= 8) {
|
|
||||||
r += (b >>> (l -= 8)) % 256 |> w(%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
async function something() {
|
|
||||||
let a = 100;
|
|
||||||
a *= 100000;
|
|
||||||
return fetch("https://uib.no").then(uib => {
|
|
||||||
a += 100000;
|
|
||||||
a -= 1000;
|
|
||||||
return [a, uib];
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
let aaaa = do {
|
|
||||||
let g = 100;
|
|
||||||
let ff = 10;
|
|
||||||
let ggg = a(b);
|
|
||||||
100
|
|
||||||
};
|
|
||||||
var bbaaa = do {
|
|
||||||
let lllll = 1 + 1;
|
|
||||||
100 + 100;
|
|
||||||
const aaaaa = aaaa(bb);
|
|
||||||
lllll
|
|
||||||
};
|
|
|
@ -1,2 +0,0 @@
|
||||||
let ThisTest = LOOOOOOOOL();
|
|
||||||
let HAHHAHAH = 1 + 1;
|
|
|
@ -1,4 +0,0 @@
|
||||||
a |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%);
|
|
||||||
a |> b(%, a |> b(%, a |> b(%, a |> b(%, a |> b(%, a |> b(%, a |> b(%, b)))))));
|
|
||||||
a |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a);
|
|
||||||
b(b(b(b(a, a, a), a, a), a, a), a, a);
|
|
|
@ -1,4 +0,0 @@
|
||||||
a |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%) |> w(%);
|
|
||||||
a |> b(%, a |> b(%, a |> b(%, a |> b(%, a |> b(%, a |> b(%, a |> b(%, b)))))));
|
|
||||||
a |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a) |> b(%, a);
|
|
||||||
b(b(b(b(a, a, a), a, a), a, a), a, a);
|
|
|
@ -1,104 +0,0 @@
|
||||||
return awaitedExpr.then(async _geometry => {
|
|
||||||
const _intersectPoint = /*@__PURE__*/new Vector3();
|
|
||||||
const _worldScale = /*@__PURE__*/new Vector3();
|
|
||||||
const _mvPosition = /*@__PURE__*/new Vector3();
|
|
||||||
const _alignedPosition = /*@__PURE__*/new Vector2();
|
|
||||||
const _rotatedPosition = /*@__PURE__*/new Vector2();
|
|
||||||
const _viewWorldMatrix = /*@__PURE__*/new Matrix4();
|
|
||||||
const _vA = /*@__PURE__*/new Vector3();
|
|
||||||
const _vB = /*@__PURE__*/new Vector3();
|
|
||||||
const _vC = /*@__PURE__*/new Vector3();
|
|
||||||
const _uvA = /*@__PURE__*/new Vector2();
|
|
||||||
const _uvB = /*@__PURE__*/new Vector2();
|
|
||||||
const _uvC = /*@__PURE__*/new Vector2();
|
|
||||||
class Sprite extends Object3D {
|
|
||||||
constructor(material = new SpriteMaterial()) {
|
|
||||||
super();
|
|
||||||
this.isSprite = true;
|
|
||||||
this.type = "Sprite";
|
|
||||||
if (_geometry === undefined) {
|
|
||||||
_geometry = new BufferGeometry();
|
|
||||||
const float32Array = new Float32Array([-0.5, -0.5, 0, 0, 0, 0.5, -0.5, 0, 1, 0, 0.5, 0.5, 0, 1, 1, -0.5, 0.5, 0, 0, 1]);
|
|
||||||
const interleavedBuffer = new InterleavedBuffer(float32Array, 5);
|
|
||||||
_geometry.setIndex([0, 1, 2, 0, 2, 3]);
|
|
||||||
_geometry.setAttribute("position", new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false));
|
|
||||||
_geometry.setAttribute("uv", new InterleavedBufferAttribute(interleavedBuffer, 2, 3, false));
|
|
||||||
}
|
|
||||||
this.geometry = _geometry;
|
|
||||||
this.material = material;
|
|
||||||
this.center = new Vector2(0.5, 0.5);
|
|
||||||
}
|
|
||||||
raycast(raycaster, intersects) {
|
|
||||||
if (raycaster.camera === null) {
|
|
||||||
console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');
|
|
||||||
}
|
|
||||||
_worldScale.setFromMatrixScale(this.matrixWorld);
|
|
||||||
_viewWorldMatrix.copy(raycaster.camera.matrixWorld);
|
|
||||||
this.modelViewMatrix.multiplyMatrices(raycaster.camera.matrixWorldInverse, this.matrixWorld);
|
|
||||||
_mvPosition.setFromMatrixPosition(this.modelViewMatrix);
|
|
||||||
if (raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false) {
|
|
||||||
_worldScale.multiplyScalar(-_mvPosition.z);
|
|
||||||
}
|
|
||||||
const rotation = this.material.rotation;
|
|
||||||
let sin, cos;
|
|
||||||
if (rotation !== 0) {
|
|
||||||
cos = Math.cos(rotation);
|
|
||||||
sin = Math.sin(rotation);
|
|
||||||
}
|
|
||||||
const center = this.center;
|
|
||||||
transformVertex(_vA.set(-0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);
|
|
||||||
transformVertex(_vB.set(0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);
|
|
||||||
transformVertex(_vC.set(0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);
|
|
||||||
_uvA.set(0, 0);
|
|
||||||
_uvB.set(1, 0);
|
|
||||||
_uvC.set(1, 1);
|
|
||||||
|
|
||||||
// check first triangle
|
|
||||||
let intersect = raycaster.ray.intersectTriangle(_vA, _vB, _vC, false, _intersectPoint);
|
|
||||||
if (intersect === null) {
|
|
||||||
// check second triangle
|
|
||||||
transformVertex(_vB.set(-0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);
|
|
||||||
_uvB.set(0, 1);
|
|
||||||
intersect = raycaster.ray.intersectTriangle(_vA, _vC, _vB, false, _intersectPoint);
|
|
||||||
if (intersect === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const distance = raycaster.ray.origin.distanceTo(_intersectPoint);
|
|
||||||
if (distance < raycaster.near || distance > raycaster.far) return;
|
|
||||||
intersects.push({
|
|
||||||
distance: distance,
|
|
||||||
point: _intersectPoint.clone(),
|
|
||||||
uv: Triangle.getInterpolation(_intersectPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2()),
|
|
||||||
face: null,
|
|
||||||
object: this
|
|
||||||
});
|
|
||||||
}
|
|
||||||
copy(source, recursive) {
|
|
||||||
super.copy(source, recursive);
|
|
||||||
if (source.center !== undefined) this.center.copy(source.center);
|
|
||||||
this.material = source.material;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function transformVertex(vertexPosition, mvPosition, center, scale, sin, cos) {
|
|
||||||
// compute position in camera space
|
|
||||||
_alignedPosition.subVectors(vertexPosition, center).addScalar(0.5).multiply(scale);
|
|
||||||
|
|
||||||
// to check if rotation is not zero
|
|
||||||
if (sin !== undefined) {
|
|
||||||
_rotatedPosition.x = cos * _alignedPosition.x - sin * _alignedPosition.y;
|
|
||||||
_rotatedPosition.y = sin * _alignedPosition.x + cos * _alignedPosition.y;
|
|
||||||
} else {
|
|
||||||
_rotatedPosition.copy(_alignedPosition);
|
|
||||||
}
|
|
||||||
vertexPosition.copy(mvPosition);
|
|
||||||
vertexPosition.x += _rotatedPosition.x;
|
|
||||||
vertexPosition.y += _rotatedPosition.y;
|
|
||||||
|
|
||||||
// transform to world space
|
|
||||||
vertexPosition.applyMatrix4(_viewWorldMatrix);
|
|
||||||
}
|
|
||||||
export { Sprite };
|
|
||||||
return returnExpr;
|
|
||||||
});
|
|
|
@ -1,94 +0,0 @@
|
||||||
function parse() {
|
|
||||||
const input = ("input" |> document.getElementById(%)).value;
|
|
||||||
const data = 32 |> input.slice(%);
|
|
||||||
const compressedData = data |> decode_base64(%);
|
|
||||||
const uncompressed = compressedData |> pako.inflate(%, {
|
|
||||||
to: "string"
|
|
||||||
});
|
|
||||||
const json = uncompressed |> JSON.parse(%);
|
|
||||||
json |> console.log(%);
|
|
||||||
json |> convertToDesktop(%);
|
|
||||||
}
|
|
||||||
function convertToDesktop(json) {
|
|
||||||
const newValues = {
|
|
||||||
crb: false,
|
|
||||||
newClanRaidClassId: 0,
|
|
||||||
newClanRaidClassLevel: 0,
|
|
||||||
pendingImmortalSouls: 0,
|
|
||||||
pendingRaidRubies: 0,
|
|
||||||
immortalSouls: 0,
|
|
||||||
lastPurchaseTime: 0,
|
|
||||||
lastRaidAttemptTimestamp: 0,
|
|
||||||
lastRaidRewardCheckTimestamp: 0,
|
|
||||||
shouldShowHZERoster: false,
|
|
||||||
lastBonusRewardCheckTimestamp: 0
|
|
||||||
};
|
|
||||||
const mappedValues = {
|
|
||||||
rubies: json.rubies / 10 |> Math.round(%)
|
|
||||||
};
|
|
||||||
const pcSpecificValues = {
|
|
||||||
readPatchNumber: "1.0e12",
|
|
||||||
saveOrigin: "pc"
|
|
||||||
};
|
|
||||||
const hash = "7a990d405d2c6fb93aa8fbb0ec1a3b23";
|
|
||||||
const newData = {
|
|
||||||
...newValues,
|
|
||||||
...json,
|
|
||||||
...mappedValues,
|
|
||||||
...pcSpecificValues
|
|
||||||
};
|
|
||||||
const compressed = newData |> JSON.stringify(%) |> pako.deflate(%, {
|
|
||||||
to: "string"
|
|
||||||
});
|
|
||||||
const base64 = compressed |> btoa(%);
|
|
||||||
const finalSaveString = hash + base64;
|
|
||||||
("output_output" |> document.getElementById(%)).innerText = finalSaveString;
|
|
||||||
showOutput();
|
|
||||||
}
|
|
||||||
function showOutput() {
|
|
||||||
("outputs" |> document.getElementById(%)).style.visibility = "visible";
|
|
||||||
}
|
|
||||||
function copyOutput() {
|
|
||||||
const output = "output_output" |> document.getElementById(%);
|
|
||||||
output.disabled = false;
|
|
||||||
output.focus();
|
|
||||||
output.select();
|
|
||||||
"copy" |> document.execCommand(%);
|
|
||||||
output.disabled = true;
|
|
||||||
const successElement = "copy_success_msg" |> document.getElementById(%);
|
|
||||||
successElement.style.visibility = "visible";
|
|
||||||
(() => successElement.style.visibility = "hidden") |> setTimeout(%, 4000);
|
|
||||||
}
|
|
||||||
function decode_base64(s) {
|
|
||||||
let e = {},
|
|
||||||
i,
|
|
||||||
k,
|
|
||||||
v = [],
|
|
||||||
r = "",
|
|
||||||
w = String.fromCharCode;
|
|
||||||
let n = [[65, 91], [97, 123], [48, 58], [43, 44], [47, 48]];
|
|
||||||
for (z in n) {
|
|
||||||
for (i = n[z][0]; i < n[z][1]; i++) {
|
|
||||||
i |> w(%) |> v.push(%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < 64; i++) {
|
|
||||||
e[v[i]] = i;
|
|
||||||
}
|
|
||||||
for (i = 0; i < s.length; i += 72) {
|
|
||||||
let b = 0,
|
|
||||||
c,
|
|
||||||
x,
|
|
||||||
l = 0,
|
|
||||||
o = i |> s.substring(%, i + 72);
|
|
||||||
for (x = 0; x < o.length; x++) {
|
|
||||||
c = e[x |> o.charAt(%)];
|
|
||||||
b = (b << 6) + c;
|
|
||||||
l += 6;
|
|
||||||
while (l >= 8) {
|
|
||||||
r += (b >>> (l -= 8)) % 256 |> w(%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
async function something() {
|
|
||||||
let a = 100;
|
|
||||||
a *= 100000;
|
|
||||||
return fetch("https://uib.no").then(uib => {
|
|
||||||
a += 100000;
|
|
||||||
a -= 1000;
|
|
||||||
return [a, uib];
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,98 +0,0 @@
|
||||||
// "fast-glob" and `createTwoFilesPatch` are bundled here since the API uses `micromatch` and `diff` too
|
|
||||||
import { createTwoFilesPatch } from "diff/lib/patch/create.js";
|
|
||||||
import fastGlob from "fast-glob";
|
|
||||||
import * as vnopts from "vnopts";
|
|
||||||
import * as errors from "./common/errors.js";
|
|
||||||
import getFileInfoWithoutPlugins from "./common/get-file-info.js";
|
|
||||||
import mockable from "./common/mockable.js";
|
|
||||||
import { clearCache as clearConfigCache, resolveConfig, resolveConfigFile } from "./config/resolve-config.js";
|
|
||||||
import * as core from "./main/core.js";
|
|
||||||
import { formatOptionsHiddenDefaults } from "./main/normalize-format-options.js";
|
|
||||||
import normalizeOptions from "./main/normalize-options.js";
|
|
||||||
import * as optionCategories from "./main/option-categories.js";
|
|
||||||
import { clearCache as clearPluginCache, loadBuiltinPlugins, loadPlugins } from "./main/plugins/index.js";
|
|
||||||
import { getSupportInfo as getSupportInfoWithoutPlugins, normalizeOptionSettings } from "./main/support.js";
|
|
||||||
import { createIsIgnoredFunction } from "./utils/ignore.js";
|
|
||||||
import isNonEmptyArray from "./utils/is-non-empty-array.js";
|
|
||||||
import omit from "./utils/object-omit.js";
|
|
||||||
import partition from "./utils/partition.js";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {*} fn
|
|
||||||
* @param {number} [optionsArgumentIndex]
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
function withPlugins(fn, optionsArgumentIndex = 1 // Usually `options` is the 2nd argument
|
|
||||||
) {
|
|
||||||
return async (...args) => {
|
|
||||||
const options = args[optionsArgumentIndex] ?? {};
|
|
||||||
const {
|
|
||||||
plugins = []
|
|
||||||
} = options;
|
|
||||||
args[optionsArgumentIndex] = {
|
|
||||||
...options,
|
|
||||||
plugins: (await ([loadBuiltinPlugins(), plugins |> loadPlugins(%)] |> Promise.all(%))).flat()
|
|
||||||
};
|
|
||||||
return fn(...args);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const formatWithCursor = core.formatWithCursor |> withPlugins(%);
|
|
||||||
async function format(text, options) {
|
|
||||||
const {
|
|
||||||
formatted
|
|
||||||
} = await (text |> formatWithCursor(%, {
|
|
||||||
...options,
|
|
||||||
cursorOffset: -1
|
|
||||||
}));
|
|
||||||
return formatted;
|
|
||||||
}
|
|
||||||
async function check(text, options) {
|
|
||||||
return (await (text |> format(%, options))) === text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line require-await
|
|
||||||
async function clearCache() {
|
|
||||||
clearConfigCache();
|
|
||||||
clearPluginCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @type {typeof getFileInfoWithoutPlugins} */
|
|
||||||
const getFileInfo = getFileInfoWithoutPlugins |> withPlugins(%);
|
|
||||||
|
|
||||||
/** @type {typeof getSupportInfoWithoutPlugins} */
|
|
||||||
const getSupportInfo = getSupportInfoWithoutPlugins |> withPlugins(%, 0);
|
|
||||||
|
|
||||||
// Internal shared with cli
|
|
||||||
const sharedWithCli = {
|
|
||||||
errors,
|
|
||||||
optionCategories,
|
|
||||||
createIsIgnoredFunction,
|
|
||||||
formatOptionsHiddenDefaults,
|
|
||||||
normalizeOptions,
|
|
||||||
getSupportInfoWithoutPlugins,
|
|
||||||
normalizeOptionSettings,
|
|
||||||
vnopts: {
|
|
||||||
ChoiceSchema: vnopts.ChoiceSchema,
|
|
||||||
apiDescriptor: vnopts.apiDescriptor
|
|
||||||
},
|
|
||||||
fastGlob,
|
|
||||||
createTwoFilesPatch,
|
|
||||||
utils: {
|
|
||||||
isNonEmptyArray,
|
|
||||||
partition,
|
|
||||||
omit
|
|
||||||
},
|
|
||||||
mockable
|
|
||||||
};
|
|
||||||
const debugApis = {
|
|
||||||
parse: core.parse |> withPlugins(%),
|
|
||||||
formatAST: core.formatAst |> withPlugins(%),
|
|
||||||
formatDoc: core.formatDoc |> withPlugins(%),
|
|
||||||
printToDoc: core.printToDoc |> withPlugins(%),
|
|
||||||
printDocToString: core.printDocToString |> withPlugins(%),
|
|
||||||
mockable
|
|
||||||
};
|
|
||||||
export { debugApis as __debug, sharedWithCli as __internal, check, clearCache as clearConfigCache, format, formatWithCursor, getFileInfo, getSupportInfo, resolveConfig, resolveConfigFile };
|
|
||||||
export * as doc from "./document/public.js";
|
|
||||||
export { default as version } from "./main/version.evaluate.cjs";
|
|
||||||
export * as util from "./utils/public.js";
|
|
306
package-lock.json
generated
306
package-lock.json
generated
|
@ -15,7 +15,8 @@
|
||||||
"@types/babel-traverse": "^6.25.10",
|
"@types/babel-traverse": "^6.25.10",
|
||||||
"babel": "^6.23.0",
|
"babel": "^6.23.0",
|
||||||
"bun": "^1.0.4",
|
"bun": "^1.0.4",
|
||||||
"ts-node": "^10.9.1"
|
"ts-node": "^10.9.1",
|
||||||
|
"util": "^0.12.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-pipeline-operator": "^7.23.3",
|
"@babel/plugin-proposal-pipeline-operator": "^7.23.3",
|
||||||
|
@ -1001,6 +1002,21 @@
|
||||||
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
||||||
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
|
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/available-typed-arrays": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"possible-typed-array-names": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/babel": {
|
"node_modules/babel": {
|
||||||
"version": "6.23.0",
|
"version": "6.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel/-/babel-6.23.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel/-/babel-6.23.0.tgz",
|
||||||
|
@ -1293,6 +1309,25 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/call-bind": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"es-define-property": "^1.0.0",
|
||||||
|
"es-errors": "^1.3.0",
|
||||||
|
"function-bind": "^1.1.2",
|
||||||
|
"get-intrinsic": "^1.2.4",
|
||||||
|
"set-function-length": "^1.2.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001574",
|
"version": "1.0.30001574",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz",
|
||||||
|
@ -1452,6 +1487,23 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/define-data-property": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"es-define-property": "^1.0.0",
|
||||||
|
"es-errors": "^1.3.0",
|
||||||
|
"gopd": "^1.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/diff": {
|
"node_modules/diff": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||||
|
@ -1474,6 +1526,27 @@
|
||||||
"once": "^1.4.0"
|
"once": "^1.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/es-define-property": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"get-intrinsic": "^1.2.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/es-errors": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/escalade": {
|
"node_modules/escalade": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
|
||||||
|
@ -1647,6 +1720,24 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/for-each": {
|
||||||
|
"version": "0.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
|
||||||
|
"integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-callable": "^1.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/function-bind": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/gensync": {
|
"node_modules/gensync": {
|
||||||
"version": "1.0.0-beta.2",
|
"version": "1.0.0-beta.2",
|
||||||
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
||||||
|
@ -1655,6 +1746,25 @@
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/get-intrinsic": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"es-errors": "^1.3.0",
|
||||||
|
"function-bind": "^1.1.2",
|
||||||
|
"has-proto": "^1.0.1",
|
||||||
|
"has-symbols": "^1.0.3",
|
||||||
|
"hasown": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/get-stream": {
|
"node_modules/get-stream": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
|
||||||
|
@ -1684,6 +1794,18 @@
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/gopd": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"get-intrinsic": "^1.1.3"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/got": {
|
"node_modules/got": {
|
||||||
"version": "11.8.6",
|
"version": "11.8.6",
|
||||||
"resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz",
|
"resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz",
|
||||||
|
@ -1717,6 +1839,69 @@
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/has-property-descriptors": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"es-define-property": "^1.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/has-proto": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/has-symbols": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/has-tostringtag": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"has-symbols": "^1.0.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/hasown": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"function-bind": "^1.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/http-cache-semantics": {
|
"node_modules/http-cache-semantics": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
|
||||||
|
@ -1768,8 +1953,35 @@
|
||||||
"node_modules/inherits": {
|
"node_modules/inherits": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||||
"dev": true
|
},
|
||||||
|
"node_modules/is-arguments": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"call-bind": "^1.0.2",
|
||||||
|
"has-tostringtag": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-callable": {
|
||||||
|
"version": "1.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
|
||||||
|
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/is-extglob": {
|
"node_modules/is-extglob": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
|
@ -1780,6 +1992,21 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-generator-function": {
|
||||||
|
"version": "1.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz",
|
||||||
|
"integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"has-tostringtag": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/is-glob": {
|
"node_modules/is-glob": {
|
||||||
"version": "4.0.3",
|
"version": "4.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
||||||
|
@ -1819,6 +2046,21 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-typed-array": {
|
||||||
|
"version": "1.1.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz",
|
||||||
|
"integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"which-typed-array": "^1.1.14"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/isexe": {
|
"node_modules/isexe": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
|
@ -2082,6 +2324,15 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/possible-typed-array-names": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/pseudomap": {
|
"node_modules/pseudomap": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
||||||
|
@ -2291,6 +2542,23 @@
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/set-function-length": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"define-data-property": "^1.1.4",
|
||||||
|
"es-errors": "^1.3.0",
|
||||||
|
"function-bind": "^1.1.2",
|
||||||
|
"get-intrinsic": "^1.2.4",
|
||||||
|
"gopd": "^1.0.1",
|
||||||
|
"has-property-descriptors": "^1.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/shebang-command": {
|
"node_modules/shebang-command": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
|
||||||
|
@ -2559,6 +2827,19 @@
|
||||||
"browserslist": ">= 4.21.0"
|
"browserslist": ">= 4.21.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/util": {
|
||||||
|
"version": "0.12.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
|
||||||
|
"integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"inherits": "^2.0.3",
|
||||||
|
"is-arguments": "^1.0.4",
|
||||||
|
"is-generator-function": "^1.0.7",
|
||||||
|
"is-typed-array": "^1.1.3",
|
||||||
|
"which-typed-array": "^1.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/util-deprecate": {
|
"node_modules/util-deprecate": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
|
@ -2582,6 +2863,25 @@
|
||||||
"which": "bin/which"
|
"which": "bin/which"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/which-typed-array": {
|
||||||
|
"version": "1.1.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.15.tgz",
|
||||||
|
"integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"available-typed-arrays": "^1.0.7",
|
||||||
|
"call-bind": "^1.0.7",
|
||||||
|
"for-each": "^0.3.3",
|
||||||
|
"gopd": "^1.0.1",
|
||||||
|
"has-tostringtag": "^1.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/wrappy": {
|
"node_modules/wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
|
|
@ -20,10 +20,11 @@
|
||||||
"@babel/generator": "^7.23.0",
|
"@babel/generator": "^7.23.0",
|
||||||
"@babel/parser": "^7.23.0",
|
"@babel/parser": "^7.23.0",
|
||||||
"@babel/traverse": "^7.23.0",
|
"@babel/traverse": "^7.23.0",
|
||||||
"@types/babel__traverse": "^7.20.5",
|
|
||||||
"@types/babel-traverse": "^6.25.10",
|
"@types/babel-traverse": "^6.25.10",
|
||||||
|
"@types/babel__traverse": "^7.20.5",
|
||||||
"babel": "^6.23.0",
|
"babel": "^6.23.0",
|
||||||
"bun": "^1.0.4",
|
"bun": "^1.0.4",
|
||||||
"ts-node": "^10.9.1"
|
"ts-node": "^10.9.1",
|
||||||
|
"util": "^0.12.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
src/api/jstqlsh.ts
Normal file
8
src/api/jstqlsh.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { SelfHostedRecipe } from "../transform/transform";
|
||||||
|
import { transform } from "../transform/transform";
|
||||||
|
|
||||||
|
export function transformSH(spec: SelfHostedRecipe[], code: string) {
|
||||||
|
let res = transform(spec, code);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
|
@ -1,36 +1,9 @@
|
||||||
//import * as babelparser from "../babel/packages/babel-parser";
|
import { transform } from "./transform/transform";
|
||||||
import * as babelparser from "@babel/parser";
|
|
||||||
//import core from "../babel/packages/babel-core";
|
|
||||||
import { parse_with_plugins } from "./parser/parse";
|
|
||||||
import {
|
|
||||||
SelfHostedRecipe,
|
|
||||||
TransformRecipe,
|
|
||||||
transform,
|
|
||||||
} from "./transform/transform";
|
|
||||||
import { readdir } from "node:fs/promises";
|
import { readdir } from "node:fs/promises";
|
||||||
import { parseJSTQL } from "./langium/langiumRunner";
|
import { parseJSTQL } from "./langium/langiumRunner";
|
||||||
|
|
||||||
const dir = "../prettier/src";
|
|
||||||
|
|
||||||
const path = "test_files/test2.js";
|
|
||||||
const file = Bun.file(path);
|
|
||||||
const codeFromFile = await file.text();
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
//transform(selfHostedTransformExampleMultiStmt, codeFromFile);
|
let basepathExamplesJSFiles = "../three.js";
|
||||||
|
|
||||||
/*
|
|
||||||
console.log(codeFromFile);
|
|
||||||
const jstql_file =
|
|
||||||
"/home/rolfmg/Coding/Master/didactic-chainsaw/dsl_files/awaitToPromise.jstql";
|
|
||||||
const test_file = Bun.file(jstql_file);
|
|
||||||
const test_JSTQL = await test_file.text();
|
|
||||||
let proposals = await parseJSTQL(test_JSTQL);
|
|
||||||
|
|
||||||
let [code, count] = transform(proposals[0].cases, codeFromFile);
|
|
||||||
await Bun.write("output_files/test2.js", code);
|
|
||||||
return;
|
|
||||||
*/
|
|
||||||
let basepathExamplesJSFiles = "../next.js";
|
|
||||||
let examples = (await readdir(basepathExamplesJSFiles, { recursive: true }))
|
let examples = (await readdir(basepathExamplesJSFiles, { recursive: true }))
|
||||||
.filter((x) => x.endsWith(".js"))
|
.filter((x) => x.endsWith(".js"))
|
||||||
.map((x) => basepathExamplesJSFiles + "/" + x);
|
.map((x) => basepathExamplesJSFiles + "/" + x);
|
||||||
|
@ -40,7 +13,7 @@ const main = async () => {
|
||||||
"pipeline.jstql",
|
"pipeline.jstql",
|
||||||
"do.jstql",
|
"do.jstql",
|
||||||
"awaitToPromise.jstql",
|
"awaitToPromise.jstql",
|
||||||
].slice(1, 2)) {
|
]) {
|
||||||
const jstql_file = "dsl_files/" + proposalFile;
|
const jstql_file = "dsl_files/" + proposalFile;
|
||||||
const test_file = Bun.file(jstql_file);
|
const test_file = Bun.file(jstql_file);
|
||||||
const test_JSTQL = await test_file.text();
|
const test_JSTQL = await test_file.text();
|
|
@ -24,7 +24,7 @@ export function parseInternalTraTo(code: string): string {
|
||||||
// We encountered a closing tag
|
// We encountered a closing tag
|
||||||
flag = false;
|
flag = false;
|
||||||
|
|
||||||
cleanedJS += temp;
|
cleanedJS += "_$$_" + temp + "_$$_";
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
temp = "";
|
temp = "";
|
||||||
|
@ -59,7 +59,8 @@ export function parseInternalAplTo(code: string): InternalParseResult {
|
||||||
let wildcard = new WildcardParser(
|
let wildcard = new WildcardParser(
|
||||||
new WildcardTokenizer(temp).tokenize()
|
new WildcardTokenizer(temp).tokenize()
|
||||||
).parse();
|
).parse();
|
||||||
//wildcard.identifier.name = "_" + wildcard.identifier.name + "_";
|
wildcard.identifier.name =
|
||||||
|
"_$$_" + wildcard.identifier.name + "_$$_";
|
||||||
cleanedJS += wildcard.identifier.name;
|
cleanedJS += wildcard.identifier.name;
|
||||||
|
|
||||||
prelude.push(wildcard);
|
prelude.push(wildcard);
|
||||||
|
|
|
@ -19,13 +19,13 @@ function extractValues(types: t.Statement[]): Wildcard[] {
|
||||||
if (init) {
|
if (init) {
|
||||||
if (init.type == "StringLiteral") {
|
if (init.type == "StringLiteral") {
|
||||||
init = <t.StringLiteral>init;
|
init = <t.StringLiteral>init;
|
||||||
prelude.push(
|
let wildcard = new WildcardParser(
|
||||||
new WildcardParser(
|
|
||||||
new WildcardTokenizer(
|
new WildcardTokenizer(
|
||||||
innerDSLVariableName + ":" + init
|
innerDSLVariableName + ":" + init
|
||||||
).tokenize()
|
).tokenize()
|
||||||
).parse()
|
).parse();
|
||||||
);
|
|
||||||
|
prelude.push(wildcard);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Invalid usage of right side declaration in prelude"
|
"Invalid usage of right side declaration in prelude"
|
||||||
|
|
|
@ -116,7 +116,7 @@ export class WildcardTokenizer {
|
||||||
}
|
}
|
||||||
private isAlpha(val: string): boolean {
|
private isAlpha(val: string): boolean {
|
||||||
let alphabet = new Set(
|
let alphabet = new Set(
|
||||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_".split("")
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890".split("")
|
||||||
);
|
);
|
||||||
return alphabet.has(val);
|
return alphabet.has(val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ export function transform(
|
||||||
return [output, amount];
|
return [output, amount];
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformSelfHosted(
|
export function transformSelfHosted(
|
||||||
recipe: TransformRecipe,
|
recipe: TransformRecipe,
|
||||||
internals: Wildcard[],
|
internals: Wildcard[],
|
||||||
codeAST: t.Node
|
codeAST: t.Node
|
||||||
|
@ -91,11 +91,8 @@ function transformSelfHosted(
|
||||||
throw new Error("This no worky LOL");
|
throw new Error("This no worky LOL");
|
||||||
}
|
}
|
||||||
let matches = runMatch(codeTree, applicableToTree, internals);
|
let matches = runMatch(codeTree, applicableToTree, internals);
|
||||||
//showTreePaired(matches[0].statements[0]);
|
|
||||||
//console.log("We found", matches.length, "matches");
|
|
||||||
|
|
||||||
let outputAST = transformer(matches, transformToTree, codeAST, transformTo);
|
let outputAST = transformer(matches, transformToTree, codeAST, transformTo);
|
||||||
|
|
||||||
//console.log("Finished transforming");
|
|
||||||
return [outputAST, matches.length];
|
return [outputAST, matches.length];
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ export function transformer(
|
||||||
|
|
||||||
// For multi line applicable to
|
// For multi line applicable to
|
||||||
for (let i = 0; i < match.statements.length - 1; i++) {
|
for (let i = 0; i < match.statements.length - 1; i++) {
|
||||||
siblings[i].remove();
|
//siblings[i].remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For when we have matched with +
|
// For when we have matched with +
|
||||||
|
@ -118,8 +118,10 @@ function extractWildcardPairs(match: Match): Map<string, t.Node[]> {
|
||||||
name = node.element.aplToNode.expression.name;
|
name = node.element.aplToNode.expression.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) {
|
if (name && name.startsWith("_$$_")) {
|
||||||
if (map.has(name)) {
|
if (map.has(name)) {
|
||||||
|
console.log(name);
|
||||||
|
console.log(map.get(name));
|
||||||
throw new Error("Wildcard encountered twice!");
|
throw new Error("Wildcard encountered twice!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
let aaaa = () => {
|
let aaaa = (() => {
|
||||||
let g = 100;
|
let g = 100;
|
||||||
let ff = 10;
|
let ff = 10;
|
||||||
let ggg = a(b);
|
let ggg = a(b);
|
||||||
return 100;
|
return 100;
|
||||||
};
|
})();
|
||||||
|
|
||||||
var bbaaa = (function () {
|
var bbaaa = (function () {
|
||||||
let lllll = 1 + 1;
|
let lllll = 1 + 1;
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
let a = LOOOOOOOOL();
|
|
||||||
let b = (999 * 128) / 12;
|
|
||||||
|
|
||||||
const haha = () => {
|
|
||||||
let a = LOOOOOOOOL();
|
|
||||||
let b = (999 * 128) / 12;
|
|
||||||
};
|
|
|
@ -1,8 +0,0 @@
|
||||||
let something = 1 + 1;
|
|
||||||
let yikers = hahahah;
|
|
||||||
|
|
||||||
let lol = () => 100 + 100;
|
|
||||||
|
|
||||||
function haha() {
|
|
||||||
let fhdsjkfhdsjkfhds = fjhdkslfjhdsklfjdskl;
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
let x = () => {
|
|
||||||
let b = 0;
|
|
||||||
return b;
|
|
||||||
};
|
|
6
test_files/test3.js
Normal file
6
test_files/test3.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
let something = Iterator.from([1,2,3]);
|
||||||
|
let someOtherThing = Iterator.from([4,5,6]);
|
||||||
|
let generate = function* () {
|
||||||
|
yield* something;
|
||||||
|
yield* someOtherThing;
|
||||||
|
}();
|
|
@ -2,7 +2,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"strict": true,
|
"strict": false,
|
||||||
"target": "es2017",
|
"target": "es2017",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
@ -10,6 +10,6 @@
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"types": ["bun-types"]
|
"types": ["bun-types"]
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src", "index.ts"],
|
||||||
"exclude": ["babel"]
|
"exclude": ["babel"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue