@oidoid/void 0.1.0-6 → 0.1.0-7
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/dist/meta.json +1 -1
- package/dist/package.json +5 -5
- package/dist/public/favicon/favicon16.png +0 -0
- package/dist/public/favicon/favicon16.webp +0 -0
- package/dist/public/favicon/favicon192.png +0 -0
- package/dist/public/favicon/favicon192.webp +0 -0
- package/dist/public/favicon/favicon32.png +0 -0
- package/dist/public/favicon/favicon32.webp +0 -0
- package/dist/public/favicon/favicon48.png +0 -0
- package/dist/public/favicon/favicon48.webp +0 -0
- package/dist/public/favicon/favicon64.png +0 -0
- package/dist/public/favicon/favicon64.webp +0 -0
- package/dist/public/index.js +12 -3758
- package/dist/public/index.js.map +4 -4
- package/dist/public/preload-atlas.png +0 -0
- package/dist/public/preload-atlas.webp +0 -0
- package/dist/public/void-v0.1.0-6+20251020.7cdf98d.html +111 -0
- package/dist/public/void-v0.1.0-6+20251020.e4e9eef.html +111 -0
- package/dist/public/void-v0.1.0-7+20251021.7cdf98d.html +111 -0
- package/dist/schema/config-file.v0.json +1 -1
- package/dist/src/demo/assets/manifest.json +10 -15
- package/dist/src/demo/ents/clock-ent.d.ts +2 -1
- package/dist/src/demo/ents/clock-ent.js.map +1 -1
- package/dist/src/demo/ents/render-toggle-ent.d.ts +3 -1
- package/dist/src/demo/ents/render-toggle-ent.js +3 -0
- package/dist/src/demo/ents/render-toggle-ent.js.map +1 -1
- package/dist/src/demo/ents/work-counter-ent.d.ts +2 -2
- package/dist/src/demo/ents/work-counter-ent.js +1 -5
- package/dist/src/demo/ents/work-counter-ent.js.map +1 -1
- package/dist/src/demo/game.d.ts +1 -2
- package/dist/src/demo/game.js +14 -34
- package/dist/src/demo/game.js.map +1 -1
- package/dist/src/demo/void.json +1 -1
- package/dist/src/ents/button-ent.d.ts +2 -1
- package/dist/src/ents/button-ent.js +7 -3
- package/dist/src/ents/button-ent.js.map +1 -1
- package/dist/src/ents/cursor-ent.d.ts +2 -2
- package/dist/src/ents/cursor-ent.js +7 -2
- package/dist/src/ents/cursor-ent.js.map +1 -1
- package/dist/src/ents/ent.d.ts +3 -3
- package/dist/src/ents/follow-cam-ent.d.ts +1 -1
- package/dist/src/ents/nine-patch-ent.d.ts +1 -1
- package/dist/src/ents/text-ent.d.ts +1 -1
- package/dist/src/ents/zoo.d.ts +4 -3
- package/dist/src/ents/zoo.js +11 -4
- package/dist/src/ents/zoo.js.map +1 -1
- package/dist/src/graphics/cam.js +10 -1
- package/dist/src/graphics/cam.js.map +1 -1
- package/dist/src/graphics/renderer.d.ts +18 -4
- package/dist/src/graphics/renderer.js +20 -8
- package/dist/src/graphics/renderer.js.map +1 -1
- package/dist/src/graphics/sprite.d.ts +1 -1
- package/dist/src/graphics/sprite.js +4 -4
- package/dist/src/graphics/sprite.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/looper.d.ts +5 -3
- package/dist/src/looper.js +7 -4
- package/dist/src/looper.js.map +1 -1
- package/dist/src/types/void-version.d.ts +0 -2
- package/dist/src/types/void-version.js.map +1 -1
- package/dist/src/utils/canvas-util.js +2 -2
- package/dist/src/utils/canvas-util.js.map +1 -1
- package/dist/src/utils/debug.d.ts +4 -2
- package/dist/src/utils/debug.js +4 -3
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/delay-interval.d.ts +7 -0
- package/dist/src/utils/delay-interval.js +29 -0
- package/dist/src/utils/delay-interval.js.map +1 -0
- package/dist/src/utils/dom-util.d.ts +2 -2
- package/dist/src/utils/dom-util.js +15 -15
- package/dist/src/utils/dom-util.js.map +1 -1
- package/dist/src/void.d.ts +8 -3
- package/dist/src/void.js +22 -15
- package/dist/src/void.js.map +1 -1
- package/dist/tools/atlas-pack/atlas-pack.d.ts +1 -1
- package/dist/tools/atlas-pack/atlas-pack.js +10 -5
- package/dist/tools/atlas-pack/atlas-pack.js.map +1 -1
- package/dist/tools/bundle/bundle.js +4 -4
- package/dist/tools/bundle/bundle.js.map +1 -1
- package/dist/tools/bundle/html-plugin.js +6 -4
- package/dist/tools/bundle/html-plugin.js.map +1 -1
- package/dist/tools/tsconfig-base.json +4 -1
- package/dist/tools/tsconfig.json +1 -3
- package/dist/tools/types/config.d.ts +8 -1
- package/dist/tools/types/config.js +17 -8
- package/dist/tools/types/config.js.map +1 -1
- package/dist/tools/types/package-json.d.ts +4 -0
- package/dist/tools/types/package-json.js +2 -0
- package/dist/tools/types/package-json.js.map +1 -0
- package/dist/tools/void.d.ts +1 -3
- package/dist/tools/void.js +8 -7
- package/dist/tools/void.js.map +1 -1
- package/package.json +5 -5
- package/schema/config-file.test.ts +2 -2
- package/schema/config-file.v0.json +1 -1
- package/tools/atlas-pack/atlas-pack.ts +20 -7
- package/tools/bundle/bundle.ts +3 -4
- package/tools/bundle/html-plugin.ts +10 -10
- package/tools/types/config.ts +29 -7
- package/tools/types/package-json.ts +4 -0
- package/tools/void.ts +11 -10
- package/dist/public/favicon/favicon512.png +0 -0
- package/dist/public/index.html +0 -23
- package/dist/public/manifest.json +0 -1
- package/dist/public/void-v0.1.0-4.html +0 -111
- package/dist/public/void-v0.1.0-5.html +0 -111
- package/dist/public/void-v0.1.0-6.html +0 -111
- package/dist/src/pixel-ratio-observer.d.ts +0 -10
- package/dist/src/pixel-ratio-observer.js +0 -26
- package/dist/src/pixel-ratio-observer.js.map +0 -1
package/dist/tools/void.js
CHANGED
|
@@ -2,29 +2,30 @@
|
|
|
2
2
|
// void.ts --config=<void.json> [--minify] [--one-file] [--watch]
|
|
3
3
|
// compiles images into an atlas and bundles an HTML entrypoint.
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import
|
|
5
|
+
import voidPackageJSON from '../package.json' with { type: 'json' };
|
|
6
6
|
import { parseConfigFile } from "../schema/config-file.js";
|
|
7
7
|
import { bundle } from "./bundle/bundle.js";
|
|
8
8
|
import { Config } from "./types/config.js";
|
|
9
9
|
import { Argv } from "./utils/argv.js";
|
|
10
10
|
import { exec } from "./utils/exec.js";
|
|
11
11
|
import { parseHTML } from "./utils/html-parser.js";
|
|
12
|
-
export async function build(args
|
|
12
|
+
export async function build(args) {
|
|
13
13
|
const argv = Argv(args);
|
|
14
14
|
const configFile = await parseConfigFile(argv.opts['--config'] ?? 'void.json');
|
|
15
|
-
const
|
|
15
|
+
const hash = (await exec('git', 'rev-parse', '--short', 'HEAD')).trim();
|
|
16
|
+
const packageJSON = JSON.parse((await exec('npm', 'pkg', 'get', 'version', 'published')) || '{}');
|
|
17
|
+
const config = Config(configFile, argv, packageJSON, hash);
|
|
16
18
|
const doc = await parseHTML(config.entry);
|
|
17
19
|
const srcFilenames = [
|
|
18
20
|
...doc.querySelectorAll("script[type='module'][src$='.ts']")
|
|
19
21
|
].map(el => path.resolve(path.dirname(config.entry), el.getAttribute('src')));
|
|
20
22
|
const voidVersion = {
|
|
21
|
-
|
|
22
|
-
published: packageJSON.published,
|
|
23
|
+
published: voidPackageJSON.published,
|
|
23
24
|
// imported JSON doesn't treeshake. define as a constant.
|
|
24
|
-
version:
|
|
25
|
+
version: voidPackageJSON.version
|
|
25
26
|
};
|
|
26
27
|
await bundle(config, srcFilenames, voidVersion);
|
|
27
28
|
}
|
|
28
29
|
if (import.meta.main)
|
|
29
|
-
await build(process.argv
|
|
30
|
+
await build(process.argv);
|
|
30
31
|
//# sourceMappingURL=void.js.map
|
package/dist/tools/void.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"void.js","sourceRoot":"","sources":["../../tools/void.ts"],"names":[],"mappings":";AACA,iEAAiE;AACjE,gEAAgE;AAEhE,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"void.js","sourceRoot":"","sources":["../../tools/void.ts"],"names":[],"mappings":";AACA,iEAAiE;AACjE,gEAAgE;AAEhE,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AACjE,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AAExC,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAgBhD,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAuB;IACjD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,WAAW,CAAC,CAAA;IAC9E,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACvE,MAAM,WAAW,GAAgB,IAAI,CAAC,KAAK,CACzC,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,IAAI,IAAI,CAClE,CAAA;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;IAE1D,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG;QACnB,GAAG,GAAG,CAAC,gBAAgB,CACrB,mCAAmC,CACpC;KACF,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAE,CAAC,CAAC,CAAA;IAE9E,MAAM,WAAW,GAAgB;QAC/B,SAAS,EAAE,eAAe,CAAC,SAAS;QACpC,yDAAyD;QACzD,OAAO,EAAE,eAAe,CAAC,OAAO;KACjC,CAAA;IAED,MAAM,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;AACjD,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI;IAAE,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"esbuild": "0.25.11",
|
|
10
10
|
"html-minifier-next": "3.0.0",
|
|
11
11
|
"jsdom": "27.0.1",
|
|
12
|
-
"mem-font": "11.0.0-
|
|
12
|
+
"mem-font": "11.0.0-7"
|
|
13
13
|
},
|
|
14
14
|
"description": "basic 2D game library.",
|
|
15
15
|
"devDependencies": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=24.0"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
|
-
".": "./dist/index.js"
|
|
25
|
+
".": "./dist/src/index.js"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"published": "
|
|
44
|
+
"published": "20251021",
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|
|
47
47
|
"url": "git+https://github.com/oidoid/void.git"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc --build && npm run build:favicon && npm run build:demo -- --minify --one-file",
|
|
51
|
-
"build:favicon": "for s in 1 2 3 4 12
|
|
51
|
+
"build:favicon": "for s in 1 2 3 4 12; do f=dist/public/favicon/favicon$(($s * 16)); aseprite src/demo/assets/favicon.aseprite --batch --color-mode=indexed --scale=$s --save-as=$f.png && cwebp -exact -lossless -mt -quiet -z 9 $f.png -o $f.webp; done",
|
|
52
52
|
"build:demo": "tools/void.ts --config=src/demo/void.json",
|
|
53
53
|
"clean": "rm -rf dist",
|
|
54
54
|
"format": "npm run formatter -- --fix",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"version": "npm pkg set published=$(date +%Y%m%d) && npm test"
|
|
63
63
|
},
|
|
64
64
|
"type": "module",
|
|
65
|
-
"version": "0.1.0-
|
|
65
|
+
"version": "0.1.0-7"
|
|
66
66
|
}
|
|
@@ -26,7 +26,7 @@ test('overrides', () => {
|
|
|
26
26
|
entry: 'entry',
|
|
27
27
|
meta: 'meta',
|
|
28
28
|
out: {dir: 'outDir', name: 'name'},
|
|
29
|
-
preloadAtlas: {dir: 'dir/', image: 'image.
|
|
29
|
+
preloadAtlas: {dir: 'dir/', image: 'image.webp', json: 'json.json'}
|
|
30
30
|
}
|
|
31
31
|
assert.deepEqual<ConfigFile>(
|
|
32
32
|
parse('dirname/filename', JSON.stringify(config)),
|
|
@@ -37,7 +37,7 @@ test('overrides', () => {
|
|
|
37
37
|
out: {dir: 'dirname/outDir', name: 'name'},
|
|
38
38
|
preloadAtlas: {
|
|
39
39
|
dir: 'dirname/dir/',
|
|
40
|
-
image: 'dirname/image.
|
|
40
|
+
image: 'dirname/image.webp',
|
|
41
41
|
json: 'dirname/json.json'
|
|
42
42
|
},
|
|
43
43
|
|
|
@@ -6,13 +6,12 @@ import {globAll} from '../utils/file-util.ts'
|
|
|
6
6
|
import {parseAtlasJSON} from './atlas-json-parser.ts'
|
|
7
7
|
|
|
8
8
|
// to-do: separate executable?
|
|
9
|
-
export async function packAtlas(
|
|
10
|
-
config: Readonly<AtlasConfig>,
|
|
11
|
-
minify: boolean
|
|
12
|
-
): Promise<void> {
|
|
9
|
+
export async function packAtlas(config: Readonly<AtlasConfig>): Promise<void> {
|
|
13
10
|
const filenames = await globAll(path.join(config.dir, '**.aseprite'))
|
|
14
11
|
if (!filenames.length) return
|
|
15
12
|
|
|
13
|
+
const webp = config.image.endsWith('.webp')
|
|
14
|
+
const sheet = webp ? config.image.replace('.webp', '.png') : config.image
|
|
16
15
|
const json = await exec(
|
|
17
16
|
'aseprite',
|
|
18
17
|
'--batch',
|
|
@@ -21,18 +20,32 @@ export async function packAtlas(
|
|
|
21
20
|
'--list-slices',
|
|
22
21
|
'--list-tags',
|
|
23
22
|
'--merge-duplicates',
|
|
24
|
-
`--sheet=${
|
|
23
|
+
`--sheet=${sheet}`,
|
|
25
24
|
'--sheet-pack',
|
|
26
25
|
'--tagname-format={title}--{tag}',
|
|
27
26
|
...filenames
|
|
28
27
|
)
|
|
29
28
|
|
|
30
|
-
if (
|
|
29
|
+
if (webp)
|
|
30
|
+
await exec(
|
|
31
|
+
'cwebp',
|
|
32
|
+
'-exact',
|
|
33
|
+
'-lossless',
|
|
34
|
+
'-mt',
|
|
35
|
+
'-quiet',
|
|
36
|
+
'-z',
|
|
37
|
+
'9',
|
|
38
|
+
sheet,
|
|
39
|
+
'-o',
|
|
40
|
+
config.image
|
|
41
|
+
)
|
|
31
42
|
|
|
32
43
|
await fs.writeFile(
|
|
33
44
|
config.json,
|
|
34
45
|
JSON.stringify(parseAtlasJSON(JSON.parse(json)))
|
|
35
46
|
)
|
|
36
47
|
|
|
37
|
-
|
|
48
|
+
try {
|
|
49
|
+
await exec('biome', 'check', '--fix', config.json)
|
|
50
|
+
} catch {}
|
|
38
51
|
}
|
package/tools/bundle/bundle.ts
CHANGED
|
@@ -34,10 +34,10 @@ export async function bundle(
|
|
|
34
34
|
target: 'es2024' // https://esbuild.github.io/content-types/#tsconfig-json
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
if (config.preloadAtlas) await packAtlas(config.preloadAtlas
|
|
37
|
+
if (config.preloadAtlas) await packAtlas(config.preloadAtlas)
|
|
38
38
|
if (config.preloadAtlas && config.watch) {
|
|
39
39
|
fs.watch(config.preloadAtlas.dir, {recursive: true}, (ev, type) =>
|
|
40
|
-
onWatch(config.preloadAtlas!,
|
|
40
|
+
onWatch(config.preloadAtlas!, ev, type)
|
|
41
41
|
)
|
|
42
42
|
const ctx = await esbuild.context(opts)
|
|
43
43
|
await Promise.all([
|
|
@@ -54,12 +54,11 @@ export async function bundle(
|
|
|
54
54
|
const onWatch = V.debounce(
|
|
55
55
|
async (
|
|
56
56
|
config: Readonly<AtlasConfig>,
|
|
57
|
-
minify: boolean,
|
|
58
57
|
ev: fs.WatchEventType,
|
|
59
58
|
file: string | null
|
|
60
59
|
) => {
|
|
61
60
|
console.log(`asset ${file} ${ev}.`)
|
|
62
|
-
await packAtlas(config
|
|
61
|
+
await packAtlas(config)
|
|
63
62
|
},
|
|
64
63
|
500 as V.Millis
|
|
65
64
|
)
|
|
@@ -66,8 +66,7 @@ export function HTMLPlugin(config: Readonly<Config>): esbuild.Plugin {
|
|
|
66
66
|
const manifest: Manifest = JSON.parse(
|
|
67
67
|
await fs.readFile(manifestFilename, 'utf8')
|
|
68
68
|
)
|
|
69
|
-
if (
|
|
70
|
-
manifest.version = process.env.npm_package_version
|
|
69
|
+
if (config.version) manifest.version = config.version
|
|
71
70
|
|
|
72
71
|
for (const icon of manifest.icons ?? []) {
|
|
73
72
|
if (!icon.src || !icon.type) continue
|
|
@@ -116,15 +115,16 @@ export function HTMLPlugin(config: Readonly<Config>): esbuild.Plugin {
|
|
|
116
115
|
removeComments: true,
|
|
117
116
|
removeEmptyAttributes: true
|
|
118
117
|
})
|
|
119
|
-
// to-do: what biome config does this use outside of the repo?
|
|
120
118
|
else
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
try {
|
|
120
|
+
html = await exec(
|
|
121
|
+
'biome',
|
|
122
|
+
'check',
|
|
123
|
+
'--fix',
|
|
124
|
+
`--stdin-file-path=${config.entry}`,
|
|
125
|
+
{stdin: html}
|
|
126
|
+
)
|
|
127
|
+
} catch {}
|
|
128
128
|
|
|
129
129
|
// to-do: test.
|
|
130
130
|
const outHTMLFilename = path.join(config.out.dir, config.out.filename)
|
package/tools/types/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import type {AtlasConfig, ConfigFile} from '../../schema/config-file.ts'
|
|
3
3
|
import type {Argv} from '../utils/argv.ts'
|
|
4
|
+
import type {PackageJSON} from './package-json.ts'
|
|
4
5
|
|
|
5
6
|
export type Config = {
|
|
6
7
|
$schema: string
|
|
@@ -17,27 +18,48 @@ export type Config = {
|
|
|
17
18
|
minify: boolean
|
|
18
19
|
oneFile: boolean
|
|
19
20
|
watch: boolean
|
|
21
|
+
|
|
22
|
+
/** package publish date. */
|
|
23
|
+
published: string | undefined
|
|
24
|
+
/** package version. */
|
|
25
|
+
version: string | undefined
|
|
26
|
+
|
|
27
|
+
/** Git short hash. */
|
|
28
|
+
hash: string
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
export function Config(
|
|
23
32
|
configFile: Readonly<ConfigFile>,
|
|
24
33
|
argv: Readonly<Argv>,
|
|
25
|
-
|
|
34
|
+
packageJSON: Readonly<PackageJSON>,
|
|
35
|
+
hash: string
|
|
26
36
|
): Config {
|
|
27
|
-
let
|
|
28
|
-
if (configFile.out.name && !argv.opts['--watch'])
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
let fileStem = path.basename(configFile.entry).replace(/\.[^.]+$/, '')
|
|
38
|
+
if (configFile.out.name && !argv.opts['--watch'])
|
|
39
|
+
fileStem = configFile.out.name
|
|
40
|
+
let fileSuffix = '.html'
|
|
41
|
+
if (!argv.opts['--watch']) {
|
|
42
|
+
const version = packageJSON.version ? `v${packageJSON.version}` : ''
|
|
43
|
+
const published =
|
|
44
|
+
packageJSON.version && packageJSON.published
|
|
45
|
+
? `+${packageJSON.published}`
|
|
46
|
+
: ''
|
|
47
|
+
const hashStr = packageJSON.version && hash ? `.${hash}` : ''
|
|
48
|
+
fileSuffix = `-${version}${published}${hashStr}.html`
|
|
49
|
+
}
|
|
31
50
|
return {
|
|
32
51
|
$schema: configFile.$schema,
|
|
33
52
|
entry: configFile.entry,
|
|
34
53
|
meta: configFile.meta,
|
|
35
|
-
out: {dir: configFile.out.dir, filename: `${
|
|
54
|
+
out: {dir: configFile.out.dir, filename: `${fileStem}${fileSuffix}`},
|
|
36
55
|
preloadAtlas: configFile.preloadAtlas,
|
|
37
56
|
dirname: configFile.dirname,
|
|
38
57
|
filename: configFile.filename,
|
|
39
58
|
minify: argv.opts['--minify'] ?? false,
|
|
40
59
|
oneFile: argv.opts['--one-file'] ?? false,
|
|
41
|
-
watch: argv.opts['--watch'] ?? false
|
|
60
|
+
watch: argv.opts['--watch'] ?? false,
|
|
61
|
+
published: packageJSON.published,
|
|
62
|
+
version: packageJSON.version,
|
|
63
|
+
hash
|
|
42
64
|
}
|
|
43
65
|
}
|
package/tools/void.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
// compiles images into an atlas and bundles an HTML entrypoint.
|
|
4
4
|
|
|
5
5
|
import path from 'node:path'
|
|
6
|
-
import
|
|
6
|
+
import voidPackageJSON from '../package.json' with {type: 'json'}
|
|
7
7
|
import {parseConfigFile} from '../schema/config-file.ts'
|
|
8
8
|
import type {VoidVersion} from '../src/types/void-version.ts'
|
|
9
9
|
import {bundle} from './bundle/bundle.ts'
|
|
10
10
|
import {Config} from './types/config.ts'
|
|
11
|
+
import type {PackageJSON} from './types/package-json.ts'
|
|
11
12
|
import {Argv} from './utils/argv.ts'
|
|
12
13
|
import {exec} from './utils/exec.ts'
|
|
13
14
|
import {parseHTML} from './utils/html-parser.ts'
|
|
@@ -26,13 +27,14 @@ declare module './utils/argv.ts' {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export async function build(
|
|
30
|
-
args: readonly string[],
|
|
31
|
-
env: {readonly [name: string]: string | undefined}
|
|
32
|
-
): Promise<void> {
|
|
30
|
+
export async function build(args: readonly string[]): Promise<void> {
|
|
33
31
|
const argv = Argv(args)
|
|
34
32
|
const configFile = await parseConfigFile(argv.opts['--config'] ?? 'void.json')
|
|
35
|
-
const
|
|
33
|
+
const hash = (await exec('git', 'rev-parse', '--short', 'HEAD')).trim()
|
|
34
|
+
const packageJSON: PackageJSON = JSON.parse(
|
|
35
|
+
(await exec('npm', 'pkg', 'get', 'version', 'published')) || '{}'
|
|
36
|
+
)
|
|
37
|
+
const config = Config(configFile, argv, packageJSON, hash)
|
|
36
38
|
|
|
37
39
|
const doc = await parseHTML(config.entry)
|
|
38
40
|
const srcFilenames = [
|
|
@@ -42,13 +44,12 @@ export async function build(
|
|
|
42
44
|
].map(el => path.resolve(path.dirname(config.entry), el.getAttribute('src')!))
|
|
43
45
|
|
|
44
46
|
const voidVersion: VoidVersion = {
|
|
45
|
-
|
|
46
|
-
published: packageJSON.published,
|
|
47
|
+
published: voidPackageJSON.published,
|
|
47
48
|
// imported JSON doesn't treeshake. define as a constant.
|
|
48
|
-
version:
|
|
49
|
+
version: voidPackageJSON.version
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
await bundle(config, srcFilenames, voidVersion)
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
if (import.meta.main) await build(process.argv
|
|
55
|
+
if (import.meta.main) await build(process.argv)
|
|
Binary file
|
package/dist/public/index.html
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>void</title>
|
|
6
|
-
<link
|
|
7
|
-
href="favicon/favicon16.png"
|
|
8
|
-
rel="icon"
|
|
9
|
-
sizes="16x16"
|
|
10
|
-
type="image/png"
|
|
11
|
-
>
|
|
12
|
-
<link rel="manifest" href="manifest.json">
|
|
13
|
-
</head>
|
|
14
|
-
<body style="background-color: #ffffb1">
|
|
15
|
-
<img
|
|
16
|
-
alt=""
|
|
17
|
-
id="preload-atlas"
|
|
18
|
-
style="display: none"
|
|
19
|
-
src="preload-atlas.png"
|
|
20
|
-
>
|
|
21
|
-
<script src="index.js" type="module" async=""></script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"author":"oidoid","background_color":"#ffffb1","description":"void 2D game library demo.","display":"standalone","homepage_url":"https://oidoid.com/","icons":[{"src":"favicon/favicon16.png","sizes":"16x16","type":"image/png"},{"src":"favicon/favicon32.png","sizes":"32x32","type":"image/png"},{"src":"favicon/favicon48.png","sizes":"48x48","type":"image/png"},{"src":"favicon/favicon64.png","sizes":"64x64","type":"image/png"},{"src":"favicon/favicon192.png","sizes":"192x192","type":"image/png"},{"src":"favicon/favicon512.png","sizes":"512x512","type":"image/png"}],"manifest_version":3,"name":"void","orientation":"any","short_name":"void","start_url":"http://localhost:1234","theme_color":"#ffffb1","version":"0.1.0-4"}
|