* feat(server): 外部皮肤接受跨平台客户端的 base 与装饰规则,社区皮肤可在 Windows 加载 社区皮肤库按跨平台客户端(msime 的 client-core)的规则校验,base 写的是全局主题 system / shuishan / light / paper / night / ink,而 Windows 只认六个内置皮肤 ID,所以社区里绝大多数皮肤在 Windows 上整包加载失败。 - base 为 system 时按 fluent 加载,配色原样保留。 - base 为五个内置全局主题时按 fluent 加载,并照 theme::resolve 换算配色:主题固定明暗,只取包里那一种明暗的配色,深浅两种模式都画它;读不懂的颜色当作没写,没写的按主题补齐,右键菜单和悬浮工具栏一并补上。包没声明那一种明暗时不生效,与客户端一致。 - 装饰规则与客户端对齐:空表或两个尺寸都为 0 表示无装饰;有尺寸而无 image 时用图片类型的 preview,都没有就不画。 - 复制 msime-cloud 的 client_dialect.json 作测试夹具,新测试要求客户端接受的每个包在 Windows 上都能加载;scripts/sync-client-dialect.py 负责同步,每周的 Skin client dialect 工作流比对上游。 * feat(server): 皮肤清单与跨平台客户端统一为同一套规则 同一个皮肤包现在在每个平台上要么都能加载,要么都被拒绝。规则以 msime client-core 的 load() 为准,共享用例表 client_dialect.json 改为从 msime 同步,测试要求每一条用例的接受与否都与客户端一致。 - 保留 ID 加上全局主题 ID(system、shuishan、light、paper、night、ink、custom)。 - 收紧到客户端的规则:skin.toml 最大 64 KiB;schema_version 必须是整数 1;author、description 写了不能为空;preview 写了必须指向包内已有的文件;toolbar_stylesheet 写了必须是包根目录里已有的 .css 文件;[license] 的各键有长度限制;[candidate] 与其中的 dark、light 必须是表;装饰图与背景图须是图片扩展名。 - 仓库自带的 7 个皮肤、示例皮肤和 msime-skins 里的 4 个皮肤在新规则下都能加载。
35 lines
1.9 KiB
Python
Executable File
35 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Refresh, or with --check verify, server/tests/data/client_dialect.json against msime.
|
|
|
|
The file is msime's crates/client-core/src/skin/catalog/client_dialect.json: the case table for the skin manifest rules every platform reads skin.toml with, which the cross-platform client, msime-cloud's community library and this repository are all held to. The server test candidate_skin_catalog_loads_exactly_the_packages_the_client_accepts runs every case, so a rule changed there reaches this repository as a failing check rather than as skins that load on one platform and not on another.
|
|
"""
|
|
import argparse
|
|
import sys
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
SOURCE = 'https://raw.githubusercontent.com/metasequoiaime/msime/{ref}/crates/client-core/src/skin/catalog/client_dialect.json'
|
|
TARGET = Path(__file__).resolve().parents[1] / 'server/tests/data/client_dialect.json'
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
parser.add_argument('--ref', default='develop', help='msime branch, tag or commit to read (default: develop)')
|
|
parser.add_argument('--check', action='store_true', help='fail when the copy differs instead of rewriting it')
|
|
args = parser.parse_args()
|
|
with urllib.request.urlopen(SOURCE.format(ref=args.ref), timeout=30) as response:
|
|
upstream = response.read()
|
|
if args.check:
|
|
if TARGET.read_bytes() != upstream:
|
|
print(f'{TARGET.relative_to(TARGET.parents[3])} differs from msime {args.ref}; run scripts/sync-client-dialect.py and fix what the server tests then report', file=sys.stderr)
|
|
return 1
|
|
print(f'client_dialect.json matches msime {args.ref}')
|
|
return 0
|
|
TARGET.write_bytes(upstream)
|
|
print(f'Wrote {TARGET.relative_to(TARGET.parents[3])} from msime {args.ref}')
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|