Compare commits

...
17 changed files with 186 additions and 35 deletions

No files matched your search

+9
View File
@@ -1,5 +1,14 @@
# Arcade changelog
## 0.7.114
- Apfelwurm Editor uses its painted logo cover in the library.
- Tall library previews keep their titles visible in small, compressed cards.
## 0.7.113
- Choano 0.1.3 loads its artwork and sound from the paths the game requests.
## 0.7.112
- Every library cover shows its declared app title, including Apfelwurm Editor.
+5
View File
@@ -59,6 +59,11 @@ actions it
cannot perform. Inbe supplies its own account and package policy.
Arcade's launcher icon is MingCute's `game_2` gamepad (Apache-2.0).
An optional `artwork` mapping in `games.json` names a locked source-only
dependency for a game's library pictures. Its paths still come from that
game's declarations. This lets covers advance independently of playable
code; the thumbnail source hashes remain checked when the catalog builds.
## One Chess game
Chess remains an installable app in Inner Breeze, where it also fits thoughtful
+1 -1
View File
@@ -1 +1 @@
0.7.112
0.7.114
+4 -4
View File
@@ -13,8 +13,8 @@
"choano": {
"id": "xyz.waozi.choano",
"title": "Choano",
"version": "0.1.2",
"sequence": 1,
"version": "0.1.3",
"sequence": 2,
"host_api": 41
},
"shovey": {
@@ -34,8 +34,8 @@
"arcade": {
"id": "inbe.arcade",
"title": "Arcade",
"version": "0.7.112",
"sequence": 191,
"version": "0.7.114",
"sequence": 193,
"host_api": 41
},
"wurm": {
+3 -3
View File
@@ -33,13 +33,13 @@
"source_sha256": "96db251f36835c76cd03cd0104a6e1b5096e4c442d410960457edcd8e2377a38"
},
"wurm-editor-landscape": {
"source_sha256": "670255e43a6fd232951fb3d1ce0d62d098d663230d731e7c447c44a944a907d3"
"source_sha256": "b3616e68f1b391d1a4f9dd5d91538a63a889a7f977991e625831ec9caffa71c5"
},
"wurm-editor-portrait": {
"source_sha256": "f3475185324e4f4bfa37561f09422546eab5595ab3887d26e684128b2ac9480b"
"source_sha256": "07ff2ff0142c262cdcba3643bbc4d7d3d71643b7f9f4e678a910fee2bfd3eba1"
},
"wurm-editor-preview": {
"source_sha256": "670255e43a6fd232951fb3d1ce0d62d098d663230d731e7c447c44a944a907d3"
"source_sha256": "b3616e68f1b391d1a4f9dd5d91538a63a889a7f977991e625831ec9caffa71c5"
},
"wurm-landscape": {
"source_sha256": "472773b7c106325e12777a81a29209496e22e0853782ca76955b6587824b1b30"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 115 KiB

+2 -1
View File
@@ -1,3 +1,4 @@
{
"packages": ["shovey", "wurm", "choano"]
"packages": ["shovey", "wurm", "choano"],
"artwork": {"wurm": "wurm_art"}
}
+3 -2
View File
@@ -80,7 +80,8 @@ def stage(root, controller, expected_controller_digest, output):
bundle_bytes, preview_bytes = bundle.read_bytes(), preview.read_bytes()
if not bundle_bytes or not preview_bytes:
raise ValueError("Game bundles and previews must be built first")
preview_bytes, preview_suffix = library_art(root, name, "preview", preview_bytes)
preview_bytes, preview_suffix = library_art(root, name, "preview",
(app["art_source"] / game["preview"]).read_bytes())
total += len(bundle_bytes) + len(preview_bytes)
child = dict(
id=identifier, title=game["title"],
@@ -112,7 +113,7 @@ def stage(root, controller, expected_controller_digest, output):
relative = Path(cover[key])
if relative.is_absolute() or ".." in relative.parts or relative.suffix not in {".png", ".jpg"}:
raise ValueError("Invalid cover asset path")
contents, suffix = library_art(root, name, key, (app["source"] / relative).read_bytes())
contents, suffix = library_art(root, name, key, (app["art_source"] / relative).read_bytes())
destination = Path("arcade/covers") / f"{name}-{key}{suffix}"
packed_cover[key] = "assets/" + destination.as_posix()
copies.append((contents, destination))
+9 -2
View File
@@ -30,12 +30,19 @@ def relative_path(text):
def declared_packages(root, ziran=None, lock_flags=()):
"""Arcade first, then each registered game package, with their apps."""
names = ['self', *json.loads((Path(root) / 'games.json').read_text())['packages']]
registration = json.loads((Path(root) / 'games.json').read_text())
names = ['self', *registration['packages']]
if len(set(names)) != len(names):
raise ValueError('Duplicate game package')
artwork = registration.get('artwork', {})
if not isinstance(artwork, dict) or any(name not in names[1:] or
not isinstance(alias, str) or not re.fullmatch(r'[A-Za-z_][A-Za-z0-9_]*', alias)
for name, alias in artwork.items()):
raise ValueError('Invalid artwork package')
packages = []
for name in names:
source = package_root(root, name, ziran, lock_flags)
art_source = package_root(root, artwork[name], ziran, lock_flags) if name in artwork else source
declaration = json.loads((source / 'apps.json').read_text())
apps = []
for app in declaration['apps']:
@@ -61,7 +68,7 @@ def declared_packages(root, ziran=None, lock_flags=()):
not re.fullmatch(r'[A-Za-z_][A-Za-z0-9_]*:[A-Za-z_][A-Za-z0-9_]*', item)
for item in library_entries) or len(set(library_entries)) != len(library_entries):
raise ValueError(f'{name}: invalid portable library entries')
apps.append(dict(package=name, source=source, manifest=manifest,
apps.append(dict(package=name, source=source, art_source=art_source, manifest=manifest,
descriptor=json.loads(manifest.read_text()),
cover=app.get('cover'), requires=requires, shared_code=shared_code,
shared_records=shared_records,
+7 -2
View File
@@ -42,6 +42,11 @@ def small_copy(data, key):
"""(bytes, suffix) of the library's copy of one picture."""
image = Image.open(io.BytesIO(data))
image.load()
# The shared library cards are 2:3. Keep the top of taller paintings,
# where their title lives, rather than letting the card centre-crop it.
# Originals remain untouched; this framing belongs to the thumbnail.
if key == 'portrait' and image.height > image.width * 1.5:
image = image.crop((0, 0, image.width, round(image.width * 1.5)))
longest = PREVIEW_LONGEST if key == 'preview' else LOGO_LONGEST if key == 'logo' else COVER_LONGEST
scale = min(1.0, longest / max(image.size))
alpha = 'A' in image.getbands() or 'transparency' in image.info
@@ -72,10 +77,10 @@ def art(root=ROOT):
if not app['enabled']:
continue
name = app['descriptor']['name']
yield name, 'preview', (app['source'] / app['descriptor']['preview']).read_bytes()
yield name, 'preview', (app['art_source'] / app['descriptor']['preview']).read_bytes()
for key in ('portrait', 'landscape', 'logo'):
if app['cover'] and key in app['cover']:
yield name, key, (app['source'] / app['cover'][key]).read_bytes()
yield name, key, (app['art_source'] / app['cover'][key]).read_bytes()
def main():
+87 -3
View File
@@ -20,9 +20,51 @@ spec.loader.exec_module(builder)
art_spec = importlib.util.spec_from_file_location("library_art", ROOT / "scripts/library-art.py")
artist = importlib.util.module_from_spec(art_spec)
art_spec.loader.exec_module(artist)
spec = importlib.util.spec_from_file_location("published_games", ROOT / "scripts/wait-published-games.py")
published_games = importlib.util.module_from_spec(spec)
spec.loader.exec_module(published_games)
def bundle_asset_paths(path):
"""Read the actual bundle index without loading its images or executing it."""
with published_games.Reader(path) as reader:
if reader.take(8) != b"ZX\0\0\x1a\0\0\0":
raise ValueError("Unsupported game bundle")
reader.text()
reader.text()
for _ in range(reader.number()):
reader.text()
reader.text()
for _ in range(reader.number()):
for _ in range(7):
reader.text()
reader.take(8)
reader.text()
reader.take(4)
for _ in range(reader.number()):
for _ in range(3):
reader.text()
reader.skip(reader.number())
paths = set()
for _ in range(reader.number()):
name = reader.text().decode()
if name in paths:
raise ValueError("Duplicate game asset: " + name)
paths.add(name)
reader.skip(reader.number())
reader.finish()
return paths
class CollectionTests(unittest.TestCase):
def test_choano_runtime_images_are_packed_at_their_runtime_paths(self):
# Fixed runtime references catch a doubled namespace in the real
# compiled payload, independently of the packaging declaration.
assets = bundle_asset_paths(ROOT / "build/games/choano.zx")
for path in ("assets/choano/background-inside.png", "assets/choano/organisms-hd.png",
"assets/choano/title-landscape.jpg", "assets/choano/fish/sea.png"):
self.assertTrue(path in assets, "Choano runtime image missing from its bundle: " + path)
def setUp(self):
self.directory = tempfile.TemporaryDirectory(prefix="collection-", dir=ROOT / "build")
self.addCleanup(self.directory.cleanup)
@@ -107,6 +149,10 @@ class CollectionTests(unittest.TestCase):
(library / "sources.json").write_text(json.dumps(sources))
def stage_four_leaf_wurm_fixture(self):
registration = self.root / 'games.json'
value = json.loads(registration.read_text())
value.pop('artwork', None)
registration.write_text(json.dumps(value))
source = self.root / "fixture-packages/wurm"
(source / "editor").mkdir(parents=True)
(source / "assets").mkdir()
@@ -194,7 +240,7 @@ class CollectionTests(unittest.TestCase):
self.assertEqual(wurm_package["children"], ["xyz.waozi.wurm", "xyz.waozi.wurm-editor"])
children = {child["id"]: child for child in catalog["children"]}
self.assertEqual(children["xyz.waozi.choano"]["title"], "Choano")
self.assertEqual(children["xyz.waozi.choano"]["version"], "0.1.2")
self.assertEqual(children["xyz.waozi.choano"]["version"], "0.1.3")
self.assertEqual(children["xyz.waozi.choano"]["expected_id"], "choano")
self.assertEqual(children["xyz.waozi.wurm"]["version"], wurm_version)
self.assertEqual(children["xyz.waozi.wurm-editor"]["version"], "0.1.0")
@@ -218,6 +264,26 @@ class CollectionTests(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "wurm-portrait art changed"):
self.stage()
def test_artwork_input_changes_no_game_payload_or_version(self):
packages = builder.declared_packages(self.root)
game = next(app for package in packages for app in package['apps']
if app['descriptor']['name'] == 'wurm-editor')
self.assertNotEqual(game['source'], game['art_source'])
self.assertEqual(hashlib.sha256((game['art_source'] / game['cover']['portrait']).read_bytes()).hexdigest(),
'07ff2ff0142c262cdcba3643bbc4d7d3d71643b7f9f4e678a910fee2bfd3eba1')
catalog = self.stage()
child = next(item for item in catalog['children'] if item['expected_id'] == 'wurm-editor')
self.assertEqual(child['version'], '0.1.0')
self.assertEqual(child['sha256'], builder.digest(self.root / 'build/games/wurm-editor.zx'))
def test_artwork_override_must_name_a_registered_game(self):
path = self.root / 'games.json'
value = json.loads(path.read_text())
value['artwork'] = {'unknown-game': 'wurm_art'}
path.write_text(json.dumps(value))
with self.assertRaisesRegex(ValueError, 'Invalid artwork package'):
self.stage()
def test_every_library_cover_uses_a_bounded_thumbnail(self):
catalog, packages = builder.stage(self.root, self.controller, self.controller_digest, self.output)
children = {child['id']: child for child in catalog['children']}
@@ -229,7 +295,7 @@ class CollectionTests(unittest.TestCase):
for key in ('portrait', 'landscape', 'logo'):
if key not in app['cover']:
continue
original = (app['source'] / app['cover'][key]).read_bytes()
original = (app['art_source'] / app['cover'][key]).read_bytes()
with self.subTest(app=child['id'], image=key):
with Image.open(io.BytesIO(original)) as source:
with Image.open(self.output / child['cover'][key]) as thumbnail:
@@ -237,8 +303,11 @@ class CollectionTests(unittest.TestCase):
self.assertLessEqual(max(thumbnail.size), limit)
self.assertLessEqual(thumbnail.width, source.width)
self.assertLessEqual(thumbnail.height, source.height)
expected_ratio = source.width / source.height
if key == 'portrait':
expected_ratio = max(2 / 3, expected_ratio)
self.assertAlmostEqual(thumbnail.width / thumbnail.height,
source.width / source.height, delta=0.01)
expected_ratio, delta=0.01)
self.assertIn(thumbnail.mode, ('RGB', 'RGBA'))
# Opaque cover art is a JPEG; transparency stays PNG.
self.assertEqual(thumbnail.format, 'JPEG' if key != 'logo' and
@@ -389,6 +458,21 @@ class CollectionTests(unittest.TestCase):
class LibraryThumbnailTests(unittest.TestCase):
def test_tall_portrait_keeps_title_inside_the_library_card(self):
source = Image.new('RGB', (800, 1600), (25, 50, 75))
source.paste((220, 180, 40), (80, 100, 720, 220))
data = io.BytesIO()
source.save(data, 'PNG')
contents, suffix = artist.small_copy(data.getvalue(), 'portrait')
self.assertEqual(suffix, '.jpg')
with Image.open(io.BytesIO(contents)) as thumbnail:
self.assertEqual(thumbnail.size, (427, 640))
# The real card's centred cover fit now leaves the title intact.
red, green, blue = thumbnail.getpixel((213, 85))
self.assertGreater(red, 200)
self.assertGreater(green, 160)
self.assertLess(blue, 60)
def test_cover_keeps_full_colour_at_thumbnail_resolution(self):
source = Image.new('RGB', (900, 1200))
source.putdata([(x % 256, y % 256, (x + y) % 256)
+31 -7
View File
@@ -4,9 +4,12 @@
// and the covers must draw from the site's own copies or its exact art.
// Usage: node tests/web_site_test.mjs SITE_DIR
// ARCADE_TEST_LIBRARY_ONLY=1 checks painted library covers and titles without downloading games.
// ARCADE_TEST_PACKAGES=DIR serves local packages by their verified SHA-256 for unpublished builds.
import { spawn } from 'node:child_process';
import { createHash } from 'node:crypto';
import { createReadStream } from 'node:fs';
import { createServer } from 'node:http';
import { access, mkdtemp, readFile, rm } from 'node:fs/promises';
import { access, mkdtemp, readFile, rm, stat } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { extname, join, normalize } from 'node:path';
import { setTimeout as delay } from 'node:timers/promises';
@@ -15,6 +18,7 @@ const site = process.argv[2];
const libraryOnly = process.env.ARCADE_TEST_LIBRARY_ONLY === '1';
const requiredTitles = ['Apfelwurm', 'Apfelwurm Editor', 'Choano'];
const game = process.env.ARCADE_TEST_GAME || 'Apfelwurm';
const packages = process.env.ARCADE_TEST_PACKAGES;
if (!site) throw new Error('Usage: node tests/web_site_test.mjs SITE_DIR');
const types = { '.html': 'text/html', '.js': 'text/javascript', '.wasm': 'application/wasm', '.json': 'application/json',
'.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.webp': 'image/webp',
@@ -28,6 +32,19 @@ const server = createServer(async (request, response) => {
const url = new URL(request.url, 'http://x');
const path = normalize(decodeURIComponent(url.pathname)).replace(/^\/+/, '') || 'index.html';
try {
const fixture = packages && /^test-packages\/([a-f0-9]{64})\.zx$/.exec(path);
if (fixture) {
const file = join(packages, fixture[1] + '.zx');
const size = (await stat(file)).size;
if (size > 64 * 1024 * 1024) throw new Error('Oversized local package');
const hash = createHash('sha256');
for await (const chunk of createReadStream(file)) hash.update(chunk);
if (hash.digest('hex') !== fixture[1]) throw new Error('Local package does not match requested digest');
response.writeHead(200, { 'Content-Type': 'application/octet-stream', 'Content-Length': size,
'Access-Control-Allow-Origin': '*' });
createReadStream(file).pipe(response);
return;
}
// Model the previous runtime still cached under its unversioned URL.
// A new deployment must request its coherent runtime revision instead.
if (path === 'runtime.js' && !url.searchParams.has('v')) {
@@ -93,6 +110,12 @@ try {
const { requestId, request } = message.params;
const refuse = library && request.url.includes(library.art);
if (refuse) refusedArt.push(request.url);
const fixture = packages && /\/api\/v2\/packages\/inbe\.arcade\/([a-f0-9]{64})\.zx(?:\?|$)/.exec(request.url);
if (fixture && !refuse) {
socket.send(JSON.stringify({ id: ++sequence, method: 'Fetch.continueRequest', params: {
requestId, url: `http://127.0.0.1:${server.address().port}/test-packages/${fixture[1]}.zx` } }));
return;
}
socket.send(JSON.stringify(refuse
? { id: ++sequence, method: 'Fetch.failRequest', params: { requestId, errorReason: 'BlockedByClient' } }
: { id: ++sequence, method: 'Fetch.continueRequest', params: { requestId } }));
@@ -172,14 +195,15 @@ try {
};
const button = (nodes, label) => nodes.find(node => node.kind === 'button' && node.label === label && node.visible);
const waitButton = async label => {
const labels = Array.isArray(label) ? label : [label];
let nodes;
for (const end = Date.now() + 60000; Date.now() < end;) {
nodes = await tree();
const found = button(nodes, label);
const found = nodes.find(node => node.kind === 'button' && labels.includes(node.label) && node.visible);
if (found) return found;
await delay(150);
}
throw new Error('Game did not show ' + label + ': ' + nodes.filter(node => node.kind === 'button').map(node => node.label).join(', '));
throw new Error('Game did not show ' + labels.join(' or ') + ': ' + nodes.filter(node => node.kind === 'button').map(node => node.label).join(', '));
};
const pageReady = async () => {
for (const end = Date.now() + 60000; Date.now() < end;) {
@@ -255,12 +279,12 @@ try {
const download = (await tree()).findLast(node => node.kind === 'button' && node.label === 'Download');
if (!download) throw new Error('The cover did not offer its download');
await click(download);
await waitButton(game === 'Apfelwurm' ? 'Play' : 'Back');
await waitButton(game === 'Apfelwurm' ? 'Play' : ['Play', 'Back']);
const play = button(await tree(), 'Play');
if (play) await click(play);
const swipe = button(await tree(), 'Swipe');
if (swipe) await click(swipe);
if (game === 'Apfelwurm') await waitButton('Pause');
if (play || game === 'Apfelwurm') await waitButton('Pause');
// Flush the actual control record before a cold restart.
await evaluate(`new Promise((resolve,reject) => FS.syncfs(false,error => error ? reject(error) : resolve(true)))`);
await command('Page.reload');
@@ -269,7 +293,7 @@ try {
const installed = button(reloaded, game);
if (!installed) throw new Error('Installed cover missing after reload');
await click(installed);
await waitButton(game === 'Apfelwurm' ? 'Play' : 'Back');
await waitButton(game === 'Apfelwurm' ? 'Play' : ['Play', 'Back']);
console.log(game + ' downloaded, opened its game and reopened from its installed cover');
if (game === 'Apfelwurm') {
await command('Page.reload');
@@ -369,4 +393,4 @@ if (failure) {
console.error(console_lines.slice(-20).join('\n'));
throw new Error(failure);
}
console.log('Arcade opened its library in the browser');
console.log('Arcade opened its library in the browser' + (packages ? ' using local packages verified by SHA-256' : ''));
+18 -9
View File
@@ -160,6 +160,14 @@
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "528618898db605b0f2960759d49871cde2209086",
"dependencies": {"apps": "p9928fc15e7b93288", "entity": "pb6d17ac2aeb5844f", "game2d": "pf2f54c7603f6e861", "kryon": "p43481d12b77897ce", "mingcute": "pe1027b9d16704793"},
"id": "pba7b4d6a4dcf84ae",
"name": "Choano",
"ref": "528618898db605b0f2960759d49871cde2209086",
"url": "https://github.com/waozixyz/choano.git"
},
{
"commit": "944826f70779a6b6cd53f6b06a75b36f4d8a2558",
"dependencies": {},
@@ -176,14 +184,6 @@
"ref": "master",
"url": "https://github.com/kryonlabs/mingcute.git"
},
{
"commit": "b7cfb33ab6f6d5fc0bcf472282d507ada42d0702",
"dependencies": {"apps": "p9928fc15e7b93288", "entity": "pb6d17ac2aeb5844f", "game2d": "pf2f54c7603f6e861", "kryon": "p43481d12b77897ce", "mingcute": "pe1027b9d16704793"},
"id": "pe128e00fa98e0676",
"name": "Choano",
"ref": "b7cfb33ab6f6d5fc0bcf472282d507ada42d0702",
"url": "https://github.com/waozixyz/choano.git"
},
{
"commit": "d32e4b606ece83e8869c954f66c334f44f7b4838",
"dependencies": {"kryon": "p43481d12b77897ce"},
@@ -192,6 +192,15 @@
"ref": "d32e4b606ece83e8869c954f66c334f44f7b4838",
"url": "https://github.com/kryonlabs/game2d.git"
},
{
"commit": "2fa52f64eb0c29e8351b437176e896b938ece8e8",
"dependencies": {},
"id": "pef8c9ab30363ef38",
"name": "wurm_art",
"ref": "2fa52f64eb0c29e8351b437176e896b938ece8e8",
"source": true,
"url": "https://github.com/waozixyz/wurm.git"
},
{
"commit": "cee04692f3461dcb098833472f071c434980debb",
"dependencies": {"kryon": "p43481d12b77897ce"},
@@ -202,7 +211,7 @@
}
],
"root": {
"dependencies": {"apps": "p6a59d2d6364debd6", "choano": "pe128e00fa98e0676", "entity": "pb6d17ac2aeb5844f", "game2d": "pe878ed78ee9f8300", "inbe": "p183b01bccc6424e7", "kryon": "p43481d12b77897ce", "mingcute": "pe1027b9d16704793", "shovey": "p1b5832789c5a5053", "wurm": "pb4256918f4b7855d"},
"dependencies": {"apps": "p6a59d2d6364debd6", "choano": "pba7b4d6a4dcf84ae", "entity": "pb6d17ac2aeb5844f", "game2d": "pe878ed78ee9f8300", "inbe": "p183b01bccc6424e7", "kryon": "p43481d12b77897ce", "mingcute": "pe1027b9d16704793", "shovey": "p1b5832789c5a5053", "wurm": "pb4256918f4b7855d", "wurm_art": "pef8c9ab30363ef38"},
"name": "Arcade"
},
"toolchain": {
+7 -1
View File
@@ -64,4 +64,10 @@ ref = "d32e4b606ece83e8869c954f66c334f44f7b4838"
[dependencies.choano]
git = "https://github.com/waozixyz/choano.git"
ref = "b7cfb33ab6f6d5fc0bcf472282d507ada42d0702"
ref = "528618898db605b0f2960759d49871cde2209086"
# Library art can advance independently of the tested game payload.
[dependencies.wurm_art]
git = "https://github.com/waozixyz/wurm.git"
ref = "2fa52f64eb0c29e8351b437176e896b938ece8e8"
source = true