Skip to content

Commit 62acffd

Browse files
authored
Merge pull request #196 from litecanvas/next
v0.92
2 parents 5d41454 + 306b7bd commit 62acffd

File tree

10 files changed

+668
-649
lines changed

10 files changed

+668
-649
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,16 @@ Litecanvas is a lightweight HTML5 canvas 2D engine suitable for small web games,
2828

2929
## Getting Started
3030

31-
You can try our [online playground](https://litecanvas.github.io) or just installing the [basic template](https://github.com/litecanvas/template):
31+
You can try our [online playground](https://litecanvas.github.io) or install the [basic template](https://github.com/litecanvas/template):
3232

3333
```sh
34-
# requires Node.js
34+
# requires Node.js & NPM
3535
npx tiged litecanvas/template my-game
3636
cd my-game
3737
npm install
3838
npm run dev
3939
```
4040

41-
If you prefer, you can manually install via [NPM](https://www.npmjs.com/package/litecanvas):
42-
43-
```
44-
npm install litecanvas
45-
```
46-
4741
### Show me the code!
4842

4943
```js

bun.lock

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "litecanvas",
3-
"version": "0.91.0",
3+
"version": "0.92.0",
44
"description": "Lightweight HTML5 canvas 2D game engine suitable for small projects and creative coding. Inspired by PICO-8 and P5/Processing.",
55
"license": "MIT",
66
"author": "Luiz Bills <luizbills@pm.me>",
@@ -14,8 +14,25 @@
1414
"url": "https://github.com/litecanvas/game-engine/issues"
1515
},
1616
"type": "module",
17-
"main": "src/index.js",
18-
"types": "types/index.d.ts",
17+
"main": "./src/index.js",
18+
"module": "./src/index.js",
19+
"types": "./types/index.d.ts",
20+
"exports": {
21+
".": {
22+
"import": {
23+
"types": "./types/index.d.ts",
24+
"default": "./src/index.js"
25+
}
26+
},
27+
"./global": "./src/index.js"
28+
},
29+
"typesVersions": {
30+
"*": {
31+
"./global": [
32+
"./types/global.d.ts"
33+
]
34+
}
35+
},
1936
"keywords": [
2037
"canvas",
2138
"2d",
@@ -33,7 +50,7 @@
3350
"@size-limit/preset-small-lib": "^11.2.0",
3451
"@swc/core": "^1.12.11",
3552
"@types/jsdom": "^21.1.7",
36-
"ava": "^6.4.0",
53+
"ava": "^6.4.1",
3754
"esbuild": "^0.25.6",
3855
"genversion": "^3.2.0",
3956
"gzip-size": "^7.0.0",

src/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default function litecanvas(settings = {}) {
8787
*/
8888
_eventListeners = {}
8989

90-
/** @type {Omit<LitecanvasInstance,'PI'|'sin'|'cos'|'atan2'|'hypot'|'tan'|'abs'|'ceil'|'floor'|'trunc'|'min'|'max'|'pow'|'sqrt'|'sign'|'exp'|'iskeydown'|'iskeypressed'>} */
90+
/** @type {LitecanvasInstance} */
9191
const instance = {
9292
/** @type {number} */
9393
W: 0,
@@ -945,7 +945,6 @@ export default function litecanvas(settings = {}) {
945945
DEV: assert(isNumber(volumeFactor), '[litecanvas] sfx() 3rd param must be a number')
946946

947947
if (
948-
// @ts-ignore
949948
root.zzfxV <= 0 ||
950949
(navigator.userActivation && !navigator.userActivation.hasBeenActive)
951950
) {
@@ -975,7 +974,6 @@ export default function litecanvas(settings = {}) {
975974
volume(value) {
976975
DEV: assert(isNumber(value), '[litecanvas] volume() 1st param must be a number')
977976

978-
// @ts-ignore
979977
root.zzfxV = value
980978
},
981979

@@ -1082,7 +1080,9 @@ export default function litecanvas(settings = {}) {
10821080
def(key, value) {
10831081
DEV: assert('string' === typeof key, '[litecanvas] def() 1st param must be a string')
10841082
DEV: if (null == value) {
1085-
console.warn(`def: key "${key}" was defined as ${value} but now is null`)
1083+
console.warn(
1084+
`[litecanvas] def() changed the key "${key}" to null (previous value was ${instance[key]})`
1085+
)
10861086
}
10871087

10881088
instance[key] = value
@@ -1148,8 +1148,7 @@ export default function litecanvas(settings = {}) {
11481148
// 7
11491149
_timeScale,
11501150
// 8
1151-
// @ts-ignore
1152-
root.zzfxV || 1,
1151+
root.zzfxV,
11531152
// 9
11541153
_rngSeed,
11551154
// 10
@@ -1189,7 +1188,6 @@ export default function litecanvas(settings = {}) {
11891188
for (const key in instance) {
11901189
delete root[key]
11911190
}
1192-
// @ts-ignore
11931191
delete root.ENGINE
11941192
}
11951193

@@ -1568,7 +1566,7 @@ export default function litecanvas(settings = {}) {
15681566

15691567
on(_canvas, 'click', () => root.focus())
15701568

1571-
// @ts-ignore
1569+
/** @ts-ignore */
15721570
_canvas.style = ''
15731571

15741572
resizeCanvas()
@@ -1657,7 +1655,6 @@ export default function litecanvas(settings = {}) {
16571655
* @param {*} config
16581656
*/
16591657
function loadPlugin(callback, config) {
1660-
// @ts-ignore
16611658
const pluginData = callback(instance, config)
16621659

16631660
DEV: assert(
@@ -1671,12 +1668,10 @@ export default function litecanvas(settings = {}) {
16711668
}
16721669

16731670
if (settings.global) {
1674-
// @ts-ignore
16751671
if (root.ENGINE) {
16761672
throw new Error('only one global litecanvas is allowed')
16771673
}
16781674
Object.assign(root, instance)
1679-
// @ts-ignore
16801675
root.ENGINE = instance
16811676
}
16821677

@@ -1691,6 +1686,5 @@ export default function litecanvas(settings = {}) {
16911686
raf(init)
16921687
}
16931688

1694-
// @ts-ignore
16951689
return instance
16961690
}

src/version.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
import litecanvas from './index.js'
22

3-
/**
4-
* @global
5-
*/
63
globalThis.litecanvas = litecanvas

tsconfig.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"compilerOptions": {
3-
"target": "es2016",
4-
"lib": ["es2016", "dom", "dom.iterable"],
3+
"target": "es2017",
4+
"lib": ["ES2017", "DOM", "DOM.Iterable"],
55
"allowJs": true,
6-
"noEmit": true
7-
},
8-
"files": ["types/index.d.ts", "src/index.js"]
6+
"noEmit": true,
7+
"baseUrl": "src",
8+
"paths": {
9+
"*": ["types/*"]
10+
},
11+
"moduleResolution": "nodenext",
12+
"module": "nodenext"
13+
}
914
}

0 commit comments

Comments
 (0)