Skip to content

Commit dd5a20d

Browse files
authored
Merge pull request #271 from litecanvas/patch
Patch
2 parents 5a1411c + 59b1387 commit dd5a20d

File tree

9 files changed

+234
-244
lines changed

9 files changed

+234
-244
lines changed

bun.lock

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "litecanvas",
3-
"version": "0.103.4",
3+
"version": "0.103.5",
44
"description": "Lightweight HTML5 canvas 2D game engine suitable for small projects and creative coding. Inspired by PICO-8 and p5.js/Processing.",
55
"license": "MIT",
66
"author": "Luiz Bills <luizbills@pm.me>",
@@ -33,15 +33,15 @@
3333
],
3434
"devDependencies": {
3535
"@happy-dom/global-registrator": "^20.8.3",
36-
"@size-limit/preset-small-lib": "^12.0.0",
36+
"@size-limit/preset-small-lib": "^12.0.1",
3737
"@swc/core": "^1.15.18",
3838
"ava": "^7.0.0",
3939
"esbuild": "^0.27.3",
4040
"genversion": "^3.2.0",
4141
"gzip-size": "^7.0.0",
4242
"prettier": "^3.8.1",
4343
"sinon": "^21.0.2",
44-
"size-limit": "^12.0.0",
44+
"size-limit": "^12.0.1",
4545
"tap-min": "^3.0.0"
4646
},
4747
"trustedDependencies": [

samples/palette-dither-test/palette-dither-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ litecanvas({
1212
})
1313

1414
function init() {
15-
framerate(1)
1615
combinations = []
1716
for (let y = 0; y < cols; y++) {
1817
for (let x = 0; x < cols; x++) {
@@ -35,6 +34,8 @@ function draw() {
3534
}
3635
}
3736
}
37+
38+
pause()
3839
}
3940

4041
function tapped() {

samples/plugin-basics/plugin-basics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function pluginTest(engine, config) {
3434
// the event callback
3535
function () {
3636
engine.cls(1)
37-
engine.rectfill(0, 0, 100, 100, 4)
37+
engine.rectfill(0, 0, 100, 100, 3)
3838
}
3939
)
4040

samples/snake/snake.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function draw() {
105105
textfont('monospace')
106106
textalign('center', 'middle')
107107
textsize(28)
108-
text(W / 2, H / 2, 'GAME OVER', 4, 'bold')
108+
text(W / 2, H / 2, 'GAME OVER', 3, 'bold')
109109
}
110110
}
111111

script/build.js

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,75 @@
1-
import fs from 'node:fs'
1+
import fs from 'node:fs/promises'
22
import esbuild from 'esbuild'
33
import { minify } from '@swc/core'
44
import { gzipSizeSync } from 'gzip-size'
5+
import * as prettier from 'prettier'
56

6-
fs.rmSync('dist', { recursive: true, force: true })
7+
await fs.rm('dist', { recursive: true, force: true })
78

89
// build the dist.dev.js (for development)
9-
await esbuild.build({
10-
entryPoints: ['src/web.js'],
11-
outfile: 'dist/dist.dev.js',
12-
bundle: true,
13-
legalComments: 'eof',
14-
drop: ['debugger'],
15-
})
16-
console.log(` 📄 dist/dist.dev.js (${filesize('dist/dist.dev.js')})`)
10+
{
11+
const filepath = 'dist/dist.dev.js'
12+
await esbuild.build({
13+
entryPoints: ['src/web.js'],
14+
outfile: filepath,
15+
bundle: true,
16+
legalComments: 'eof',
17+
minifyWhitespace: true,
18+
drop: ['debugger'],
19+
})
20+
const formatted = await prettier.format(await fs.readFile(filepath, 'utf8'), {
21+
parser: 'babel',
22+
tabWidth: 2,
23+
semi: false,
24+
})
25+
await fs.writeFile(filepath, formatted)
26+
27+
console.log(` 📄 ${filepath} (${await filesize(filepath)})`)
28+
}
1729

1830
// build the dist.js
19-
await esbuild.build({
20-
entryPoints: ['src/web.js'],
21-
outfile: 'dist/dist.js',
22-
bundle: true,
23-
legalComments: 'eof',
24-
drop: ['console'],
25-
dropLabels: ['DEV'],
26-
})
31+
{
32+
{
33+
const filepath = 'dist/dist.js'
34+
await esbuild.build({
35+
entryPoints: ['src/web.js'],
36+
outfile: filepath,
37+
bundle: true,
38+
legalComments: 'eof',
39+
minifyWhitespace: true,
40+
drop: ['debugger', 'console'],
41+
dropLabels: ['DEV'],
42+
})
43+
const formatted = await prettier.format(await fs.readFile(filepath, 'utf8'), {
44+
parser: 'babel',
45+
tabWidth: 2,
46+
semi: false,
47+
})
48+
await fs.writeFile(filepath, formatted)
2749

28-
console.log(` 📄 dist/dist.js (${filesize('dist/dist.js')})`)
50+
console.log(` 📄 ${filepath} (${await filesize(filepath)})`)
51+
}
52+
}
2953

3054
// build the dist.min.js
31-
const minified = await minify(fs.readFileSync('dist/dist.js', { encoding: 'utf-8' }), {
32-
format: {
33-
comments: false,
34-
},
35-
compress: {
36-
drop_console: true,
37-
},
38-
mangle: true,
39-
})
40-
fs.writeFileSync('dist/dist.min.js', minified.code)
41-
console.log(
42-
` 📄 dist/dist.min.js (${filesize('dist/dist.min.js')} ~= ${gzipsize(minified.code)} gzip)`
43-
)
44-
45-
function filesize(filename) {
46-
const stats = fs.statSync(filename)
55+
{
56+
const minified = await minify(await fs.readFile('dist/dist.js', { encoding: 'utf-8' }), {
57+
format: {
58+
comments: false,
59+
},
60+
compress: {
61+
drop_console: true,
62+
},
63+
mangle: true,
64+
})
65+
await fs.writeFile('dist/dist.min.js', minified.code)
66+
console.log(
67+
` 📄 dist/dist.min.js (${await filesize('dist/dist.min.js')} ~= ${gzipsize(minified.code)} gzip)`
68+
)
69+
}
70+
71+
async function filesize(filename) {
72+
const stats = await fs.stat(filename)
4773
return (stats.size / 1000).toFixed(2) + 'kb'
4874
}
4975

src/dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
* @param {string} message
44
*/
55
export const assert = (condition, message = 'Assertion failed') => {
6-
if (!condition) throw new Error(message)
6+
if (!condition) throw new Error('[litecanvas] ' + message)
77
}

0 commit comments

Comments
 (0)