Skip to content

Commit 36bf3cc

Browse files
authored
Merge pull request #4 from TypeScriptToLua/updates
2 parents cedd5e3 + c641578 commit 36bf3cc

32 files changed

+8782
-9375
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{yml,md}]
12+
indent_size = 2

.github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check:
7+
name: Check
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Use Node.js 12
13+
uses: actions/setup-node@v1
14+
with:
15+
node-version: 12
16+
- run: npm ci
17+
- run: npm run build
18+
- run: npm run lint

.github/workflows/deploy.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: master
6+
7+
jobs:
8+
deploy:
9+
name: Deploy
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Use Node.js 12
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
- run: npm ci
19+
- run: npm run build
20+
- uses: peaceiris/actions-gh-pages@v3
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
publish_dir: dist
24+
publish_branch: master

.gitignore

+2-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
node_modules/
2-
yarn.lock
3-
4-
coverage/
5-
.nyc*
6-
*.js.map
7-
8-
# Release
9-
*.tgz
10-
11-
# OSX
12-
.DS_Store
13-
*.lcov
14-
15-
# IDEA IDEs
16-
.idea/
17-
18-
typescript_lualib.lua
19-
lualib_bundle.lua
20-
21-
dist/*
1+
node_modules
2+
/dist

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist

assets/layout/landing.html

+22-19
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,57 @@
2222
<main>
2323
<div id="example">
2424
<div id="ts">
25+
<!-- prettier-ignore -->
2526
<div class="example-item" id="ts-declarations"><b>// TS Declarations</b>
2627

28+
/** <a href="https://github.com/TypeScriptToLua/TypeScriptToLua/wiki/Functions-and-the-%60self%60-Parameter#noselfinfile" target="_blank">@noSelfInFile</a> */
2729
type Vector = [number, number, number];
2830

29-
declare class Unit {
30-
getLevel(): number;
31+
declare function findUnitsInRadius(center: Vector, radius: number): Unit[];
32+
declare interface Unit {
3133
isEnemy(other: Unit): boolean;
3234
kill(): void;
33-
FindUnitsInRadius(radius: number): Unit[];
3435
}</div>
36+
<!-- prettier-ignore -->
3537
<div class="example-item" id="ts-source"><b>// TS Source</b>
3638

37-
function onSpellStart(caster: Unit, targetLocation: Vector): void {
38-
const units = FindUnitsInRadius(targetLocation, 500);
39+
function onAbilityCast(this: void, caster: Unit, targetLocation: Vector) {
40+
const units = findUnitsInRadius(targetLocation, 500);
3941
const enemies = units.filter(unit => caster.isEnemy(unit));
4042

4143
for (const enemy of enemies) {
4244
enemy.kill();
4345
}
4446
}</div>
4547
</div>
48+
<!-- prettier-ignore -->
4649
<div class="example-item" id="lua"><b>-- Lua Output</b>
4750

48-
function onSpellStart(caster, targetLocation)
49-
local units = FindUnitsInRadius(targetLocation, 500);
50-
local enemies = __TS__ArrayFilter(units, function(unit) return caster:isEnemy(unit) end);
51-
for _, enemy in ipairs(enemies) do
52-
do
53-
enemy:kill();
54-
end
51+
function onAbilityCast(caster, targetLocation)
52+
local units = findUnitsInRadius(targetLocation, 500)
53+
local enemies = __TS__ArrayFilter(units, function(____, unit) return caster:isEnemy(unit) end)
54+
for ____, enemy in ipairs(enemies) do
55+
enemy:kill()
5556
end
5657
end</div>
5758
</div>
5859
<div id="features">
5960
<div class="feature-item">
6061
<div class="feature-header">Extend existing APIs</div>
61-
This project is useful in any environment where Lua code is accepted,
62-
with the powerful option of simply declaring any existing API using TypeScript declaration files.
62+
This project is useful in any environment where Lua code is accepted, with the powerful option of simply
63+
declaring any existing API using TypeScript declaration files.
6364
</div>
6465
<div class="feature-item">
6566
<div class="feature-header">Type Safety</div>
66-
Static types can ease the mental burden of writing programs, by automatically tracking information the programmer would otherwise have to track mentally in some fashion.
67-
Types serve as documentation for yourself and other programmers and provide a ‘gradient’ that tells you what terms make sense to write.
67+
Static types can ease the mental burden of writing programs, by automatically tracking information the
68+
programmer would otherwise have to track mentally in some fashion. Types serve as documentation for yourself
69+
and other programmers and provide a ‘gradient’ that tells you what terms make sense to write.
6870
</div>
6971
<div class="feature-item">
7072
<div class="feature-header">IDE Support</div>
71-
Types enable JavaScript developers to use highly-productive development tools and practices like static checking and code refactoring when developing JavaScript applications.
72-
TypeScript extensions are available for many text editors.
73+
Types enable JavaScript developers to use highly-productive development tools and practices like static
74+
checking and code refactoring when developing JavaScript applications. TypeScript extensions are available
75+
for many text editors.
7376
</div>
7477
</div>
75-
</main>
78+
</main>

assets/layout/play.html

+6-10
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@
1313
</div>
1414
<div id="content">
1515
<div id="editor-container">
16-
<div id="editor-ts" class="editor">
17-
</div>
18-
<div id="editor-lua" class="editor editor-lua-active">
19-
</div>
20-
<div id="editor-lua-ast" class="editor">
21-
</div>
16+
<div id="editor-ts" class="editor"></div>
17+
<div id="editor-lua" class="editor editor-lua-active"></div>
18+
<div id="editor-lua-ast" class="editor"></div>
2219
<div id="editor-output" class="editor">
2320
<div id="editor-output-linenumbers">
2421
>_
2522
</div>
2623
<div id="editor-output-terminal">
2724
<div id="editor-output-terminal-header">
28-
TypescriptToLua version ...
29-
</div>
30-
<div id="editor-output-terminal-content">
25+
TypeScriptToLua version ...
3126
</div>
27+
<div id="editor-output-terminal-content"></div>
3228
</div>
3329
</div>
3430
</div>
35-
</div>
31+
</div>

assets/layout/template.html

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7-
<link rel="apple-touch-icon" sizes="180x180" href="<%= require('../images/favicons/apple-touch-icon.png') %>">
8-
<link rel="icon" type="image/png" sizes="32x32" href="<%= require('../images/favicons/favicon-32x32.png') %>">
9-
<link rel="icon" type="image/png" sizes="16x16" href="<%= require('../images/favicons/favicon-16x16.png') %>">
10-
<link rel="manifest" href="<%= require('../images/favicons/site.webmanifest') %>">
11-
<link rel="mask-icon" href="<%= require('../images/favicons/safari-pinned-tab.svg') %>" color="#418fd6">
12-
<meta name="msapplication-TileColor" content="#2d89ef">
13-
<meta name="theme-color" content="#ffffff">
14-
<title><%= htmlWebpackPlugin.options.title %></title>
15-
</head>
16-
<body>
17-
<%= require('html-loader!./' + htmlWebpackPlugin.options.contentFile ) %>
18-
</body>
19-
</html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
7+
<link rel="apple-touch-icon" sizes="180x180" href="<%= require('../images/favicons/apple-touch-icon.png') %>" />
8+
<link rel="icon" type="image/png" sizes="32x32" href="<%= require('../images/favicons/favicon-32x32.png') %>" />
9+
<link rel="icon" type="image/png" sizes="16x16" href="<%= require('../images/favicons/favicon-16x16.png') %>" />
10+
<link rel="manifest" href="<%= require('../images/favicons/site.webmanifest') %>" />
11+
<link rel="mask-icon" href="<%= require('../images/favicons/safari-pinned-tab.svg') %>" color="#418fd6" />
12+
<meta name="msapplication-TileColor" content="#2d89ef" />
13+
<meta name="theme-color" content="#ffffff" />
14+
<title><%= htmlWebpackPlugin.options.title %></title>
15+
</head>
16+
<body>
17+
<%= require('html-loader!./' + htmlWebpackPlugin.options.contentFile ) %>
18+
</body>
19+
</html>

assets/styles/_base.scss

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
@import 'fonts';
2-
@import 'colors';
1+
@import "fonts";
2+
@import "colors";
33

4-
html, body {
5-
width: 100%; height: 100%;
4+
html,
5+
body {
6+
width: 100%;
7+
height: 100%;
68
padding: 0px;
79
margin: 0px;
810
font-family: "Open Sans";
@@ -17,4 +19,4 @@ div {
1719
a {
1820
color: inherit;
1921
text-decoration: none;
20-
}
22+
}

assets/styles/_colors.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ $ts-blue: rgb(67, 119, 194);
33
$body-background: #1e1e1e;
44
$grey-accent: #333333;
55
$body-font-color: #ededed;
6-
$card-color: #1d2021;
6+
$card-color: #1d2021;

assets/styles/_fonts.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,700|Raleway:300,400,700|Source+Code+Pro');
1+
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,700|Raleway:300,400,700|Source+Code+Pro");
22

3-
$console-fonts: Menlo, Monaco, "Lucida Console", "Courier New", monospace;
3+
$console-fonts: Menlo, Monaco, "Lucida Console", "Courier New", monospace;

assets/styles/landing.scss

+34-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@import 'base';
1+
@import "base";
22

3-
main, header {
4-
width: 900px;
3+
main,
4+
header {
55
overflow: hidden;
66
margin-left: auto;
77
margin-right: auto;
@@ -46,11 +46,18 @@ nav {
4646
}
4747
}
4848

49+
main {
50+
display: flex;
51+
flex-flow: column;
52+
align-items: center;
53+
}
54+
4955
#features {
56+
max-width: 900px;
5057
margin-top: 30px;
5158
margin-bottom: 20px;
5259
display: flex;
53-
flex-wrap: wrap;
60+
flex-wrap: wrap;
5461
}
5562

5663
.feature-item {
@@ -65,42 +72,42 @@ nav {
6572
margin-bottom: 10px;
6673
}
6774

68-
.example-item {
69-
padding: (15px !important);
70-
white-space: pre;
71-
font-size: 12px;
72-
font-family: $console-fonts;
75+
#example {
76+
max-width: 100%;
77+
margin-top: 70px;
7378
}
7479

7580
#example #ts {
7681
display: flex;
77-
border-bottom: solid 2px #5690fc;
82+
@media screen and (max-width: 1200px) {
83+
flex-direction: column;
84+
}
7885
}
7986

80-
#example {
81-
margin-top: 70px;
82-
width: 100%;
87+
.example-item {
88+
padding: (15px !important);
89+
white-space: pre;
90+
font-size: 12px;
91+
font-family: $console-fonts;
8392
}
8493

85-
#ts-declarations, #ts-source {
86-
display: inline-block;
87-
overflow: hidden;
94+
@media screen and (max-width: 1200px) {
95+
.example-item:not(#lua) {
96+
border-bottom: solid 2px #5690fc;
97+
}
8898
}
8999

90-
#ts-declarations {
91-
flex: 40%;
92-
}
100+
@media screen and (min-width: 1201px) {
101+
#example #ts {
102+
border-bottom: solid 2px #5690fc;
103+
}
93104

94-
#ts-source {
95-
flex: 60%;
96-
border-left: solid 2px #5690fc;
105+
#ts-source {
106+
border-left: solid 2px #5690fc;
107+
}
97108
}
98109

99110
@media screen and (max-width: 900px) {
100-
main, header {
101-
width: 100%;
102-
}
103-
104111
nav {
105112
font-size: 24px;
106113
}
@@ -110,10 +117,6 @@ nav {
110117
margin-top: 15px;
111118
}
112119

113-
.example-item {
114-
font-size: 9px;
115-
}
116-
117120
#example {
118121
margin-top: 25px;
119122
}
@@ -129,4 +132,4 @@ nav {
129132
.feature-item {
130133
flex: 100%;
131134
}
132-
}
135+
}

0 commit comments

Comments
 (0)