@jspicl/core 4.0.0-alpha.4 → 4.0.1
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/CHANGELOG.md +0 -1
- package/README.md +1 -70
- package/dist/ast/expressions/newExpression.d.ts.map +1 -1
- package/dist/ast/expressions/newExpression.js.map +1 -1
- package/dist/ast/statements/forStatement.d.ts.map +1 -1
- package/dist/ast/statements/forStatement.js.map +1 -1
- package/dist/ast/statements/ifStatement.d.ts.map +1 -1
- package/dist/ast/statements/ifStatement.js.map +1 -1
- package/dist/polyfills/getRequiredPolyfills.d.ts.map +1 -1
- package/dist/polyfills/getRequiredPolyfills.js.map +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -241,7 +241,6 @@ _2017-11-14_
|
|
|
241
241
|
- Api now returns an object containing the transpiled code and polyfills instead of a string
|
|
242
242
|
- Polyfills are now only included if used
|
|
243
243
|
- Added several polyfills/remaps:
|
|
244
|
-
|
|
245
244
|
- object/array.toString()
|
|
246
245
|
- console.log
|
|
247
246
|
- array.reduce
|
package/README.md
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The core transpiler library for jspicl. Converts JavaScript to PICO-8 Lua.
|
|
4
4
|
|
|
5
|
-
<a href="https://www.npmjs.com/package/@jspicl/core" target="_blank" rel="noopener noreferrer">
|
|
6
|
-
<img alt="npm version" src="https://img.shields.io/npm/v/@jspicl/core.svg?style=for-the-badge" />
|
|
7
|
-
<img alt="License" src="https://img.shields.io/npm/l/@jspicl/core.svg?style=for-the-badge">
|
|
8
|
-
</a>
|
|
9
|
-
|
|
10
5
|
## Installation
|
|
11
6
|
|
|
12
7
|
```bash
|
|
@@ -45,68 +40,4 @@ console.log(result.polyfills);
|
|
|
45
40
|
// Output: Any required polyfill implementations
|
|
46
41
|
```
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### `jspicl(source, options?)`
|
|
51
|
-
|
|
52
|
-
Transpiles JavaScript source code to PICO-8 Lua.
|
|
53
|
-
|
|
54
|
-
#### Parameters
|
|
55
|
-
|
|
56
|
-
- `source` (string) - The JavaScript source code to transpile
|
|
57
|
-
- `options` (object, optional)
|
|
58
|
-
- `prettify` (boolean, default: `true`) - Whether to format the output with proper indentation
|
|
59
|
-
- `customMappers` (object) - Custom AST node handlers to override or extend transpilation
|
|
60
|
-
|
|
61
|
-
#### Returns
|
|
62
|
-
|
|
63
|
-
An object containing:
|
|
64
|
-
- `code` (string) - The transpiled Lua code
|
|
65
|
-
- `polyfills` (object) - Map of required polyfill function names to their Lua implementations
|
|
66
|
-
|
|
67
|
-
### Types
|
|
68
|
-
|
|
69
|
-
Types can be imported from `@jspicl/core/types`:
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
import type {JspiclOptions, JspiclOutput, AstNodeParser} from "@jspicl/core/types";
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Custom Mappers
|
|
76
|
-
|
|
77
|
-
You can provide custom mappers to override how specific AST node types are transpiled:
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
import {jspicl} from "@jspicl/core";
|
|
81
|
-
|
|
82
|
-
const customMappers = {
|
|
83
|
-
Literal: ({raw}) => {
|
|
84
|
-
// Custom handling for literals
|
|
85
|
-
return raw === "null" ? "nil" : raw;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const result = jspicl(source, {customMappers});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Each mapper receives the AST node and an options object with:
|
|
93
|
-
- `transpile` - Function to recursively transpile child nodes
|
|
94
|
-
- `scope` - Object containing variable metadata and scope information
|
|
95
|
-
|
|
96
|
-
## Supported Polyfills
|
|
97
|
-
|
|
98
|
-
When your JavaScript uses methods without direct Lua equivalents, jspicl automatically detects and provides polyfill implementations:
|
|
99
|
-
|
|
100
|
-
- Array methods: `map`, `filter`, `reduce`, `includes`, `findIndex`, `join`, `pop`, `sort`
|
|
101
|
-
- String methods: `split`, `substr`, `substring`, `toString`
|
|
102
|
-
- Object methods: `Object.assign`, `Object.keys`, `Object.values`, `Object.entries`
|
|
103
|
-
|
|
104
|
-
The polyfills are returned separately so you can include them once at the top of your PICO-8 cartridge.
|
|
105
|
-
|
|
106
|
-
## Requirements
|
|
107
|
-
|
|
108
|
-
- Node.js 22+
|
|
109
|
-
|
|
110
|
-
## License
|
|
111
|
-
|
|
112
|
-
MIT
|
|
43
|
+
Visit [jspicl.github.io](https://jspicl.github.io/reference/api/) for detailed documentation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"newExpression.d.ts","sourceRoot":"","sources":["../../../src/ast/expressions/newExpression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"newExpression.d.ts","sourceRoot":"","sources":["../../../src/ast/expressions/newExpression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,GAAG,IAAI,KAAG,IAAI,IAAI,aAChC,CAAC;AAEjC,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,aAAa,CAQvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"newExpression.js","sourceRoot":"","sources":["../../../src/ast/expressions/newExpression.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"newExpression.js","sourceRoot":"","sources":["../../../src/ast/expressions/newExpression.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAyB,EAAE,CAC9E,IAAI,EAAE,IAAI,KAAK,eAAe,CAAC;AAEjC,MAAM,CAAC,MAAM,aAAa,GAAkC,CAC1D,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,EACzB,EAAC,SAAS,EAAC,EACX,EAAE;IACF,MAAM,SAAS,GAAG,SAAS,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/C,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,EAAE,EAAC,cAAc,EAAE,GAAG,EAAC,CAAC,CAAC;IAE9D,OAAO,GAAG,SAAS,IAAI,cAAc,GAAG,CAAC;AAC3C,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/forStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"forStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/forStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,GAAG,IAAI,KAAG,IAAI,IAAI,YAChC,CAAC;AAEhC,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,YAAY,CAQhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/forStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"forStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/forStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAqB,EAAwB,EAAE,CAC5E,IAAI,EAAE,IAAI,KAAK,cAAc,CAAC;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAiC,CACxD,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,EAC1B,EAAC,SAAS,EAAC,EACX,EAAE,CACF,GAAG,SAAS,CAAC,IAAI,CAAC;UACV,SAAS,CAAC,IAAI,CAAC;MACnB,SAAS,CAAC,IAAI,CAAC;MACf,SAAS,CAAC,MAAM,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;MACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/ifStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"ifStatement.d.ts","sourceRoot":"","sources":["../../../src/ast/statements/ifStatement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,GAAG,IAAI,KAAG,IAAI,IAAI,WAChC,CAAC;AAE/B,QAAA,MAAM,WAAW,EAAE,cAAc,CAAC,WAAW,CAoB5C,CAAC;AAEF,OAAO,EAAC,WAAW,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/ifStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"ifStatement.js","sourceRoot":"","sources":["../../../src/ast/statements/ifStatement.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAqB,EAAuB,EAAE,CAC1E,IAAI,EAAE,IAAI,KAAK,aAAa,CAAC;AAE/B,MAAM,WAAW,GAAgC,CAC/C,EAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAC,EAC7B,EAAC,SAAS,EAAC,EACX,EAAE;IACF,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,aAAa,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,kBAAkB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IAEhD,MAAM,sBAAsB,GAAG,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC;IAE7E,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,kBAAkB,EAAE,CAAC;QACvB,gBAAgB,GAAG,sBAAsB;YACvC,CAAC,CAAC,OAAO,kBAAkB,EAAE;YAC7B,CAAC,CAAC,QAAQ,kBAAkB,MAAM,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,cAAc;MACvB,aAAa;IACf,gBAAgB,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,OAAO,EAAC,WAAW,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequiredPolyfills.d.ts","sourceRoot":"","sources":["../../src/polyfills/getRequiredPolyfills.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getRequiredPolyfills.d.ts","sourceRoot":"","sources":["../../src/polyfills/getRequiredPolyfills.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,0BAkBnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequiredPolyfills.js","sourceRoot":"","sources":["../../src/polyfills/getRequiredPolyfills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,8BAA8B,MAAM,mCAAmC,CAAC;AACpF,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,qEAAqE;IACrE,qCAAqC;IACrC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,8BAGvB,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"getRequiredPolyfills.js","sourceRoot":"","sources":["../../src/polyfills/getRequiredPolyfills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,8BAA8B,MAAM,mCAAmC,CAAC;AACpF,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,qEAAqE;IACrE,qCAAqC;IACrC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,8BAGvB,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,CACzC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAChB,0CAA0C;QAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,UAAU,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAChB,CAAC,EACD,EAA4B,CAC7B,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspicl/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A javascript to PICO-8 LUA converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -69,6 +69,5 @@
|
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=22"
|
|
72
|
-
}
|
|
73
|
-
"stableVersion": "4.0.0-alpha.4"
|
|
72
|
+
}
|
|
74
73
|
}
|