Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30d347a393 | ||
|
|
ad2f5c252a | ||
|
|
e6693ad6c5 | ||
|
|
6dbad8d73f | ||
|
|
755e0ae1d0 | ||
|
|
244d3ef9a3 | ||
|
|
80ac2c61a5 |
No files matched your search
@@ -83,6 +83,10 @@ jobs:
|
||||
--controller-sha256 "$(cat build/published/apps-controller.sha256)" \
|
||||
--version '${{ steps.published.outputs.version }}'
|
||||
rm -f build/web-site/runtime.html
|
||||
- name: Wait for the published games the browser will download
|
||||
run: |
|
||||
python3 scripts/wait-published-games.py --deadline-seconds 900 --poll-seconds 30 \
|
||||
build/published/arcade.zx build/published/arcade.games.tar
|
||||
- name: Open Arcade in a private browser
|
||||
run: |
|
||||
export CHROMIUM="$(command -v google-chrome || command -v chromium)"
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# 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.
|
||||
- Choano appears in Arcade and launches from its own game package.
|
||||
- Apfelwurm and Apfelwurm Editor open correctly in standalone Arcade.
|
||||
|
||||
## 0.7.111
|
||||
|
||||
- Apfelwurm 0.2.27: Earn coins for every level you clear and spend them on new skins.
|
||||
|
||||
@@ -20,7 +20,7 @@ DATA_DIR ?= $(if $(XDG_DATA_HOME),$(XDG_DATA_HOME),$(HOME)/.local/share)
|
||||
all: collection build/entity.zx build/arcade build/shovey
|
||||
|
||||
games:
|
||||
python3 scripts/check-games.py
|
||||
python3 scripts/check-games.py --ziran '$(ZIRAN)' $(LOCK_FLAGS)
|
||||
python3 scripts/build-games.py --ziran '$(ZIRAN)' $(LOCK_FLAGS)
|
||||
|
||||
$(APPS_BUNDLE): ziran.lock apps-controller.sha256 scripts/build-apps.py Makefile
|
||||
|
||||
@@ -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 @@
|
||||
e41f568fade6b2fc1d622d42d57340ad4743c0cea281f410764b79fcefdf4ec0
|
||||
fc63c84e19ce2f63fcd587478962c67aee31202353addcf840c9228d69c048c7
|
||||
@@ -10,6 +10,13 @@
|
||||
"sequence": 6,
|
||||
"host_api": 41
|
||||
},
|
||||
"choano": {
|
||||
"id": "xyz.waozi.choano",
|
||||
"title": "Choano",
|
||||
"version": "0.1.3",
|
||||
"sequence": 2,
|
||||
"host_api": 41
|
||||
},
|
||||
"shovey": {
|
||||
"id": "arcade.shovey",
|
||||
"title": "Shovey",
|
||||
@@ -27,8 +34,8 @@
|
||||
"arcade": {
|
||||
"id": "inbe.arcade",
|
||||
"title": "Arcade",
|
||||
"version": "0.7.111",
|
||||
"sequence": 190,
|
||||
"version": "0.7.114",
|
||||
"sequence": 193,
|
||||
"host_api": 41
|
||||
},
|
||||
"wurm": {
|
||||
|
||||
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 95 KiB |
@@ -1,4 +1,13 @@
|
||||
{
|
||||
"choano-landscape": {
|
||||
"source_sha256": "1ca6e31c1062a7cca41bace4cf1bb221291988aea4a1dd61271899c2f5f28307"
|
||||
},
|
||||
"choano-portrait": {
|
||||
"source_sha256": "47b07722c474a67ee4a06b7644a3aff211503674391e363c17eb06a34ce60d6c"
|
||||
},
|
||||
"choano-preview": {
|
||||
"source_sha256": "1ca6e31c1062a7cca41bace4cf1bb221291988aea4a1dd61271899c2f5f28307"
|
||||
},
|
||||
"shovey-editor-landscape": {
|
||||
"source_sha256": "7b1eae4209ede14807806a4cbce1e2bf7a14d342e75c89042958a524cf60d67e"
|
||||
},
|
||||
@@ -24,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"
|
||||
|
||||
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 115 KiB |
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"packages": ["shovey", "wurm"]
|
||||
"packages": ["shovey", "wurm", "choano"],
|
||||
"artwork": {"wurm": "wurm_art"}
|
||||
}
|
||||
@@ -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"],
|
||||
@@ -110,9 +111,9 @@ def stage(root, controller, expected_controller_digest, output):
|
||||
if key not in cover:
|
||||
continue
|
||||
relative = Path(cover[key])
|
||||
if relative.is_absolute() or ".." in relative.parts or relative.suffix != ".png":
|
||||
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))
|
||||
|
||||
@@ -37,6 +37,7 @@ def build(ziran, lock_flags):
|
||||
[ziran, "pkg", "path", name, *lock_flags], cwd=ROOT, text=True).strip())
|
||||
|
||||
kryon = package("kryon")
|
||||
game2d = package("game2d")
|
||||
toolchain = package("ziran")
|
||||
entity = package("entity")
|
||||
compiler = toolchain / "build/bin/ziran"
|
||||
@@ -142,6 +143,7 @@ def build(ziran, lock_flags):
|
||||
"--module-path", str(kryon / "src/ui"),
|
||||
"--module-path", "kryon=" + str(kryon / "src/ui"),
|
||||
"--module-path", "kryon=" + str(kryon / "src/backend"),
|
||||
"--module-path", "game2d=" + str(game2d / "src"),
|
||||
"--module-path", "std=" + str(toolchain / "std"),
|
||||
"--module-path", str(toolchain / "std"),
|
||||
"--module-path", "apps=" + str(package("apps") / "src"),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check game ownership, shared interface versions, translations and update metadata."""
|
||||
import json
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import re
|
||||
from game_packages import declared_apps
|
||||
@@ -8,7 +9,7 @@ from game_packages import declared_apps
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def check():
|
||||
def check(ziran, lock_flags):
|
||||
standard = json.loads((ROOT / 'standards/game-v1.json').read_text())
|
||||
ledger = json.loads((ROOT / 'apps/versions.json').read_text())
|
||||
# Arcade's own players refuse games newer than GAME_HOST_API, so it moves
|
||||
@@ -16,7 +17,7 @@ def check():
|
||||
player = re.search(r'^GAME_HOST_API :: (\d+)$', (ROOT / 'src/game_contract.zi').read_text(), re.M)
|
||||
assert player and int(player[1]) == standard['host_api'] == ledger['host_api'], \
|
||||
'src/game_contract.zi GAME_HOST_API, standards/game-v1.json and apps/versions.json must name the same host interface'
|
||||
for app in declared_apps(ROOT):
|
||||
for app in declared_apps(ROOT, ziran, lock_flags):
|
||||
source, manifest, game = app['source'], app['manifest'], app['descriptor']
|
||||
for field in ['contract_version', 'module_api', 'host_api']:
|
||||
assert game[field] == standard[field], f'{game["name"]}: incompatible {field}'
|
||||
@@ -61,5 +62,9 @@ def check():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
check()
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--ziran', default=str(ROOT / 'scripts/ziran.sh'))
|
||||
parser.add_argument('--locked', action='store_true')
|
||||
arguments = parser.parse_args()
|
||||
check(arguments.ziran, ['--locked'] if arguments.locked else [])
|
||||
print('Game contract, package sources, translated text and independent version ledger passed')
|
||||
@@ -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,
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Wait for the game packages a published Arcade catalog advertises.
|
||||
|
||||
The site still tests the real Inbe API before its browser gate. The publisher
|
||||
can follow a GitHub release by several minutes, so readiness is conditional and
|
||||
has a hard deadline; no package is extracted or executed.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
API_ROOT = "https://api.waozi.xyz"
|
||||
CATALOG_PATH = "assets/apps/catalog.json"
|
||||
BUNDLE_LIMIT = 64 * 1024 * 1024
|
||||
CATALOG_LIMIT = 1024 * 1024
|
||||
READ_CHUNK = 1024 * 1024
|
||||
PREFIX_BYTES = 16
|
||||
REQUEST_TIMEOUT_SECONDS = 15
|
||||
|
||||
|
||||
class Reader:
|
||||
def __init__(self, path):
|
||||
self.size = path.stat().st_size
|
||||
if self.size > BUNDLE_LIMIT:
|
||||
raise ValueError("published Arcade bundle is too large")
|
||||
self.remaining = self.size
|
||||
self.file = path.open("rb")
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, kind, value, traceback):
|
||||
self.file.close()
|
||||
|
||||
def take(self, size):
|
||||
if size < 0 or size > self.remaining:
|
||||
raise ValueError("truncated bundle")
|
||||
data = self.file.read(size)
|
||||
if len(data) != size:
|
||||
raise ValueError("truncated bundle")
|
||||
self.remaining -= size
|
||||
return data
|
||||
|
||||
def skip(self, size):
|
||||
if size < 0 or size > self.remaining:
|
||||
raise ValueError("truncated bundle")
|
||||
self.file.seek(size, 1)
|
||||
self.remaining -= size
|
||||
|
||||
def number(self):
|
||||
return struct.unpack("<I", self.take(4))[0]
|
||||
|
||||
def text(self, limit=BUNDLE_LIMIT):
|
||||
size = self.number()
|
||||
if size > limit or size > self.remaining:
|
||||
raise ValueError("oversized bundle field")
|
||||
return self.take(size)
|
||||
|
||||
def finish(self):
|
||||
if self.file.read(1):
|
||||
raise ValueError("trailing bundle bytes")
|
||||
self.file.close()
|
||||
|
||||
|
||||
def catalog_from_bundle(path):
|
||||
with Reader(path) as reader:
|
||||
if reader.take(8) != b"ZX\0\0\x1a\0\0\0":
|
||||
raise ValueError("unsupported 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())
|
||||
assets = reader.number()
|
||||
catalog = None
|
||||
seen = set()
|
||||
for _ in range(assets):
|
||||
name = reader.text().decode()
|
||||
if name in seen:
|
||||
raise ValueError("duplicate bundle file")
|
||||
seen.add(name)
|
||||
size = reader.number()
|
||||
if name == CATALOG_PATH:
|
||||
if catalog is not None or size > CATALOG_LIMIT:
|
||||
raise ValueError("invalid collection catalog")
|
||||
catalog = reader.take(size)
|
||||
else:
|
||||
reader.skip(size)
|
||||
reader.finish()
|
||||
if catalog is None:
|
||||
raise ValueError("the collection lacks a catalog")
|
||||
return json.loads(catalog)
|
||||
|
||||
|
||||
def expected_games(catalog):
|
||||
children = catalog.get("children")
|
||||
if not isinstance(children, list):
|
||||
raise ValueError("invalid collection catalog")
|
||||
games = {}
|
||||
for child in children:
|
||||
digest, size = child.get("sha256", ""), child.get("bytes")
|
||||
if not re.fullmatch(r"[0-9a-f]{64}", digest) or not isinstance(size, int) \
|
||||
or not 0 < size <= BUNDLE_LIMIT:
|
||||
raise ValueError("invalid game in the collection catalog")
|
||||
games[digest] = size
|
||||
return games
|
||||
|
||||
|
||||
def archive_members(archive, games):
|
||||
members = {}
|
||||
with tarfile.open(archive, "r:") as content:
|
||||
for entry in content:
|
||||
digest = entry.name.removesuffix(".zx")
|
||||
if digest not in games:
|
||||
continue
|
||||
if not entry.isfile() or digest in members or entry.size != games[digest]:
|
||||
raise ValueError("the release game archive differs from the catalog")
|
||||
source = content.extractfile(entry)
|
||||
source_digest = hashlib.sha256()
|
||||
prefix = bytearray()
|
||||
read = 0
|
||||
while chunk := source.read(min(READ_CHUNK, games[digest] - read)):
|
||||
source_digest.update(chunk)
|
||||
if len(prefix) < PREFIX_BYTES:
|
||||
prefix.extend(chunk[:PREFIX_BYTES - len(prefix)])
|
||||
read += len(chunk)
|
||||
if read != games[digest] or source_digest.hexdigest() != digest:
|
||||
raise ValueError("the release game archive differs from the catalog")
|
||||
members[digest] = (source_digest.hexdigest(), bytes(prefix))
|
||||
if set(members) != set(games):
|
||||
raise ValueError("the release game archive lacks a catalog game")
|
||||
return members
|
||||
|
||||
|
||||
def package_ready(api_root, digest, size, prefix, timeout_seconds=REQUEST_TIMEOUT_SECONDS):
|
||||
url = f"{api_root.rstrip('/')}/api/v2/packages/inbe.arcade/{digest}.zx"
|
||||
request = urllib.request.Request(
|
||||
url,
|
||||
headers={"Range": f"bytes=0-{PREFIX_BYTES - 1}", "User-Agent": "arcade-site-readiness"},
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=timeout_seconds) as response:
|
||||
status = response.status
|
||||
content_type = response.headers.get_content_type()
|
||||
etag = response.headers.get("ETag")
|
||||
content_range = response.headers.get("Content-Range")
|
||||
content_length = response.headers.get("Content-Length")
|
||||
body = response.read(PREFIX_BYTES)
|
||||
except urllib.error.HTTPError as error:
|
||||
error.close()
|
||||
return False
|
||||
except (TimeoutError, urllib.error.URLError):
|
||||
return False
|
||||
if etag != f'"{digest}"':
|
||||
return False
|
||||
expected_length = size if status == 200 else min(PREFIX_BYTES, size)
|
||||
if content_length is not None:
|
||||
try:
|
||||
length = int(content_length)
|
||||
except ValueError:
|
||||
return False
|
||||
if length != expected_length:
|
||||
return False
|
||||
if status == 206:
|
||||
match = re.fullmatch(r"bytes 0-(\d+)/(\d+)", content_range or "")
|
||||
if not match or int(match[1]) != min(PREFIX_BYTES, size) - 1 or int(match[2]) != size:
|
||||
return False
|
||||
elif status != 200:
|
||||
return False
|
||||
return content_type == "application/octet-stream" and body == prefix
|
||||
|
||||
|
||||
def wait_for_published_games(api_root, archive, games, members, deadline_seconds,
|
||||
poll_seconds=30, clock=time.monotonic, sleep=time.sleep):
|
||||
deadline = clock() + deadline_seconds
|
||||
pending = set(games)
|
||||
while True:
|
||||
for digest in list(pending):
|
||||
remaining = deadline - clock()
|
||||
if remaining <= 0:
|
||||
raise TimeoutError(
|
||||
f"published game packages still unavailable: {', '.join(sorted(pending))}"
|
||||
)
|
||||
ready = package_ready(
|
||||
api_root, digest, games[digest], members[digest][1],
|
||||
timeout_seconds=min(REQUEST_TIMEOUT_SECONDS, remaining),
|
||||
)
|
||||
if not ready:
|
||||
continue
|
||||
pending.remove(digest)
|
||||
if not pending:
|
||||
return
|
||||
now = clock()
|
||||
remaining = deadline - now
|
||||
if remaining <= 0:
|
||||
raise TimeoutError(f"published game packages still unavailable: {', '.join(pending)}")
|
||||
sleep(min(poll_seconds, remaining))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--api-root", default=API_ROOT)
|
||||
parser.add_argument("--deadline-seconds", type=int, default=900)
|
||||
parser.add_argument("--poll-seconds", type=float, default=30)
|
||||
parser.add_argument("bundle", type=Path)
|
||||
parser.add_argument("archive", type=Path)
|
||||
arguments = parser.parse_args()
|
||||
catalog = catalog_from_bundle(arguments.bundle)
|
||||
games = expected_games(catalog)
|
||||
members = archive_members(arguments.archive, games)
|
||||
wait_for_published_games(arguments.api_root, arguments.archive, games, members,
|
||||
arguments.deadline_seconds, arguments.poll_seconds)
|
||||
print(f"all {len(games)} catalog game packages are published and ready")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except (OSError, ValueError, TimeoutError, tarfile.TarError) as error:
|
||||
raise SystemExit(str(error))
|
||||
@@ -9,12 +9,14 @@ Game :: struct {
|
||||
enabled: bool
|
||||
}
|
||||
|
||||
GameCount :: 4
|
||||
GameCount :: 6
|
||||
|
||||
GameAt :: (index: s32) -> Game {
|
||||
if index == 0 { return Game.{.id = "inbe.chess", .name = "chess", .title = "Chess", .bundle = "chess.zx", .preview = "chess-preview.png", .package = "self", .enabled = false} }
|
||||
if index == 1 { return Game.{.id = "arcade.shovey", .name = "shovey", .title = "Shovey", .bundle = "shovey.zx", .preview = "shovey-preview.png", .package = "shovey", .enabled = true} }
|
||||
if index == 2 { return Game.{.id = "arcade.shovey-editor", .name = "shovey-editor", .title = "Shovey Editor", .bundle = "shovey-editor.zx", .preview = "shovey-editor-preview.png", .package = "shovey", .enabled = true} }
|
||||
if index == 3 { return Game.{.id = "xyz.waozi.wurm", .name = "wurm", .title = "Apfelwurm", .bundle = "wurm.zx", .preview = "wurm-preview.png", .package = "wurm", .enabled = true} }
|
||||
if index == 4 { return Game.{.id = "xyz.waozi.wurm-editor", .name = "wurm-editor", .title = "Apfelwurm Editor", .bundle = "wurm-editor.zx", .preview = "wurm-editor-preview.png", .package = "wurm", .enabled = true} }
|
||||
if index == 5 { return Game.{.id = "xyz.waozi.choano", .name = "choano", .title = "Choano", .bundle = "choano.zx", .preview = "choano-preview.png", .package = "choano", .enabled = true} }
|
||||
return Game.{}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ CollectionAllows :: (context: *void, node: *AppNode, name: string) -> bool {
|
||||
return name == "AppRecordHost" || name == "SaveAppRecordHost" ||
|
||||
name == "AppFriendHost" || name == "AppSharedHost" || name == "AppSharedItemHost" ||
|
||||
name == "AppInvitationHost" || name == "RefreshAppSharedHost" || name == "SendAppSharedHost" ||
|
||||
name == "SmoothFramesHost" || name == "AppLocaleHost" || name == "AppSoundHost" ||
|
||||
name == "SmoothFramesHost" || name == "AppLocaleHost" || name == "AppSoundHost" || name == "AppNowHost" ||
|
||||
name == "tile_map.sampling" || name == "arcade.controls" || name == "arcade.sound" || name == "arcade.navigation" ||
|
||||
name == "arcade.updates" ||
|
||||
name == PUBLICATIONS_SERVICE || name == PUBLICATIONS_READ_SERVICE ||
|
||||
@@ -186,6 +186,12 @@ CollectionCall :: (context: *void, node: *AppNode, module: *u8, function: *u8,
|
||||
result.* = HostScalar("bool", ifx asset.found && SoundPlay(asset.data) then 1 else 0)
|
||||
return 1
|
||||
}
|
||||
// Seconds since 1970: Apfelwurm counts its daily rewards by them.
|
||||
if name == "AppNowHost" && count == 0 {
|
||||
result.* = HostValue.{.kind = cast(s32)HostReal, .type_name = HostTextData("float64"),
|
||||
.real = cast(float64)UnixMilliseconds() / 1000.0}
|
||||
return 1
|
||||
}
|
||||
if name == "SmoothFramesHost" && count == 1 {
|
||||
result.* = HostScalar("bool", 1)
|
||||
return 1
|
||||
|
||||
@@ -13,6 +13,11 @@ inbe = Path(os.environ['INBE_SOURCE']) if 'INBE_SOURCE' in os.environ else Path(
|
||||
catalog = json.loads((ROOT / "build/catalog.json").read_text())["games"]
|
||||
chess = next(game for game in catalog if game["name"] == "chess")
|
||||
assert chess["id"] == "inbe.chess"
|
||||
choano = next(game for game in catalog if game["name"] == "choano")
|
||||
assert choano["id"] == "xyz.waozi.choano"
|
||||
assert choano["kind"] == "game"
|
||||
assert choano["entry"] == "portable:Main"
|
||||
assert choano["package"] == "choano"
|
||||
# Inbe releases before its node apps have no node_apps ledger at all.
|
||||
assert "chess" not in json.loads((inbe / "apps/versions.json").read_text()).get("node_apps", {})
|
||||
assert set(chess["harnesses"]) == {"arcade", "inbe"}
|
||||
@@ -25,8 +30,10 @@ assert (ROOT / chess["preview"]).is_file()
|
||||
env = {key: value for key, value in os.environ.items()
|
||||
if key not in {"DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS"}}
|
||||
listed = subprocess.run([str(ROOT / "build/arcade"), "--list"], env=env, capture_output=True, timeout=10)
|
||||
assert listed.returncode == 0 and b"inbe.chess" not in listed.stderr + listed.stdout
|
||||
assert b"arcade.shovey\n" in listed.stderr + listed.stdout
|
||||
listed_output = listed.stderr + listed.stdout
|
||||
assert listed.returncode == 0 and b"inbe.chess" not in listed_output
|
||||
assert b"arcade.shovey\n" in listed_output
|
||||
assert b"xyz.waozi.choano\n" in listed_output
|
||||
unknown = subprocess.run([str(ROOT / "build/arcade"), "--app", "unknown"],
|
||||
env=env, capture_output=True, timeout=10)
|
||||
assert unknown.returncode == 1 and b"unknown game" in unknown.stderr
|
||||
@@ -34,7 +41,13 @@ original = (ROOT / 'build/games/chess.zx').read_bytes()
|
||||
container = (ROOT / 'build/arcade.zx').read_bytes()
|
||||
metadata = json.loads((ROOT / 'build/arcade.json').read_text())
|
||||
assert original not in container, 'Disabled Chess must not remain in the published collection'
|
||||
assert {child['id'] for child in metadata['children']} == {'arcade.shovey', 'arcade.shovey-editor', 'xyz.waozi.wurm'}
|
||||
assert {child['id'] for child in metadata['children']} == {
|
||||
'arcade.shovey', 'arcade.shovey-editor', 'xyz.waozi.choano',
|
||||
'xyz.waozi.wurm', 'xyz.waozi.wurm-editor'
|
||||
}
|
||||
choano_child = next(child for child in metadata['children'] if child['id'] == 'xyz.waozi.choano')
|
||||
assert choano_child['expected_id'] == 'choano'
|
||||
assert choano_child['bundle'] == 'assets/arcade/games/choano.zx'
|
||||
for child in metadata['children']:
|
||||
name = child['expected_id']
|
||||
exact = (ROOT / f'build/games/{name}.zx').read_bytes()
|
||||
|
||||
@@ -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()
|
||||
@@ -189,9 +235,13 @@ class CollectionTests(unittest.TestCase):
|
||||
self.assert_children_match_declarations(catalog, packages, self.root)
|
||||
self.assertEqual([child["id"] for child in catalog["children"]],
|
||||
["arcade.shovey", "arcade.shovey-editor",
|
||||
"xyz.waozi.wurm", "xyz.waozi.wurm-editor"])
|
||||
self.assertEqual(packages[-1]["children"], ["xyz.waozi.wurm", "xyz.waozi.wurm-editor"])
|
||||
"xyz.waozi.wurm", "xyz.waozi.wurm-editor", "xyz.waozi.choano"])
|
||||
wurm_package = next(package for package in packages if package["name"] == "wurm")
|
||||
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.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")
|
||||
self.assertEqual(children["xyz.waozi.wurm"]["cover"]["caption"], "Classic")
|
||||
@@ -214,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']}
|
||||
@@ -225,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:
|
||||
@@ -233,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
|
||||
@@ -385,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)
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
import hashlib
|
||||
import http.server
|
||||
import io
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import tarfile
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"wait_published_games", ROOT / "scripts/wait-published-games.py"
|
||||
)
|
||||
readiness = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(readiness)
|
||||
|
||||
|
||||
def bundle(files):
|
||||
def text(value):
|
||||
return struct.pack("<I", len(value)) + value
|
||||
|
||||
data = b"ZX\0\0\x1a\0\0\0" + text(b"arcade") + text(b"Main")
|
||||
data += struct.pack("<IIII", 0, 0, 0, 0) + struct.pack("<I", len(files))
|
||||
for path in sorted(files):
|
||||
data += text(path.encode()) + text(files[path])
|
||||
return data
|
||||
|
||||
|
||||
class Clock:
|
||||
def __init__(self):
|
||||
self.now = 0.0
|
||||
|
||||
def __call__(self):
|
||||
return self.now
|
||||
|
||||
def sleep(self, seconds):
|
||||
self.now += seconds
|
||||
|
||||
|
||||
class Handler(http.server.BaseHTTPRequestHandler):
|
||||
responses = {}
|
||||
|
||||
def do_GET(self):
|
||||
digest = self.path.rsplit("/", 1)[-1].removesuffix(".zx")
|
||||
response = self.responses.get(digest, "ready")
|
||||
if isinstance(response, list):
|
||||
response = response.pop(0)
|
||||
if response == "ready":
|
||||
game = getattr(self.server, "games", {})
|
||||
body = game.get(digest, b"")[:16]
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/octet-stream")
|
||||
self.send_header("ETag", f'"{digest}"')
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
return
|
||||
if isinstance(response, int):
|
||||
self.send_response(response)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"{}")
|
||||
return
|
||||
body = response.get("body", b"ZX\0\0\x1a\0\0\0port")
|
||||
self.send_response(response.get("status", 200))
|
||||
self.send_header("Content-Type", response.get("type", "application/octet-stream"))
|
||||
if "etag" in response:
|
||||
self.send_header("ETag", response["etag"])
|
||||
if "range" in response:
|
||||
self.send_header("Content-Range", response["range"])
|
||||
self.send_header("Content-Length", str(response.get("length", len(body))))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, format, *arguments):
|
||||
pass
|
||||
|
||||
|
||||
class WaitPublishedGamesTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
work = ROOT / "build/scratch"
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
self.temporary = tempfile.TemporaryDirectory(prefix="published-games-", dir=work)
|
||||
self.root = Path(self.temporary.name)
|
||||
self.games = {
|
||||
hashlib.sha256(b"first game").hexdigest(): b"first game",
|
||||
hashlib.sha256(b"second game").hexdigest(): b"second game",
|
||||
hashlib.sha256(b"third game with bytes").hexdigest(): b"third game with bytes",
|
||||
}
|
||||
catalog = {
|
||||
"children": [
|
||||
{"sha256": digest, "bytes": len(data)} for digest, data in self.games.items()
|
||||
]
|
||||
}
|
||||
self.bundle = self.root / "arcade.zx"
|
||||
self.bundle.write_bytes(bundle({"assets/apps/catalog.json": json.dumps(catalog).encode()}))
|
||||
self.archive = self.root / "arcade.games.tar"
|
||||
with tarfile.open(self.archive, "w") as content:
|
||||
for digest, data in self.games.items():
|
||||
member = tarfile.TarInfo(digest + ".zx")
|
||||
member.size = len(data)
|
||||
content.addfile(member, io.BytesIO(data))
|
||||
Handler.responses = {}
|
||||
self.server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler)
|
||||
self.server.games = {digest: data for digest, data in self.games.items()}
|
||||
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
|
||||
self.thread.start()
|
||||
self.api_root = f"http://127.0.0.1:{self.server.server_port}"
|
||||
|
||||
def tearDown(self):
|
||||
self.server.shutdown()
|
||||
self.server.server_close()
|
||||
self.thread.join(timeout=5)
|
||||
self.temporary.cleanup()
|
||||
|
||||
def wait(self, deadline=1.0):
|
||||
games = readiness.expected_games(readiness.catalog_from_bundle(self.bundle))
|
||||
members = readiness.archive_members(self.archive, games)
|
||||
clock = Clock()
|
||||
readiness.wait_for_published_games(self.api_root, self.archive, games, members,
|
||||
deadline, poll_seconds=0.01,
|
||||
clock=clock, sleep=clock.sleep)
|
||||
|
||||
def test_all_packages_ready(self):
|
||||
self.wait()
|
||||
|
||||
def test_a_404_is_retried_until_the_package_is_ready(self):
|
||||
digest = next(iter(self.games))
|
||||
Handler.responses[digest] = [404, "ready"]
|
||||
self.wait(deadline=0.03)
|
||||
|
||||
def test_a_permanent_404_fails_at_the_deadline(self):
|
||||
Handler.responses[next(iter(self.games))] = 404
|
||||
with self.assertRaisesRegex(TimeoutError, "still unavailable"):
|
||||
self.wait(deadline=0.01)
|
||||
|
||||
def test_error_or_mismatched_responses_do_not_count_as_ready(self):
|
||||
digest = next(iter(self.games))
|
||||
for response in (
|
||||
{"etag": '"0" * 64'},
|
||||
{"type": "text/plain"},
|
||||
{"body": b"not the verified prefix"},
|
||||
{"body": b"0123456789abcdef", "etag": None},
|
||||
{"status": 206, "range": "bytes 0-15/1"},
|
||||
500,
|
||||
):
|
||||
Handler.responses[digest] = response
|
||||
with self.subTest(response=response), self.assertRaises(TimeoutError):
|
||||
self.wait()
|
||||
|
||||
def test_an_exact_partial_response_counts_as_ready(self):
|
||||
digest, game = next(item for item in self.games.items() if len(item[1]) > 16)
|
||||
Handler.responses[digest] = {
|
||||
"status": 206,
|
||||
"etag": f'"{digest}"',
|
||||
"range": f"bytes 0-{min(16, len(game)) - 1}/{len(game)}",
|
||||
"body": game[:16],
|
||||
}
|
||||
self.wait()
|
||||
|
||||
def test_a_wrong_full_response_content_length_does_not_count_as_ready(self):
|
||||
digest, game = next(iter(self.games.items()))
|
||||
Handler.responses[digest] = {
|
||||
"etag": f'"{digest}"',
|
||||
"body": game,
|
||||
"length": len(game) + 1,
|
||||
}
|
||||
with self.assertRaisesRegex(TimeoutError, digest):
|
||||
self.wait(deadline=0.02)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -3,15 +3,22 @@
|
||||
// library's art never comes from api.waozi.xyz: those requests are refused,
|
||||
// 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';
|
||||
|
||||
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',
|
||||
@@ -25,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')) {
|
||||
@@ -90,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 } }));
|
||||
@@ -169,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;) {
|
||||
@@ -220,110 +247,135 @@ try {
|
||||
if (served.art || refusedArt.length || served.pictures !== Object.keys(library.pictures).length ||
|
||||
fetched.some(name => !/\.webp\?v=/.test(name) && !Object.values(library.pictures).some(picture => name.includes(picture.file))))
|
||||
throw new Error('The covers did not come from the small copies alone: ' + JSON.stringify({ served, refusedArt, fetched }));
|
||||
console.log(`Covers drew from ${served.pictures} small copies (${Object.values(library.pictures).reduce((sum, picture) => sum + picture.bytes, 0)} bytes, art ${library.bytes} bytes); colours ${colours}`);
|
||||
await command('Emulation.setDeviceMetricsOverride', { width: 1280, height: 1400, deviceScaleFactor: 1, mobile: false });
|
||||
await delay(500);
|
||||
// Sample only the Text widget's rectangle below each cover. Neither the
|
||||
// cover image nor its invisible button/alt text can satisfy this check.
|
||||
const titles = (await tree()).filter(node => node.kind === 'text' && node.visible &&
|
||||
node.visible_height >= 20 && requiredTitles.includes(node.label));
|
||||
const paintedTitles = await evaluate(`(() => {
|
||||
const canvas = document.getElementById('canvas'), context = canvas.getContext('2d');
|
||||
const scale = canvas.width / canvas.clientWidth;
|
||||
return Object.fromEntries(${JSON.stringify(titles)}.map(node => {
|
||||
const pixels = context.getImageData(Math.round(node.visible_x * scale), Math.round(node.visible_y * scale),
|
||||
Math.round(node.visible_width * scale), Math.round(node.visible_height * scale)).data;
|
||||
let ink = 0;
|
||||
for (let at = 0; at < pixels.length; at += 4)
|
||||
if (pixels[at] > 120 && pixels[at + 1] > 120 && pixels[at + 2] > 120) ink++;
|
||||
return [node.label, ink];
|
||||
}));
|
||||
})()`);
|
||||
for (const title of requiredTitles) {
|
||||
if (!(paintedTitles[title] >= 100)) throw new Error(`Game title was not painted: ${title}: ${JSON.stringify(paintedTitles)}`);
|
||||
}
|
||||
console.log(`Covers drew from ${served.pictures} small copies (${Object.values(library.pictures).reduce((sum, picture) => sum + picture.bytes, 0)} bytes, art ${library.bytes} bytes); colours ${colours}; title ink pixels ${JSON.stringify(paintedTitles)}`);
|
||||
}
|
||||
const cover = button(await tree(), game);
|
||||
if (!cover) throw new Error('Game cover missing');
|
||||
await click(cover);
|
||||
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');
|
||||
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');
|
||||
// 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');
|
||||
await pageReady();
|
||||
const reloaded = await tree();
|
||||
const installed = button(reloaded, game);
|
||||
if (!installed) throw new Error('Installed cover missing after reload');
|
||||
await click(installed);
|
||||
await waitButton(game === 'Apfelwurm' ? 'Play' : 'Back');
|
||||
console.log(game + ' downloaded, opened its game and reopened from its installed cover');
|
||||
if (game === 'Apfelwurm') {
|
||||
if (!libraryOnly) {
|
||||
await command('Emulation.setDeviceMetricsOverride', { width: 1280, height: 800, deviceScaleFactor: 1, mobile: false });
|
||||
await delay(500);
|
||||
const cover = button(await tree(), game);
|
||||
if (!cover) throw new Error('Game cover missing');
|
||||
await click(cover);
|
||||
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' : ['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 (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');
|
||||
await pageReady();
|
||||
const installed = button(await tree(), game);
|
||||
const saved = await evaluate(`(() => {
|
||||
const root='/kryon-apps/arcade/games';
|
||||
for (const name of FS.readdir(root)) {
|
||||
const path=root+'/'+name+'/records/controls.dat';
|
||||
if (FS.analyzePath(path).exists) return {path,text:FS.readFile(path,{encoding:'utf8'})};
|
||||
}
|
||||
return null;
|
||||
})()`);
|
||||
if (!saved) throw new Error('Playing did not retain the control choice');
|
||||
await evaluate(`(() => {
|
||||
const original=FS.open;
|
||||
FS.open=function(path,...args) {
|
||||
if (String(path).includes('/games/') && String(path).includes('/records/') && !String(path).endsWith('/.lock')) {
|
||||
FS.open=original;
|
||||
throw new FS.ErrnoError(29);
|
||||
}
|
||||
return original.call(this,path,...args);
|
||||
};
|
||||
})()`);
|
||||
const reloaded = await tree();
|
||||
const installed = button(reloaded, game);
|
||||
if (!installed) throw new Error('Installed cover missing after reload');
|
||||
await click(installed);
|
||||
// Depending on the game version it first reads records on its title
|
||||
// or on Play. Either path must expose a usable recovery control.
|
||||
if (!await evaluate('!!Module.arcadeFailed')) {
|
||||
try {
|
||||
const play=button(await tree(),'Play');
|
||||
if (play) await click(play);
|
||||
} catch (error) {
|
||||
// The first game frame can fail between sampling the flag and
|
||||
// asking for its tree. Require the runtime's failure signal.
|
||||
let failed=false;
|
||||
for (const end=Date.now()+1000; Date.now()<end;) {
|
||||
failed=await evaluate('!!Module.arcadeFailed');
|
||||
if (failed) break;
|
||||
await delay(50);
|
||||
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');
|
||||
await pageReady();
|
||||
const installed = button(await tree(), game);
|
||||
const saved = await evaluate(`(() => {
|
||||
const root='/kryon-apps/arcade/games';
|
||||
for (const name of FS.readdir(root)) {
|
||||
const path=root+'/'+name+'/records/controls.dat';
|
||||
if (FS.analyzePath(path).exists) return {path,text:FS.readFile(path,{encoding:'utf8'})};
|
||||
}
|
||||
return null;
|
||||
})()`);
|
||||
if (!saved) throw new Error('Playing did not retain the control choice');
|
||||
await evaluate(`(() => {
|
||||
const original=FS.open;
|
||||
FS.open=function(path,...args) {
|
||||
if (String(path).includes('/games/') && String(path).includes('/records/') && !String(path).endsWith('/.lock')) {
|
||||
FS.open=original;
|
||||
throw new FS.ErrnoError(29);
|
||||
}
|
||||
return original.call(this,path,...args);
|
||||
};
|
||||
})()`);
|
||||
await click(installed);
|
||||
// Depending on the game version it first reads records on its title
|
||||
// or on Play. Either path must expose a usable recovery control.
|
||||
if (!await evaluate('!!Module.arcadeFailed')) {
|
||||
try {
|
||||
const play=button(await tree(),'Play');
|
||||
if (play) await click(play);
|
||||
} catch (error) {
|
||||
// The first game frame can fail between sampling the flag and
|
||||
// asking for its tree. Require the runtime's failure signal.
|
||||
let failed=false;
|
||||
for (const end=Date.now()+1000; Date.now()<end;) {
|
||||
failed=await evaluate('!!Module.arcadeFailed');
|
||||
if (failed) break;
|
||||
await delay(50);
|
||||
}
|
||||
if (!failed) throw error;
|
||||
}
|
||||
if (!failed) throw error;
|
||||
}
|
||||
let recovered=false;
|
||||
for (const end=Date.now()+15000; Date.now()<end;) {
|
||||
recovered=await evaluate(`!!Module.arcadeFailed && document.getElementById('loading').classList.contains('error') && getComputedStyle(document.getElementById('loading')).opacity==='1'`);
|
||||
if (recovered) break;
|
||||
await delay(100);
|
||||
}
|
||||
if (!recovered) throw new Error('A failed game left the library frozen without recovery');
|
||||
if (!console_lines.some(line=>/portable execution failed in ReadLevel/.test(line)))
|
||||
throw new Error('The fixture did not reproduce the reported saved-record failure');
|
||||
expectedDiagnostics=console_lines.length;
|
||||
const retry=await evaluate(`(() => {const r=document.getElementById('retry').getBoundingClientRect();return {visible_x:r.x,visible_y:r.y,visible_width:r.width,visible_height:r.height};})()`);
|
||||
await click(retry);
|
||||
await pageReady();
|
||||
if (await evaluate(`FS.readFile(${JSON.stringify(saved.path)},{encoding:'utf8'})`) !== saved.text)
|
||||
throw new Error('Recovering from a failed game changed its saved record');
|
||||
await click(button(await tree(),game));
|
||||
await waitButton('Play');
|
||||
console.log('The reported ReadLevel failure showed recovery; returning reopened the installed game and retained its saved record');
|
||||
}
|
||||
let recovered=false;
|
||||
for (const end=Date.now()+15000; Date.now()<end;) {
|
||||
recovered=await evaluate(`!!Module.arcadeFailed && document.getElementById('loading').classList.contains('error') && getComputedStyle(document.getElementById('loading')).opacity==='1'`);
|
||||
if (recovered) break;
|
||||
await delay(100);
|
||||
if (library) {
|
||||
// Damaged copies are refused; the exact art from the site draws instead.
|
||||
libraryMode = 'corrupt'; served.pictures = served.art = 0;
|
||||
await command('Page.reload');
|
||||
await pageReady();
|
||||
const colours = await coversDrawn();
|
||||
if (served.art !== 1 || refusedArt.length)
|
||||
throw new Error('Damaged copies did not fall back to the site\'s exact art: ' + JSON.stringify({ served, refusedArt }));
|
||||
console.log(`Damaged copies were refused and the site's exact art drew the covers; colours ${colours}`);
|
||||
// Without the site's art the covers stay empty and Arcade asks the API.
|
||||
libraryMode = 'missing';
|
||||
await command('Page.reload');
|
||||
await pageReady();
|
||||
await delay(3000);
|
||||
const empty = await coverColours();
|
||||
if (!refusedArt.length || !empty.length || empty.some(count => count >= DRAWN))
|
||||
throw new Error('The cover check did not tell empty covers apart: ' + JSON.stringify({ empty, refusedArt }));
|
||||
console.log(`Without the site's art the covers stayed empty (colours ${empty}) and the API art request was refused`);
|
||||
libraryMode = 'site';
|
||||
}
|
||||
if (!recovered) throw new Error('A failed game left the library frozen without recovery');
|
||||
if (!console_lines.some(line=>/portable execution failed in ReadLevel/.test(line)))
|
||||
throw new Error('The fixture did not reproduce the reported saved-record failure');
|
||||
expectedDiagnostics=console_lines.length;
|
||||
const retry=await evaluate(`(() => {const r=document.getElementById('retry').getBoundingClientRect();return {visible_x:r.x,visible_y:r.y,visible_width:r.width,visible_height:r.height};})()`);
|
||||
await click(retry);
|
||||
await pageReady();
|
||||
if (await evaluate(`FS.readFile(${JSON.stringify(saved.path)},{encoding:'utf8'})`) !== saved.text)
|
||||
throw new Error('Recovering from a failed game changed its saved record');
|
||||
await click(button(await tree(),game));
|
||||
await waitButton('Play');
|
||||
console.log('The reported ReadLevel failure showed recovery; returning reopened the installed game and retained its saved record');
|
||||
}
|
||||
if (library) {
|
||||
// Damaged copies are refused; the exact art from the site draws instead.
|
||||
libraryMode = 'corrupt'; served.pictures = served.art = 0;
|
||||
await command('Page.reload');
|
||||
await pageReady();
|
||||
const colours = await coversDrawn();
|
||||
if (served.art !== 1 || refusedArt.length)
|
||||
throw new Error('Damaged copies did not fall back to the site\'s exact art: ' + JSON.stringify({ served, refusedArt }));
|
||||
console.log(`Damaged copies were refused and the site's exact art drew the covers; colours ${colours}`);
|
||||
// Without the site's art the covers stay empty and Arcade asks the API.
|
||||
libraryMode = 'missing';
|
||||
await command('Page.reload');
|
||||
await pageReady();
|
||||
await delay(3000);
|
||||
const empty = await coverColours();
|
||||
if (!refusedArt.length || !empty.length || empty.some(count => count >= DRAWN))
|
||||
throw new Error('The cover check did not tell empty covers apart: ' + JSON.stringify({ empty, refusedArt }));
|
||||
console.log(`Without the site's art the covers stayed empty (colours ${empty}) and the API art request was refused`);
|
||||
libraryMode = 'site';
|
||||
}
|
||||
}
|
||||
const failed = console_lines.slice(expectedDiagnostics).find(line => /frame failed|portable execution failed/.test(line));
|
||||
@@ -341,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' : ''));
|
||||
@@ -86,6 +86,14 @@
|
||||
"source": true,
|
||||
"url": "https://github.com/raysan5/raylib.git"
|
||||
},
|
||||
{
|
||||
"commit": "94095a939e5fa5dee1d4d9af3a9af0e9a1cb630a",
|
||||
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "p43481d12b77897ce"},
|
||||
"id": "p6a59d2d6364debd6",
|
||||
"name": "Apps",
|
||||
"ref": "94095a939e5fa5dee1d4d9af3a9af0e9a1cb630a",
|
||||
"url": "https://github.com/waozixyz/apps.git"
|
||||
},
|
||||
{
|
||||
"commit": "22d2ddbdc236796953c905a05a2cebf5ab1b4ff3",
|
||||
"dependencies": {"liboqs": "p1aaef6f156781e69"},
|
||||
@@ -152,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": {},
|
||||
@@ -168,6 +184,23 @@
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/mingcute.git"
|
||||
},
|
||||
{
|
||||
"commit": "d32e4b606ece83e8869c954f66c334f44f7b4838",
|
||||
"dependencies": {"kryon": "p43481d12b77897ce"},
|
||||
"id": "pe878ed78ee9f8300",
|
||||
"name": "Game2D",
|
||||
"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"},
|
||||
@@ -178,7 +211,7 @@
|
||||
}
|
||||
],
|
||||
"root": {
|
||||
"dependencies": {"apps": "p9928fc15e7b93288", "entity": "pb6d17ac2aeb5844f", "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": {
|
||||
|
||||
@@ -34,7 +34,7 @@ ref = "master"
|
||||
[dependencies.apps]
|
||||
git = "https://github.com/waozixyz/apps.git"
|
||||
# Use the shared controller reviewed with the supported collection host.
|
||||
ref = "5b67236a8e355e67ce4f8cc0389b9ce3805b874b"
|
||||
ref = "94095a939e5fa5dee1d4d9af3a9af0e9a1cb630a"
|
||||
|
||||
# Shovey's editions and editor are available as separate downloads.
|
||||
[dependencies.shovey]
|
||||
@@ -57,3 +57,17 @@ ref = "master"
|
||||
[dependencies.wurm]
|
||||
git = "https://github.com/waozixyz/wurm.git"
|
||||
ref = "99d9ad777325e9dfc15cd8610056948819dc1f07"
|
||||
|
||||
[dependencies.game2d]
|
||||
git = "https://github.com/kryonlabs/game2d.git"
|
||||
ref = "d32e4b606ece83e8869c954f66c334f44f7b4838"
|
||||
|
||||
[dependencies.choano]
|
||||
git = "https://github.com/waozixyz/choano.git"
|
||||
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
|
||||