-
Notifications
You must be signed in to change notification settings - Fork 3
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
0 parents
commit e8eb22a
Showing
10 changed files
with
1,939 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
env: { | ||
commonjs: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
], | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly', | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 11, | ||
}, | ||
rules: { | ||
}, | ||
}; |
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 @@ | ||
node_modules/ |
Empty file.
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,34 @@ | ||
// @ts-nocheck | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var MyActor = /** @class */ (function (_super) { | ||
__extends(MyActor, _super); | ||
function MyActor() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
MyActor.prototype.properties = function () { | ||
this.hello /*Replicated+EditAnywhere+string*/; | ||
}; | ||
MyActor.prototype.ctor = function () { | ||
this.hello = "Hello? Random: " + Math.round(Math.random() * 100); | ||
}; | ||
MyActor.prototype.receiveBeginPlay = function () { | ||
_super.prototype.receiveBeginPlay.call(this); | ||
console.log(this.hello); | ||
}; | ||
return MyActor; | ||
}(Actor)); | ||
require('bootstrap')('index'); |
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,16 @@ | ||
// @ts-nocheck | ||
|
||
@UCLASS() | ||
class MyActor extends Actor { | ||
@UPROPERTY(Replicated, EditAnywhere) | ||
hello: string; | ||
|
||
constructor() { | ||
this.hello = `Hello? Random: ${Math.round(Math.random() * 100)}`; | ||
} | ||
|
||
receiveBeginPlay() { | ||
super.receiveBeginPlay(); | ||
console.log(this.hello); | ||
} | ||
} |
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,66 @@ | ||
/* eslint-disable no-console */ | ||
const yargs = require('yargs/yargs'); | ||
const { hideBin } = require('yargs/helpers'); | ||
const ts = require('typescript'); | ||
|
||
const utils = require('./utils'); | ||
const parser = require('./parser'); | ||
|
||
const { argv } = yargs(hideBin(process.argv)); | ||
|
||
const processCode = (code) => { | ||
const lines = code.split('\n'); | ||
|
||
const propertyBag = []; | ||
let constructorLine = null; | ||
|
||
// eslint-disable-next-line array-callback-return | ||
const transformedCodeArray = lines.map((line, i) => { | ||
if (parser.isConstructor(line)) { | ||
constructorLine = i; | ||
return parser.replaceConstructorName(line, lines, i); | ||
} | ||
if (parser.isDecorator(line)) { | ||
const [decorator, decoratorArguments] = parser.parseDecorator(line); | ||
if (decorator === 'UCLASS') { | ||
return ''; | ||
} | ||
if (decorator === 'UPROPERTY') { | ||
// basically now we need to check the next line to see what are we trying to decorate | ||
// and get the type accordingly | ||
const nextLine = lines[i + 1]; | ||
const [propertyName, propertyType] = parser.parseTypescriptClassField( | ||
nextLine, | ||
); | ||
propertyBag.push({ | ||
type: propertyType, | ||
name: propertyName, | ||
line: i + 1, | ||
decoratorArguments, | ||
}); | ||
return ''; | ||
} | ||
} | ||
|
||
return line; | ||
}); | ||
|
||
const processedCode = parser.injectBootstrap(parser.injectProperties( | ||
transformedCodeArray, | ||
propertyBag, | ||
constructorLine, | ||
), argv.file); | ||
|
||
const compiledJavascript = ts.transpileModule(processedCode.join('\n'), { | ||
compilerOptions: { removeComments: false }, | ||
}).outputText; | ||
|
||
utils.writeCode(argv.file, compiledJavascript); | ||
}; | ||
|
||
if (argv.file) { | ||
(async () => { | ||
const code = await utils.readCode(argv.file); | ||
processCode(code); | ||
})(); | ||
} |
Oops, something went wrong.