From 8d745845a2739e244f464d405d296c8dc874c1d7 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sun, 12 Feb 2023 18:30:50 +0000 Subject: [PATCH 1/6] Update Discord titles --- src/discord/titles/nintendo.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/discord/titles/nintendo.ts b/src/discord/titles/nintendo.ts index f88bb01..3053479 100644 --- a/src/discord/titles/nintendo.ts +++ b/src/discord/titles/nintendo.ts @@ -138,6 +138,18 @@ export const titles: Title[] = [ client: '950907272438104064', largeImageText: 'SEGA Mega Drive', }, + { + // Game Boy - Nintendo Switch Online + id: '0100c62011050000', + client: '950907272438104064', + largeImageText: 'Game Boy', + }, + { + // Game Boy Advance - Nintendo Switch Online + id: '010012f017576000', + client: '950907272438104064', + largeImageText: 'Game Boy Advance', + }, { // Animal Crossing: New Horizons From af2535da20428fd3832cb6ecb094d374cee3423c Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 28 Feb 2023 11:09:28 +0000 Subject: [PATCH 2/6] Update splatnet3-types --- package-lock.json | 14 +++++++------- package.json | 2 +- src/api/splatnet3.ts | 20 ++++++++++++++++++-- src/cli/splatnet3/token.ts | 1 + 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index d527c8d..ff29eac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "node-notifier": "^10.0.1", "node-persist": "^3.1.0", "read": "^1.0.7", - "splatnet3-types": "^0.2.20230125112953", + "splatnet3-types": "^0.2.20230227204004", "supports-color": "^8.1.1", "tslib": "^2.4.1", "uuid": "^8.3.2", @@ -4065,9 +4065,9 @@ "dev": true }, "node_modules/splatnet3-types": { - "version": "0.2.20230125112953", - "resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.2.20230125112953.tgz", - "integrity": "sha512-ZoyYHjRlq0ZIg8ZWVnQ6MYWSjEv7nVMgSImyDqho9taZS31yxrSj/xZer6teTSrCTGIabYDvx+MPEhAHg8Jbpw==" + "version": "0.2.20230227204004", + "resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.2.20230227204004.tgz", + "integrity": "sha512-FAY6pbUcrp5O8c49BNXSKxoyM3UlCrRx2AtA9Y3qlvqOLdHqwxtzcdzbk1b1hRam8ZcrxRzE/ii6ESRiPIAnZw==" }, "node_modules/sprintf-js": { "version": "1.1.2", @@ -7769,9 +7769,9 @@ "dev": true }, "splatnet3-types": { - "version": "0.2.20230125112953", - "resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.2.20230125112953.tgz", - "integrity": "sha512-ZoyYHjRlq0ZIg8ZWVnQ6MYWSjEv7nVMgSImyDqho9taZS31yxrSj/xZer6teTSrCTGIabYDvx+MPEhAHg8Jbpw==" + "version": "0.2.20230227204004", + "resolved": "https://registry.npmjs.org/splatnet3-types/-/splatnet3-types-0.2.20230227204004.tgz", + "integrity": "sha512-FAY6pbUcrp5O8c49BNXSKxoyM3UlCrRx2AtA9Y3qlvqOLdHqwxtzcdzbk1b1hRam8ZcrxRzE/ii6ESRiPIAnZw==" }, "sprintf-js": { "version": "1.1.2", diff --git a/package.json b/package.json index da0694e..60cb4b3 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "node-notifier": "^10.0.1", "node-persist": "^3.1.0", "read": "^1.0.7", - "splatnet3-types": "^0.2.20230125112953", + "splatnet3-types": "^0.2.20230227204004", "supports-color": "^8.1.1", "tslib": "^2.4.1", "uuid": "^8.3.2", diff --git a/src/api/splatnet3.ts b/src/api/splatnet3.ts index 927f47d..6756b6e 100644 --- a/src/api/splatnet3.ts +++ b/src/api/splatnet3.ts @@ -85,6 +85,7 @@ export default class SplatNet3Api { public version: string, public map_queries: Partial>, readonly map_queries_mode: MapQueriesMode, + readonly na_country: string, public language: string, public useragent: string, ) {} @@ -244,12 +245,16 @@ export default class SplatNet3Api { /** / */ async getHome() { - return this.persistedQuery(RequestId.HomeQuery, {}); + return this.persistedQuery(RequestId.HomeQuery, { + naCountry: this.na_country, + }); } /** / -> /setting */ async getSettings() { - return this.persistedQuery(RequestId.SettingQuery, {}); + return this.persistedQuery(RequestId.SettingQuery, { + naCountry: this.na_country, + }); } /** / -> /photo_album */ @@ -693,6 +698,14 @@ export default class SplatNet3Api { }); } + /** / -> /my_outfits [-> /my_outfits/{id}] -> share */ + async shareOutfit(index: number, timezone_offset_minutes = 0) { + return this.persistedQuery(RequestId.ShareMyOutfitQuery, { + myOutfitIndex: index, + timezoneOffset: timezone_offset_minutes, // (new Date()).getTimezoneOffset() + }); + } + // // Replays // @@ -933,6 +946,7 @@ export default class SplatNet3Api { data.version, data.queries ?? {}, getMapPersistedQueriesModeFromEnvironment(), + data.country, data.bullet_token.lang, data.useragent, ); @@ -944,6 +958,7 @@ export default class SplatNet3Api { data.version, data.queries ?? {}, getMapPersistedQueriesModeFromEnvironment(), + data.country ?? 'GB', data.language, SPLATNET3_WEBSERVICE_USERAGENT, ); @@ -1081,6 +1096,7 @@ export interface SplatNet3CliTokenData { bullet_token: string; expires_at: number; language: string; + country: string; version: string; queries?: Partial>; } diff --git a/src/cli/splatnet3/token.ts b/src/cli/splatnet3/token.ts index 2309100..2b9782b 100644 --- a/src/cli/splatnet3/token.ts +++ b/src/cli/splatnet3/token.ts @@ -40,6 +40,7 @@ export async function handler(argv: ArgumentsCamelCase) { bullet_token: data.bullet_token.bulletToken, expires_at: data.expires_at, language: data.bullet_token.lang, + country: data.country, version: data.version, queries: data.queries, }; From 1d4781f4f6309cae428ee55de2bb09f7e150bae6 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 28 Feb 2023 14:05:49 +0000 Subject: [PATCH 3/6] Skip TypeScript when bundling --- package-lock.json | 34 --------------------- package.json | 1 - rollup.config.js | 76 +++++++++++++++++------------------------------ 3 files changed, 28 insertions(+), 83 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff29eac..b3dda0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,6 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^14.1.0", "@rollup/plugin-replace": "^4.0.0", - "@rollup/plugin-typescript": "^8.5.0", "@types/body-parser": "^1.19.2", "@types/cli-table": "^0.3.1", "@types/debug": "^4.1.7", @@ -348,29 +347,6 @@ "rollup": "^1.20.0 || ^2.0.0" } }, - "node_modules/@rollup/plugin-typescript": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz", - "integrity": "sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==", - "dev": true, - "dependencies": { - "@rollup/pluginutils": "^3.1.0", - "resolve": "^1.17.0" - }, - "engines": { - "node": ">=8.0.0" - }, - "peerDependencies": { - "rollup": "^2.14.0", - "tslib": "*", - "typescript": ">=3.7.0" - }, - "peerDependenciesMeta": { - "tslib": { - "optional": true - } - } - }, "node_modules/@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", @@ -4850,16 +4826,6 @@ "magic-string": "^0.25.7" } }, - "@rollup/plugin-typescript": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz", - "integrity": "sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "resolve": "^1.17.0" - } - }, "@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", diff --git a/package.json b/package.json index 60cb4b3..6b21136 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^14.1.0", "@rollup/plugin-replace": "^4.0.0", - "@rollup/plugin-typescript": "^8.5.0", "@types/body-parser": "^1.19.2", "@types/cli-table": "^0.3.1", "@types/debug": "^4.1.7", diff --git a/rollup.config.js b/rollup.config.js index fbf0705..575a09a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,8 +2,8 @@ import * as path from 'path'; import { fileURLToPath } from 'url'; import * as fs from 'fs'; import * as child_process from 'child_process'; +import { Module } from 'module'; -import typescript from '@rollup/plugin-typescript'; import commonjs from '@rollup/plugin-commonjs'; import alias from '@rollup/plugin-alias'; import replace from '@rollup/plugin-replace'; @@ -43,7 +43,7 @@ const release = process.env.NODE_ENV === 'production' ? process.env.CI_COMMIT_TA * @type {import('@rollup/plugin-replace').RollupReplaceOptions} */ const replace_options = { - include: ['src/util/product.ts'], + include: ['dist/util/product.js'], values: { 'globalThis.__NXAPI_BUNDLE_PKG__': JSON.stringify(pkg), 'globalThis.__NXAPI_BUNDLE_GIT__': JSON.stringify(git), @@ -58,14 +58,14 @@ const replace_options = { * @type {import('rollup').RollupOptions['watch']} */ const watch = { - include: 'src/**', + include: 'dist/**', }; /** * @type {import('rollup').RollupOptions} */ const main = { - input: ['src/cli-entry.ts', 'src/app/main/index.ts'], + input: ['dist/cli-entry.js', 'dist/app/main/index.js'], output: { dir: 'dist/bundle', format: 'es', @@ -79,19 +79,17 @@ const main = { }, plugins: [ replace(replace_options), - typescript({ - outDir: 'dist/bundle/ts', - noEmit: true, - declaration: false, - }), commonjs({ - // the ".ts" extension is required - extensions: ['.js', '.jsx', '.ts', '.tsx'], esmExternals: true, // events and stream modify module.exports requireReturnsDefault: 'preferred', }), json(), + alias({ + entries: [ + ...Module.builtinModules.map(m => ({find: m, replacement: 'node:' + m})), + ], + }), nodeResolve({ exportConditions: ['node'], browser: false, @@ -110,29 +108,26 @@ const main = { * @type {import('rollup').RollupOptions} */ const app_entry = { - input: 'src/app/app-entry.cts', + input: 'dist/app/app-entry.cjs', output: { file: 'dist/bundle/app-entry.cjs', format: 'iife', inlineDynamicImports: true, sourcemap: true, + globals: { + 'electron': 'require("electron")', + }, }, plugins: [ replace(replace_options), replace({ - include: ['src/app/app-entry.cts'], + include: ['dist/app/app-entry.cjs'], values: { '__NXAPI_BUNDLE_APP_MAIN__': JSON.stringify('./app-main-bundle.js'), }, preventAssignment: true, }), - typescript({ - noEmit: true, - declaration: false, - }), commonjs({ - // the ".ts" extension is required - extensions: ['.js', '.jsx', '.ts', '.tsx'], esmExternals: true, // events and stream modify module.exports requireReturnsDefault: 'preferred', @@ -146,7 +141,8 @@ const app_entry = { ], external: [ 'electron', - path.resolve(__dirname, 'src/app/app-main-bundle.js'), + path.resolve(__dirname, 'dist/app/app-main-bundle.js'), + path.resolve(__dirname, 'dist/app/main/index.js'), ], watch, }; @@ -155,7 +151,7 @@ const app_entry = { * @type {import('rollup').RollupOptions} */ const app_preload = { - input: 'src/app/preload/index.ts', + input: 'dist/app/preload/index.js', output: { file: 'dist/app/bundle/preload.cjs', format: 'cjs', @@ -163,13 +159,7 @@ const app_preload = { }, plugins: [ replace(replace_options), - typescript({ - noEmit: true, - declaration: false, - }), commonjs({ - // the ".ts" extension is required - extensions: ['.js', '.jsx', '.ts', '.tsx'], esmExternals: true, }), nodeResolve({ @@ -187,20 +177,14 @@ const app_preload = { * @type {import('rollup').RollupOptions} */ const app_preload_webservice = { - input: 'src/app/preload-webservice/index.ts', + input: 'dist/app/preload-webservice/index.js', output: { file: 'dist/app/bundle/preload-webservice.cjs', format: 'cjs', }, plugins: [ replace(replace_options), - typescript({ - noEmit: true, - declaration: false, - }), commonjs({ - // the ".ts" extension is required - extensions: ['.js', '.jsx', '.ts', '.tsx'], esmExternals: true, }), nodeResolve({ @@ -218,7 +202,7 @@ const app_preload_webservice = { * @type {import('rollup').RollupOptions} */ const app_browser = { - input: 'src/app/browser/index.ts', + input: 'dist/app/browser/index.js', output: { dir: 'dist/app/bundle', format: 'es', @@ -238,14 +222,7 @@ const app_browser = { title: 'nxapi', }), replace(replace_options), - typescript({ - outDir: 'dist/app/bundle/ts', - noEmit: true, - declaration: false, - }), commonjs({ - // the ".ts" extension is required - extensions: ['.js', '.jsx', '.ts', '.tsx'], esmExternals: true, }), nodePolyfill(), @@ -255,6 +232,7 @@ const app_browser = { // used when resolving react-native-web. For some reason this causes both versions // to be included in the bundle, so here we explicitly use the CommonJS build. {find: 'react-native', replacement: path.resolve(__dirname, 'node_modules', 'react-native-web', 'dist', 'cjs', 'index.js')}, + {find: 'react-native-web', replacement: path.resolve(__dirname, 'node_modules', 'react-native-web', 'dist', 'cjs', 'index.js')}, // rollup-plugin-polyfill-node doesn't support node: module identifiers {find: /^node:(.+)/, replacement: '$1'}, @@ -268,10 +246,12 @@ const app_browser = { watch, }; +const skip = process.env.BUNDLE_SKIP?.split(',') ?? []; + export default [ - main, - app_entry, - app_preload, - app_preload_webservice, - app_browser, -]; + !skip?.includes('main') && main, + !skip?.includes('app-entry') && app_entry, + !skip?.includes('app-preload') && app_preload, + !skip?.includes('app-preload-webservice') && app_preload_webservice, + !skip?.includes('app-browser') && app_browser, +].filter(c => c); From a7406bd850d340ec72565cdf02ae27942a53b5e5 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 28 Feb 2023 14:08:54 +0000 Subject: [PATCH 4/6] Update SplatNet 3 version --- resources/common/remote-config.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/common/remote-config.json b/resources/common/remote-config.json index e87c0cb..cffe2e0 100644 --- a/resources/common/remote-config.json +++ b/resources/common/remote-config.json @@ -17,8 +17,8 @@ "blanco_version": "2.1.1" }, "coral_gws_splatnet3": { - "app_ver": "2.0.0-bd36a652", - "version": "2.0.0", - "revision": "bd36a652913aa26b132b84df921e07b20f4a414d" + "app_ver": "3.0.0-2857bc50", + "version": "3.0.0", + "revision": "2857bc50653d316cb69f017b2eef24d2ae56a1b7" } } From 9b038c76da9ebe203d1d04763194065cacf869bb Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 28 Feb 2023 14:20:55 +0000 Subject: [PATCH 5/6] Add support for Eggstra Work and Tableturf Battle for Splatoon 3 presence --- src/discord/monitor/splatoon3.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/discord/monitor/splatoon3.ts b/src/discord/monitor/splatoon3.ts index 7fb6b2f..a54a328 100644 --- a/src/discord/monitor/splatoon3.ts +++ b/src/discord/monitor/splatoon3.ts @@ -1,7 +1,7 @@ import createDebug from 'debug'; import persist from 'node-persist'; import DiscordRPC from 'discord-rpc'; -import { BankaraMatchMode, BankaraMatchSetting, CoopSchedule, CoopSchedule_schedule, CoopSetting, DetailVotingStatusResult, FestMatchSetting, FestState, FestTeamRole, FestTeam_schedule, FestTeam_votingStatus, Fest_schedule, FriendListResult, FriendOnlineState, GraphQLSuccessResponse, LeagueMatchSetting, RegularMatchSetting, StageScheduleResult, VsSchedule_bankara, VsSchedule_fest, VsSchedule_league, VsSchedule_regular, VsSchedule_xMatch, XMatchSetting } from 'splatnet3-types/splatnet3'; +import { BankaraMatchMode, BankaraMatchSetting, CoopRule, CoopSchedule_schedule, CoopSetting_schedule, DetailVotingStatusResult, FestMatchSetting, FestTeam_schedule, FestTeam_votingStatus, Fest_schedule, FriendListResult, FriendOnlineState, GraphQLSuccessResponse, LeagueMatchSetting, RegularMatchSetting, StageScheduleResult, VsSchedule_bankara, VsSchedule_fest, VsSchedule_league, VsSchedule_regular, VsSchedule_xMatch, XMatchSetting } from 'splatnet3-types/splatnet3'; import { Game } from '../../api/coral-types.js'; import SplatNet3Api from '../../api/splatnet3.js'; import { DiscordPresenceExternalMonitorsConfiguration } from '../../app/common/types.js'; @@ -35,6 +35,7 @@ export default class SplatNet3Monitor extends EmbeddedLoop { x_schedule: VsSchedule_xMatch | null = null; coop_regular_schedule: CoopSchedule_schedule | null = null; coop_big_run_schedule: CoopSchedule_schedule | null = null; + coop_team_contest_schedule: CoopSchedule_schedule | null = null; fest: Fest_schedule | null = null; fest_team_voting_status: FestTeam_votingStatus | null = null; fest_team: FestTeam_schedule | null = null; @@ -135,6 +136,7 @@ export default class SplatNet3Monitor extends EmbeddedLoop { this.x_schedule = this.getSchedule(this.cached_schedules?.data.xSchedules.nodes ?? []); this.coop_regular_schedule = this.getSchedule(this.cached_schedules?.data.coopGroupingSchedule.regularSchedules.nodes ?? []); this.coop_big_run_schedule = this.getSchedule(this.cached_schedules?.data.coopGroupingSchedule.bigRunSchedules.nodes ?? []); + this.coop_team_contest_schedule = this.getSchedule(this.cached_schedules?.data.coopGroupingSchedule.teamContestSchedules.nodes ?? []); this.fest = this.cached_schedules?.data.currentFest ?? null; // Identify the user by their icon as the vote list doesn't have friend IDs @@ -225,7 +227,7 @@ interface PresenceUrlResponse { splatoon3_vs_setting?: RegularMatchSetting | BankaraMatchSetting | FestMatchSetting | LeagueMatchSetting | XMatchSetting | null; - splatoon3_coop_setting?: CoopSetting | null; + splatoon3_coop_setting?: CoopSetting_schedule | null; splatoon3_fest?: Fest_schedule | null; } @@ -339,9 +341,9 @@ export function callback(activity: DiscordRPC.Presence, game: Game, context?: Di presence_proxy_data && 'splatoon3_coop_setting' in presence_proxy_data ? presence_proxy_data.splatoon3_coop_setting : monitor ? - friend.coopRule === 'BIG_RUN' ? - monitor.coop_big_run_schedule?.setting : - monitor.coop_regular_schedule?.setting : + friend.coopRule === CoopRule.BIG_RUN ? monitor.coop_big_run_schedule?.setting : + friend.coopRule === CoopRule.TEAM_CONTEST ? monitor.coop_team_contest_schedule?.setting : + monitor.coop_regular_schedule?.setting : null; if (coop_setting) { @@ -359,4 +361,8 @@ export function callback(activity: DiscordRPC.Presence, game: Game, context?: Di } } } + + if (friend.onlineState === FriendOnlineState.MINI_GAME_PLAYING) { + activity.details = 'Tableturf Battle'; + } } From ccf0951df58ac1e8f6857ca036321eec01954626 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 28 Feb 2023 14:38:50 +0000 Subject: [PATCH 6/6] Update Discord titles https://github.com/samuelthomas2774/nxapi/issues/55 --- src/discord/titles/index.ts | 1 + src/discord/titles/thatgamecompany.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/discord/titles/thatgamecompany.ts diff --git a/src/discord/titles/index.ts b/src/discord/titles/index.ts index e4bb8f9..ceb82a5 100644 --- a/src/discord/titles/index.ts +++ b/src/discord/titles/index.ts @@ -2,3 +2,4 @@ export * as nintendo from './nintendo.js'; export * as mojang from './mojang.js'; export * as capcom from './capcom.js'; export * as the_pokemon_company from './the-pokémon-company.js'; +export * as thatgamecompany from './thatgamecompany.js'; diff --git a/src/discord/titles/thatgamecompany.ts b/src/discord/titles/thatgamecompany.ts new file mode 100644 index 0000000..e731a39 --- /dev/null +++ b/src/discord/titles/thatgamecompany.ts @@ -0,0 +1,11 @@ +import { Title } from '../types.js'; + +export const titles: Title[] = [ + { + // Sky: Children of the Light + id: '0100c52011460000', + client: '1080136394288144465', + showPlayingOnline: true, + showActiveEvent: true, + }, +];