@jspicl/core 4.0.1 → 4.0.3
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.
- package/README.md +42 -7
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @jspicl/core
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The transpiler library that converts JavaScript to PICO-8 Lua. Use this to build custom tools, integrate into existing pipelines, or when you need fine-grained control over transpilation.
|
|
4
|
+
|
|
5
|
+
> **Most users should use [@jspicl/cli](../cli)** - it handles bundling, transpiling, and cartridge generation in one step.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -22,8 +24,6 @@ function _init() {
|
|
|
22
24
|
function _update() {
|
|
23
25
|
if (btn(0)) x -= 1;
|
|
24
26
|
if (btn(1)) x += 1;
|
|
25
|
-
if (btn(2)) y -= 1;
|
|
26
|
-
if (btn(3)) y += 1;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function _draw() {
|
|
@@ -34,10 +34,45 @@ function _draw() {
|
|
|
34
34
|
|
|
35
35
|
const result = jspicl(javascript);
|
|
36
36
|
console.log(result.code);
|
|
37
|
-
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Output:**
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
```lua
|
|
42
|
+
function _init()
|
|
43
|
+
x = 64
|
|
44
|
+
y = 64
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
function _update()
|
|
48
|
+
if btn(0) then
|
|
49
|
+
x -= 1
|
|
50
|
+
end
|
|
51
|
+
if btn(1) then
|
|
52
|
+
x += 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
function _draw()
|
|
57
|
+
cls()
|
|
58
|
+
circfill(x, y, 4, 8)
|
|
59
|
+
end
|
|
41
60
|
```
|
|
42
61
|
|
|
43
|
-
|
|
62
|
+
## Advanced Usage
|
|
63
|
+
|
|
64
|
+
Extend or replace transpilation behavior with custom mappers:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const result = jspicl(javascript, {
|
|
68
|
+
customMappers: {
|
|
69
|
+
// Replace how while loops are transpiled
|
|
70
|
+
WhileStatement: ({body, test}, {transpile}) =>
|
|
71
|
+
`while ${transpile(test)} do\n${transpile(body)}\nend`
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Documentation
|
|
77
|
+
|
|
78
|
+
Visit [jspicl.github.io](https://jspicl.github.io/reference/api/) for the full API reference and customization guides.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspicl/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "A javascript to PICO-8 LUA converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,9 +41,10 @@
|
|
|
41
41
|
"trailingComma": "none",
|
|
42
42
|
"useTabs": false
|
|
43
43
|
},
|
|
44
|
+
"homepage": "https://jspicl.github.io",
|
|
44
45
|
"repository": {
|
|
45
46
|
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/
|
|
47
|
+
"url": "git+https://github.com/jspicl/jspicl"
|
|
47
48
|
},
|
|
48
49
|
"keywords": [
|
|
49
50
|
"pico-8",
|