From 4a1b901f25560d9fbaba4ae669b7bf1c96e2b996 Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Sat, 22 Feb 2025 18:07:27 +0800 Subject: [PATCH] chore: config updates --- .vscode/launch.json | 7 ++ README.md | 169 +++++++++++++++++++++-------- apps/showcase/index.js | 4 +- package.json | 2 +- packages/assets/config.yaml | 10 +- packages/assets/index.js | 2 +- packages/assets/libs/build.js | 8 +- packages/assets/runner.js | 1 - packages/config/config.yaml | 30 +++-- packages/operator/index.js | 6 +- packages/vite-helpers/index.js | 40 ++++--- packages/wrangler/eslint.config.js | 6 +- turbo.json | 24 +++- 13 files changed, 205 insertions(+), 104 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f8af529..ff442a4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -104,5 +104,12 @@ "command": "pnpm run download:data", "cwd": "${workspaceFolder}" }, + { + "type": "node-terminal", + "name": "Run Script: deploy", + "request": "launch", + "command": "pnpm run deploy", + "cwd": "${workspaceFolder}" + }, ] } diff --git a/README.md b/README.md index 84e107b..fe31661 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,30 @@ Run dev server for showcase webpage for an operator $ name= pnpm run preview:showcase Preview built showcase webpage for an operator ``` +``` bash +$ pnpm run dev:directory +Run dev server for directory webpage +``` +``` bash +$ name= pnpm run preview:directory +Preview built directory webpage +``` +``` bash +$ pnpm run preview +Preview built all webpages +``` +``` bash +$ name= id= pnpm run init +Init new operator config +``` +``` bash +$ pnpm run download:game +Download latest game data from Arknights +``` +``` bash +$ pnpm run download:data +Download extracted game assets +``` ### Webpage & JavaScript Add query string `aklive2d` to bring up the settings panel to adjust your settings. @@ -52,33 +76,103 @@ Using JS events to change settings is recommended. ## Config ### General Config in `packages/config/config.yaml` + +Settings for the whole project ``` yaml -folder: - operator: ./operator/ # folder for operator assets - release: ./release/ # folder for released showcase page -operators: - chen: !include config/chen.yaml # include the config for the operator under folder `config/chen.yaml` - dusk: !include config/dusk.yaml - dusk_everything_is_a_miracle: !include config/dusk_everything_is_a_miracle.yaml - ling: !include config/ling.yaml - nearl: !include config/nearl.yaml - nian: !include config/nian.yaml - nian_unfettered_freedom: !include config/nian_unfettered_freedom.yaml - phatom_focus: !include config/phatom_focus.yaml - rosmontis: !include config/rosmontis.yaml - skadi: !include config/skadi.yaml - skadi_sublimation: !include config/skadi_sublimation.yaml - w: !include config/w.yaml - w_fugue: !include config/w_fugue.yaml - specter: !include config/specter.yaml - gavial: !include config/gavial.yaml - surtr_colorful_wonderland: !include config/surtr_colorful_wonderland.yaml - lee_trust_your_eyes: !include config/lee_trust_your_eyes.yaml - texas_the_omertosa: !include config/texas_the_omertosa.yaml - nearl_relight: !include config/nearl_relight.yaml - rosmontis_become_anew: !include config/rosmontis_become_anew.yaml - passager_dream_in_a_moment: !include config/passager_dream_in_a_moment.yaml - mizuki_summer_feast: !include config/mizuki_summer_feast.yaml +site_id: aklive2d +akassets: + project_name: akassets + url: https://akassets.pages.dev +insight: + id: aklive2d + url: https://insight.halyul.dev/on-demand.js +module: + assets: + config_yaml: config.yaml + background: background + music: music + charword_table: charword_table + project_json: project_json + background: + operator_bg_png: operator_bg.png + charword_table: + charword_table_json: charword_table.json + music: + music_table_json: music_table.json + display_meta_table_json: display_meta_table.json + audio_data_json: audio_data.json + official_info: + official_info_json: official_info.json + operator: + operator: operator + config: config + template_yaml: _template.yaml + config_yaml: config.yaml + portraits: _portraits + logos_assets: _logos + logos: logos + directory_assets: _directory + MonoBehaviour: MonoBehaviour + Texture2D: Texture2D + title: + zh-CN: '明日方舟:' + en-US: 'Arknights: ' + project_json: + project_json: project.json + preview_jpg: preview.jpg + template_yaml: project_json.yaml + wrangler: + index_json: index.json + vite_helpers: + config_json: config.json +app: + showcase: + public: public + assets: assets +dir_name: + data: data + dist: dist + extracted: extracted + auto_update: auto_update + voice: + main: voice + sub: + - name: jp + lang: JP + lookup_region: zh_CN + - name: cn + lang: CN_MANDARIN + lookup_region: zh_CN + - name: en + lang: EN + lookup_region: en_US + - name: kr + lang: KR + lookup_region: ko_KR + - name: custom + lang: CUSTOM + lookup_region: zh_CN +directory: + assets_dir: _assets + title: AKLive2D + voice: jp/CN_037.ogg + error: + files: + - key: build_char_128_plosis_epoque#3 + paddings: + left: -120 + right: 150 + top: 10 + bottom: 0 + - key: build_char_128_plosis + paddings: + left: -90 + right: 100 + top: 10 + bottom: 0 + voice: + file: CN_034.ogg + target: error.ogg ``` ### Operators Config in `packages/operator/config.yaml` @@ -129,12 +223,9 @@ The `LICENSE` file applies to all files unless listed specifically. - all files under `packages/background/data` folder and its sub-folders ## Instructions on Extracting In-Game Assets -I'm still struggling to find a command-line tool to extract in-game assets. But [AssetRipper](https://github.com/AssetRipper/AssetRipper) seems to have a command-line interface, I'm too lazy to have a deeper inverstigation. - | Assets Name | Location | Type | |-------------|----------|------| -| Logos | spritepack/ui_camp_logo_h2_0.ab | Sprite | -| Logos for collaboration | spritepack/ui_camp_logo_h2_linkage_0.ab | Sprite | +| Logos | spritepack/ui_camp_logo_0.ab | Sprite | | Logo Mapping | gamedata/art/handbookpos_table.json3 | TextAsset | | Dynaimc Character | arts/dynchars/ | Texture2D & TextAsset | | Static Image | Operator: chararts/ ; Skin: skinpack/ | Texture2D | @@ -149,21 +240,3 @@ I'm still struggling to find a command-line tool to extract in-game assets. But 2: `gamedata/excel/display_meta_table.json->homeBackgroundData`3 and `gamedata/excel/audio_data.json`3 is required to locate the music. 3: Data is encryped, decryped version can be obtained from [ArknightsGameData](https://github.com/Kengxxiao/ArknightsGameData) for the Chinese version and [Kengxxiao/ArknightsGameData_YoStar](https://github.com/Kengxxiao/ArknightsGameData_YoStar) for other regions. - -## URLs - -| Name | URL | Note | -|------|-----|------| -| Config | [link](https://ak-conf.hypergryph.com/config/prod/official/Android/version) | Version info | -| Current Hot Update JSON | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/hot_update_list.json) | Directory JSON | -| Voice JP | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_vcjp.dat) | Voice JP | -| Voice CN | [link 1](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_vccn.dat), [link 2](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_vcbsc.dat) | Voice CN | -| Voice KR | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_vckr.dat) | Voice KR | -| Voice EN | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_vcen.dat) | Voice EN | -| Voice Custom | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_vccsm.dat) | Voice Custom | -| Misc | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_v052.dat) | Latest Home Background, Skin Static Image | -| Init | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_init.dat) | Logos, Background, Portrait Images | -| Dynaimc Characters | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_dynilst.dat) | Dynaimc Character | -| Static Image | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_crart.dat) | Operator Static Image | -| Home Music | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_music.dat) | Home Music | -| L Com? | [link](https://ak.hycdn.cn/assetbundle/official/Android/assets/24-07-09-15-29-50-f0a675/lpack_lcom.dat) | portrait_hub.ab | \ No newline at end of file diff --git a/apps/showcase/index.js b/apps/showcase/index.js index ada7157..9dacc4c 100644 --- a/apps/showcase/index.js +++ b/apps/showcase/index.js @@ -2,10 +2,10 @@ import path from 'node:path' import config from '@aklive2d/config' export const DATA_DIR = path.resolve(import.meta.dirname, config.dir_name.data) -export const PUBLIC_DIR = path.resolve(DATA_DIR, config.dir_name.public) +export const PUBLIC_DIR = path.resolve(DATA_DIR, config.app.showcase.public) export const PUBLIC_ASSETS_DIR = path.resolve( PUBLIC_DIR, - config.dir_name.assets + config.app.showcase.assets ) export const OUT_DIR = path.resolve(import.meta.dirname, config.dir_name.dist) export const DIST_DIR = path.resolve( diff --git a/package.json b/package.json index b5b955d..fccb10f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "stylelint": "^16.14.1", "turbo": "^2.4.2" }, - "packageManager": "pnpm@9.5.0", + "packageManager": "pnpm@10.4.1", "name": "aklive2d", "type": "module" } diff --git a/packages/assets/config.yaml b/packages/assets/config.yaml index bdfade6..e2868cc 100644 --- a/packages/assets/config.yaml +++ b/packages/assets/config.yaml @@ -1,8 +1,8 @@ dynchars: dynchars item_to_download: - - homebackground/wrapper - - ui_camp_logo - - charportraits - - voice.*/extra + - homebackground/wrapper + - ui_camp_logo + - charportraits + - voice.*/extra additional_regex: - - ^(?!(avg))(.*)$ \ No newline at end of file + - ^(?!(avg))(.*)$ diff --git a/packages/assets/index.js b/packages/assets/index.js index 3fef033..84c2c52 100644 --- a/packages/assets/index.js +++ b/packages/assets/index.js @@ -5,7 +5,7 @@ import { yaml } from '@aklive2d/libs' export const DIST_DIR = path.resolve(import.meta.dirname, config.dir_name.dist) export const CONFIG_PATH = path.resolve( import.meta.dirname, - config.dir_name.config_yaml + config.module.assets.config_yaml ) const selfConfig = yaml.read(CONFIG_PATH) diff --git a/packages/assets/libs/build.js b/packages/assets/libs/build.js index 63d9fce..338910a 100644 --- a/packages/assets/libs/build.js +++ b/packages/assets/libs/build.js @@ -12,7 +12,7 @@ export default async (packageDir) => { 'background', config.dir_name.dist ), - target: path.resolve(DIST_DIR, config.dir_name.background), + target: path.resolve(DIST_DIR, config.module.assets.background), }, { fn: file.symlink, @@ -21,12 +21,12 @@ export default async (packageDir) => { 'charword-table', config.dir_name.dist ), - target: path.resolve(DIST_DIR, config.dir_name.charword_table), + target: path.resolve(DIST_DIR, config.module.assets.charword_table), }, { fn: file.symlink, source: path.resolve(packageDir, 'music', config.dir_name.data), - target: path.resolve(DIST_DIR, config.dir_name.music), + target: path.resolve(DIST_DIR, config.module.assets.music), }, { fn: file.symlinkAll, @@ -40,7 +40,7 @@ export default async (packageDir) => { 'project-json', config.dir_name.dist ), - target: path.resolve(DIST_DIR, config.dir_name.project_json), + target: path.resolve(DIST_DIR, config.module.assets.project_json), }, ] copyQueue.map(({ fn, source, target }) => { diff --git a/packages/assets/runner.js b/packages/assets/runner.js index 7bba6a8..0e7c81e 100644 --- a/packages/assets/runner.js +++ b/packages/assets/runner.js @@ -1,5 +1,4 @@ import path from 'node:path' -import fs from 'node:fs' import { envParser } from '@aklive2d/libs' import config from '@aklive2d/config' import build from './libs/build.js' diff --git a/packages/config/config.yaml b/packages/config/config.yaml index d9214a6..690f0be 100644 --- a/packages/config/config.yaml +++ b/packages/config/config.yaml @@ -6,8 +6,13 @@ insight: id: aklive2d url: https://insight.halyul.dev/on-demand.js module: - background: + assets: + config_yaml: config.yaml background: background + music: music + charword_table: charword_table + project_json: project_json + background: operator_bg_png: operator_bg.png charword_table: charword_table_json: charword_table.json @@ -18,15 +23,16 @@ module: official_info: official_info_json: official_info.json operator: + operator: operator config: config template_yaml: _template.yaml config_yaml: config.yaml portraits: _portraits logos_assets: _logos + logos: logos directory_assets: _directory MonoBehaviour: MonoBehaviour Texture2D: Texture2D - assets_json: assets.json title: zh-CN: '明日方舟:' en-US: 'Arknights: ' @@ -36,21 +42,17 @@ module: template_yaml: project_json.yaml wrangler: index_json: index.json + vite_helpers: + config_json: config.json +app: + showcase: + public: public + assets: assets dir_name: - config_yaml: config.yaml - assets: assets data: data dist: dist extracted: extracted auto_update: auto_update - operator: operator - background: background - music: music - logos: logos - public: public - charword_table: charword_table - project_json: project_json - config_json: config.json voice: main: voice sub: @@ -69,10 +71,6 @@ dir_name: - name: custom lang: CUSTOM lookup_region: zh_CN -share: - title: - zh-CN: '明日方舟:' - en-US: 'Arknights: ' directory: assets_dir: _assets title: AKLive2D diff --git a/packages/operator/index.js b/packages/operator/index.js index cc611f1..05a348b 100644 --- a/packages/operator/index.js +++ b/packages/operator/index.js @@ -35,7 +35,7 @@ const getConfigFolder = () => { } const getDistFolder = (name) => { - return path.join(DIST_DIR, config.dir_name.operator, name) + return path.join(DIST_DIR, config.module.operator.operator, name) } export const has = (name) => { @@ -77,7 +77,7 @@ const copyVoices = (name) => { const copyLogos = () => { file.symlink( path.join(OPERATOR_SOURCE_FOLDER, config.module.operator.logos_assets), - path.join(DIST_DIR, config.dir_name.logos) + path.join(DIST_DIR, config.module.operator.logos) ) } @@ -270,7 +270,7 @@ export const init = (name, id) => { path.resolve(operatorConfigFolder, `${name}.yaml`) ) file.appendSync( - `\n${name}: !include ${config.module.operator.config}/${name}.yaml`, + `${name}: !include ${config.module.operator.config}/${name}.yaml\n`, CONFIG_PATH ) } diff --git a/packages/vite-helpers/index.js b/packages/vite-helpers/index.js index a9a79cf..9a07444 100644 --- a/packages/vite-helpers/index.js +++ b/packages/vite-helpers/index.js @@ -14,7 +14,7 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { file.mkdir(publicAssetsDir) const operatorAssetsDir = path.join( ASSETS_DIST_DIR, - config.dir_name.operator, + config.module.operator.operator, name ) const spineFilenames = file @@ -23,13 +23,19 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { const q = [ { fn: file.symlink, - source: path.resolve(ASSETS_DIST_DIR, config.dir_name.background), - target: path.resolve(publicAssetsDir, config.dir_name.background), + source: path.resolve( + ASSETS_DIST_DIR, + config.module.assets.background + ), + target: path.resolve( + publicAssetsDir, + config.module.assets.background + ), }, { fn: file.symlink, - source: path.resolve(ASSETS_DIST_DIR, config.dir_name.music), - target: path.resolve(publicAssetsDir, config.dir_name.music), + source: path.resolve(ASSETS_DIST_DIR, config.module.assets.music), + target: path.resolve(publicAssetsDir, config.module.assets.music), }, { fn: file.symlinkAll, @@ -45,7 +51,7 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { filename: `${operators[name].fallback_name}.png`, source: path.resolve( ASSETS_DIST_DIR, - config.dir_name.operator, + config.module.operator.operator, name ), target: path.resolve(publicAssetsDir), @@ -53,7 +59,7 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { { fn: file.symlink, filename: `${operators[name].logo}.png`, - source: path.resolve(ASSETS_DIST_DIR, config.dir_name.logos), + source: path.resolve(ASSETS_DIST_DIR, config.module.operator.logos), target: path.resolve(publicAssetsDir), }, { @@ -61,7 +67,7 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { filename: config.module.charword_table.charword_table_json, source: path.resolve( ASSETS_DIST_DIR, - config.dir_name.charword_table, + config.module.assets.charword_table, name ), target: path.resolve(publicAssetsDir), @@ -97,16 +103,16 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { image_height: 2048, default_background: config.module.background.operator_bg_png, background_files: backgroundFiles, - background_folder: config.dir_name.background, + background_folder: config.module.assets.background, voice_default_region: defaultRegion, voice_folders: config.dir_name.voice, - music_folder: config.dir_name.music, + music_folder: config.module.assets.music, music_mapping: musicMapping.musicFileMapping, use_json: operators[name].use_json, } file.writeSync( JSON.stringify(buildConfig), - path.join(path.resolve(dataDir), config.dir_name.config_json) + path.join(path.resolve(dataDir), config.module.vite_helpers.config_json) ) file.writeSync( env.generate([ @@ -127,7 +133,7 @@ export const copyShowcaseData = (name, { dataDir, publicAssetsDir }) => { export const copyProjectJSON = (name, { releaseDir }) => { file.cpSync( - path.resolve(ASSETS_DIST_DIR, config.dir_name.project_json, name), + path.resolve(ASSETS_DIST_DIR, config.module.assets.project_json, name), path.resolve(releaseDir), { dereference: true, @@ -159,7 +165,7 @@ export const copyDirectoryData = async ({ dataDir, publicDir }) => { file.readSync( path.join( ASSETS_DIST_DIR, - config.dir_name.project_json, + config.module.assets.project_json, cur.link, config.module.project_json.project_json ) @@ -187,16 +193,16 @@ export const copyDirectoryData = async ({ dataDir, publicDir }) => { directory_folder: config.directory.assets_dir, default_background: config.module.background.operator_bg_png, background_files: backgroundFiles, - background_folder: config.dir_name.background, + background_folder: config.module.assets.background, available_operators: Object.keys(operators), error_files: config.directory.error, - music_folder: config.dir_name.music, + music_folder: config.module.assets.music, music_mapping: musicMapping.musicFileMapping, operators: operatorConfig, } file.writeSync( JSON.stringify(directoryConfig), - path.join(dataDir, config.dir_name.config_json) + path.join(dataDir, config.module.vite_helpers.config_json) ) file.writeSync( @@ -218,7 +224,7 @@ export const copyDirectoryData = async ({ dataDir, publicDir }) => { file.cpSync( path.join( sourceFolder, - config.dir_name.operator, + config.module.operator.operator, key, portraitName ), diff --git a/packages/wrangler/eslint.config.js b/packages/wrangler/eslint.config.js index 83758c8..9869fd8 100644 --- a/packages/wrangler/eslint.config.js +++ b/packages/wrangler/eslint.config.js @@ -1,5 +1,3 @@ -import baseConfig from "@aklive2d/eslint-config"; +import baseConfig from '@aklive2d/eslint-config' /** @type {import('eslint').Config} */ -export default [ - ...baseConfig, -]; \ No newline at end of file +export default [...baseConfig] diff --git a/turbo.json b/turbo.json index a4fafd1..1afef3a 100644 --- a/turbo.json +++ b/turbo.json @@ -57,10 +57,17 @@ "outputs": ["auto_update/official_info.json"] }, "update": { - "dependsOn": [] + "cache": false + }, + "@aklive2d/operator#init": { + "env": ["name", "id"], + "cache": false, + "inputs": ["../official-info/auto_update/official_info.json"], + "outputs": ["config/*.yaml", "config.yaml"] }, "init": { - "dependsOn": [] + "env": ["name", "id"], + "cache": false }, "lint": { "cache": false @@ -89,17 +96,30 @@ "cache": false, "persistent": true }, + "@aklive2d/assets#download:game": { + "cache": false, + "outputs": ["data/**"] + }, "download:game": { "cache": false }, + "@aklive2d/wrangler#upload": { + "cache": false, + "inputs": ["data/**"] + }, "upload": { "cache": false }, + "@aklive2d/wrangler#download:data": { + "cache": false, + "outputs": ["data/**"] + }, "download:data": { "cache": false }, "@aklive2d/wrangler#deploy": { "env": ["CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_API_TOKEN"], + "inputs": ["../../dist/**"], "dependsOn": ["@aklive2d/directory#build"] }, "deploy": {