@jspicl/core 4.0.0-alpha.2 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"returnStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,GAAG,IAAI,KACpB,IAAI,IAAI,eAAmD,CAAC;AAE/D,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"returnStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,GAAG,IAAI,KACpB,IAAI,IAAI,eAAmD,CAAC;AAE/D,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,eAAe,CAmB3D,CAAC"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export const isReturnStatement = (node) => node?.type === "ReturnStatement";
|
|
2
2
|
export const ReturnStatement = ({ argument }, { transpile }) => {
|
|
3
|
+
// It's common for minification of Javascript to yield return statements like `return (a, b, c)`,
|
|
4
|
+
// which is a sequence expression. In Lua, we need to split the sequence expression into multiple lines and return the last expression.
|
|
5
|
+
if (argument?.type === "SequenceExpression") {
|
|
6
|
+
const lastExpression = argument.expressions[argument.expressions.length - 1];
|
|
7
|
+
const expressions = argument.expressions.slice(0, -1);
|
|
8
|
+
const transpiledExpressions = transpile(expressions);
|
|
9
|
+
const transpiledLastExpresion = transpile(lastExpression);
|
|
10
|
+
return `${transpiledExpressions}\nreturn ${transpiledLastExpresion}`;
|
|
11
|
+
}
|
|
3
12
|
const value = transpile(argument);
|
|
4
13
|
return value ? `return ${value}` : "do return end";
|
|
5
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"returnStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAqB,EACI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAoC,CAC9D,EAAC,QAAQ,EAAC,EACV,EAAC,SAAS,EAAC,EACX,EAAE;IACF,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAElC,OAAO,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;AACrD,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"returnStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/returnStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAqB,EACI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAoC,CAC9D,EAAC,QAAQ,EAAC,EACV,EAAC,SAAS,EAAC,EACX,EAAE;IACF,iGAAiG;IACjG,uIAAuI;IACvI,IAAI,QAAQ,EAAE,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAC5C,MAAM,cAAc,GAClB,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACtD,MAAM,qBAAqB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QACrD,MAAM,uBAAuB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QAE1D,OAAO,GAAG,qBAAqB,YAAY,uBAAuB,EAAE,CAAC;IACvE,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAElC,OAAO,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PICO-8 v0.2.7 Global API Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* To use these global types in your project, add this to your tsconfig.json:
|
|
5
|
+
* {
|
|
6
|
+
* "compilerOptions": {
|
|
7
|
+
* "types": ["jspicl/pico8-api"]
|
|
8
|
+
* }
|
|
9
|
+
* }
|
|
10
|
+
*
|
|
11
|
+
* Or include it directly:
|
|
12
|
+
* {
|
|
13
|
+
* "include": ["node_modules/jspicl/dist/pico8-api.d.ts"]
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
// ===== Graphics =====
|
|
19
|
+
function cls(col?: number): void;
|
|
20
|
+
function camera(x?: number, y?: number): void;
|
|
21
|
+
function clip(x?: number, y?: number, w?: number, h?: number): void;
|
|
22
|
+
function pset(x: number, y: number, col?: number): void;
|
|
23
|
+
function pget(x: number, y: number): number;
|
|
24
|
+
function spr(
|
|
25
|
+
n: number,
|
|
26
|
+
x: number,
|
|
27
|
+
y: number,
|
|
28
|
+
w?: number,
|
|
29
|
+
h?: number,
|
|
30
|
+
flip_x?: boolean,
|
|
31
|
+
flip_y?: boolean
|
|
32
|
+
): void;
|
|
33
|
+
function map(
|
|
34
|
+
cel_x: number,
|
|
35
|
+
cel_y: number,
|
|
36
|
+
sx: number,
|
|
37
|
+
sy: number,
|
|
38
|
+
cel_w: number,
|
|
39
|
+
cel_h: number,
|
|
40
|
+
layer?: number
|
|
41
|
+
): void;
|
|
42
|
+
function mget(x: number, y: number): number;
|
|
43
|
+
function mset(x: number, y: number, val: number): void;
|
|
44
|
+
function line(
|
|
45
|
+
x0: number,
|
|
46
|
+
y0: number,
|
|
47
|
+
x1: number,
|
|
48
|
+
y1: number,
|
|
49
|
+
col?: number
|
|
50
|
+
): void;
|
|
51
|
+
function circ(x: number, y: number, r: number, col?: number): void;
|
|
52
|
+
function circfill(x: number, y: number, r: number, col?: number): void;
|
|
53
|
+
function rect(
|
|
54
|
+
x0: number,
|
|
55
|
+
y0: number,
|
|
56
|
+
x1: number,
|
|
57
|
+
y1: number,
|
|
58
|
+
col?: number
|
|
59
|
+
): void;
|
|
60
|
+
function rectfill(
|
|
61
|
+
x0: number,
|
|
62
|
+
y0: number,
|
|
63
|
+
x1: number,
|
|
64
|
+
y1: number,
|
|
65
|
+
col?: number
|
|
66
|
+
): void;
|
|
67
|
+
function rrect(
|
|
68
|
+
x0: number,
|
|
69
|
+
y0: number,
|
|
70
|
+
x1: number,
|
|
71
|
+
y1: number,
|
|
72
|
+
r: number,
|
|
73
|
+
col?: number
|
|
74
|
+
): void;
|
|
75
|
+
function rrectfill(
|
|
76
|
+
x0: number,
|
|
77
|
+
y0: number,
|
|
78
|
+
x1: number,
|
|
79
|
+
y1: number,
|
|
80
|
+
r: number,
|
|
81
|
+
col?: number
|
|
82
|
+
): void;
|
|
83
|
+
function oval(
|
|
84
|
+
x0: number,
|
|
85
|
+
y0: number,
|
|
86
|
+
x1: number,
|
|
87
|
+
y1: number,
|
|
88
|
+
col?: number
|
|
89
|
+
): void;
|
|
90
|
+
function ovalfill(
|
|
91
|
+
x0: number,
|
|
92
|
+
y0: number,
|
|
93
|
+
x1: number,
|
|
94
|
+
y1: number,
|
|
95
|
+
col?: number
|
|
96
|
+
): void;
|
|
97
|
+
function pal(c0?: number, c1?: number, p?: number): void;
|
|
98
|
+
function palt(col?: number, t?: boolean): void;
|
|
99
|
+
function fillp(pattern?: number): void;
|
|
100
|
+
function color(col?: number): void;
|
|
101
|
+
function cursor(x: number, y: number, col?: number): void;
|
|
102
|
+
function print(
|
|
103
|
+
str: string | number,
|
|
104
|
+
x?: number,
|
|
105
|
+
y?: number,
|
|
106
|
+
col?: number
|
|
107
|
+
): void;
|
|
108
|
+
|
|
109
|
+
// ===== Tables =====
|
|
110
|
+
function add(tbl: any[], val: any, index?: number): any[];
|
|
111
|
+
function del(tbl: any[], val: any): any;
|
|
112
|
+
function deli(tbl: any[], index: number): any;
|
|
113
|
+
function count(tbl: any[]): number;
|
|
114
|
+
function all(tbl: any[]): any[];
|
|
115
|
+
function foreach(tbl: any[], fn: (item: any) => void): void;
|
|
116
|
+
|
|
117
|
+
// ===== Input =====
|
|
118
|
+
function btn(i?: number, p?: number): boolean | number;
|
|
119
|
+
function btnp(i?: number, p?: number): boolean | number;
|
|
120
|
+
|
|
121
|
+
// ===== Audio =====
|
|
122
|
+
function music(n?: number, fade_len?: number, channel_mask?: number): void;
|
|
123
|
+
function sfx(
|
|
124
|
+
n: number,
|
|
125
|
+
channel?: number,
|
|
126
|
+
offset?: number,
|
|
127
|
+
length?: number
|
|
128
|
+
): void;
|
|
129
|
+
|
|
130
|
+
// ===== Memory =====
|
|
131
|
+
function peek(addr: number): number;
|
|
132
|
+
function peek2(addr: number): number;
|
|
133
|
+
function peek4(addr: number): number;
|
|
134
|
+
function poke(addr: number, val: number): void;
|
|
135
|
+
function poke2(addr: number, val: number): void;
|
|
136
|
+
function poke4(addr: number, val: number): void;
|
|
137
|
+
function memcpy(dest: number, source: number, len: number): void;
|
|
138
|
+
function memset(dest: number, val: number, len: number): void;
|
|
139
|
+
function reload(
|
|
140
|
+
dest: number,
|
|
141
|
+
source: number,
|
|
142
|
+
len: number,
|
|
143
|
+
filename?: string
|
|
144
|
+
): void;
|
|
145
|
+
function cstore(
|
|
146
|
+
dest: number,
|
|
147
|
+
source: number,
|
|
148
|
+
len: number,
|
|
149
|
+
filename?: string
|
|
150
|
+
): void;
|
|
151
|
+
|
|
152
|
+
// ===== Cart Data =====
|
|
153
|
+
function cartdata(id: string): boolean;
|
|
154
|
+
function dset(index: number, value: number): void;
|
|
155
|
+
function dget(index: number): number;
|
|
156
|
+
|
|
157
|
+
// ===== Strings =====
|
|
158
|
+
function chr(...codes: number[]): string;
|
|
159
|
+
function ord(str: string, index?: number): number;
|
|
160
|
+
function sub(str: string, start: number, end?: number): string;
|
|
161
|
+
function tonum(val: any, format?: number): number | undefined;
|
|
162
|
+
function tostr(val: any, hex?: boolean): string;
|
|
163
|
+
|
|
164
|
+
// ===== Math =====
|
|
165
|
+
function max(x: number, y: number): number;
|
|
166
|
+
function min(x: number, y: number): number;
|
|
167
|
+
function mid(x: number, y: number, z: number): number;
|
|
168
|
+
function flr(x: number): number;
|
|
169
|
+
function abs(x: number): number;
|
|
170
|
+
function sgn(x: number): number;
|
|
171
|
+
function sqrt(x: number): number;
|
|
172
|
+
function sin(x: number): number;
|
|
173
|
+
function cos(x: number): number;
|
|
174
|
+
function atan2(dx: number, dy: number): number;
|
|
175
|
+
function rnd(x?: number): number;
|
|
176
|
+
function srand(seed: number): void;
|
|
177
|
+
function band(x: number, y: number): number;
|
|
178
|
+
function bor(x: number, y: number): number;
|
|
179
|
+
function bxor(x: number, y: number): number;
|
|
180
|
+
function bnot(x: number): number;
|
|
181
|
+
function shl(x: number, n: number): number;
|
|
182
|
+
function shr(x: number, n: number): number;
|
|
183
|
+
function rotl(x: number, n: number): number;
|
|
184
|
+
function rotr(x: number, n: number): number;
|
|
185
|
+
|
|
186
|
+
// ===== System =====
|
|
187
|
+
function run(): void;
|
|
188
|
+
function stop(): void;
|
|
189
|
+
function resume(): void;
|
|
190
|
+
function reset(): void;
|
|
191
|
+
function load(filename: string, breadcrumb?: string, param?: string): void;
|
|
192
|
+
function save(filename: string): void;
|
|
193
|
+
function stat(id: number): number | string;
|
|
194
|
+
function menuitem(index: number, label?: string, callback?: () => void): void;
|
|
195
|
+
function printh(str: string, filename?: string, overwrite?: boolean): void;
|
|
196
|
+
|
|
197
|
+
// ===== Callbacks =====
|
|
198
|
+
function _init(): void;
|
|
199
|
+
function _update(): void;
|
|
200
|
+
function _update60(): void;
|
|
201
|
+
function _draw(): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspicl/core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"description": "A javascript to PICO-8 LUA converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"types": "./dist/types.d.ts"
|
|
14
14
|
},
|
|
15
15
|
"./pic8-api.d.ts": {
|
|
16
|
-
"types": "./
|
|
16
|
+
"types": "./global-types/pico8-api.d.ts"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"global-types"
|
|
21
22
|
],
|
|
22
23
|
"publishConfig": {
|
|
23
24
|
"access": "public"
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
"engines": {
|
|
70
71
|
"node": ">=22"
|
|
71
72
|
},
|
|
72
|
-
"stableVersion": "4.0.0-alpha.
|
|
73
|
+
"stableVersion": "4.0.0-alpha.4"
|
|
73
74
|
}
|