From 0c013eb1af1ef082d24d70f5d58e0f86d2c0c93c Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Thu, 9 Jan 2025 13:10:53 -0700 Subject: [PATCH] \i-ification --- package.json | 2 +- pnpm-lock.yaml | 12 ++++++------ src/allActivities/index.ts | 8 ++++---- src/chatTweaks/index.ts | 18 +++++++++--------- src/mediaTweaks/index.ts | 18 +++++++++--------- src/noRpc/index.ts | 2 +- src/platformIcons/index.ts | 22 +++++++++++----------- src/platformStyles/index.ts | 8 ++++---- src/unminifyReactErrors/index.ts | 15 ++++++++------- 9 files changed, 53 insertions(+), 52 deletions(-) diff --git a/package.json b/package.json index 3dfe1a4..61c38ff 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@moonlight-mod/eslint-config": "github:moonlight-mod/eslint-config", "esbuild": "^0.19.3", "esbuild-copy-static-files": "^0.1.0", - "eslint": "^9.12.0", + "eslint": "^9.17.0", "typescript": "^5.3.2" }, "dependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2f8ebc..5c4151b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,7 +20,7 @@ importers: version: https://codeload.github.com/moonlight-mod/esbuild-config/tar.gz/af3684e88df8d8b0c205c22bdfdd1cc3d1f80685(esbuild@0.19.3) '@moonlight-mod/eslint-config': specifier: github:moonlight-mod/eslint-config - version: https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/7eb7bd7c51fe0e3ee9d2a0baf149212d2bb893af(eslint@9.17.0)(prettier@3.4.2)(typescript@5.7.2) + version: https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/e262ac24e1a0955a9b3e0d66da247a0a8c0446c9(eslint@9.17.0)(prettier@3.4.2)(typescript@5.7.2) esbuild: specifier: ^0.19.3 version: 0.19.3 @@ -28,7 +28,7 @@ importers: specifier: ^0.1.0 version: 0.1.0 eslint: - specifier: ^9.12.0 + specifier: ^9.17.0 version: 9.17.0 typescript: specifier: ^5.3.2 @@ -233,9 +233,9 @@ packages: peerDependencies: esbuild: '>= 0.19' - '@moonlight-mod/eslint-config@https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/7eb7bd7c51fe0e3ee9d2a0baf149212d2bb893af': - resolution: {tarball: https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/7eb7bd7c51fe0e3ee9d2a0baf149212d2bb893af} - version: 1.0.0 + '@moonlight-mod/eslint-config@https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/e262ac24e1a0955a9b3e0d66da247a0a8c0446c9': + resolution: {tarball: https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/e262ac24e1a0955a9b3e0d66da247a0a8c0446c9} + version: 1.0.1 peerDependencies: eslint: '>= 9' typescript: '>= 5.3' @@ -1357,7 +1357,7 @@ snapshots: dependencies: esbuild: 0.19.3 - '@moonlight-mod/eslint-config@https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/7eb7bd7c51fe0e3ee9d2a0baf149212d2bb893af(eslint@9.17.0)(prettier@3.4.2)(typescript@5.7.2)': + '@moonlight-mod/eslint-config@https://codeload.github.com/moonlight-mod/eslint-config/tar.gz/e262ac24e1a0955a9b3e0d66da247a0a8c0446c9(eslint@9.17.0)(prettier@3.4.2)(typescript@5.7.2)': dependencies: '@eslint/js': 9.17.0 eslint: 9.17.0 diff --git a/src/allActivities/index.ts b/src/allActivities/index.ts index c9535a6..03490e9 100644 --- a/src/allActivities/index.ts +++ b/src/allActivities/index.ts @@ -5,7 +5,7 @@ export const patches: Patch[] = [ { find: '"UserProfileFeaturedActivity"', replace: { - match: /:function\(\){return (.)}/, + match: /:function\(\){return (\i)}/, replacement: ':function(){return require("allActivities_activities").default}' } }, @@ -14,7 +14,7 @@ export const patches: Patch[] = [ { find: '.STREAM_PREVIEW="StreamPreview"', replace: { - match: /\(null==.\?void 0:.\.type\)!==.\.[a-zA-Z_$][\w$]*\.PLAYING&&/, + match: /\(null==\i\?void 0:\i\.type\)!==\i\.\i\.PLAYING&&/, replacement: (orig: string) => orig + orig.replace("PLAYING", "COMPETING") } }, @@ -23,7 +23,7 @@ export const patches: Patch[] = [ { find: '("use-user-profile-activity")', replace: { - match: /\(0,.\.uniqWith\)/, + match: /\(0,\i\.uniqWith\)/, replacement: "((inp)=>inp)" } }, @@ -32,7 +32,7 @@ export const patches: Patch[] = [ { find: ".lostPermission", replace: { - match: /name:null==.\?(\(0,.\.jsx\))\("span"/, + match: /name:null==\i\?(\(0,\i\.jsx\))\("span"/, replacement: (orig, createElement) => `children:${createElement}(require("allActivities_icons").default,{user:arguments[0].user}),${orig}` }, diff --git a/src/chatTweaks/index.ts b/src/chatTweaks/index.ts index 655a201..dc5c9a3 100644 --- a/src/chatTweaks/index.ts +++ b/src/chatTweaks/index.ts @@ -7,7 +7,7 @@ export const patches: Patch[] = [ { find: ',source:"message-actions"})', replace: { - match: /,message:(.),shouldMention:(!(.)\.shiftKey&&!(.)),/, + match: /,message:(\i),shouldMention:(!(\i)\.shiftKey&&!(\i)),/, replacement: (_, message, shouldMention, keyEvent, self) => `,message:${message},shouldMention:require("chatTweaks_noReplyPing")?.default?.(${message},${keyEvent},${self})??(${shouldMention}),` } @@ -17,7 +17,7 @@ export const patches: Patch[] = [ { find: ",replyChainLength:", replace: { - match: /=(.\.showThreadPromptOnReply)&&/, + match: /=(\i\.showThreadPromptOnReply)&&/, replacement: (_, showThreadPromptOnReply) => `=(moonlight.getConfigOption("chatTweaks","noReplyChainNag")??true?false:${showThreadPromptOnReply})&&` } @@ -37,7 +37,7 @@ export const patches: Patch[] = [ { find: ".BOT:default:", replace: { - match: /case .\..{1,3}\.BOT:default:(.)=/, + match: /case \i\.\i\.BOT:default:(\i)=/, replacement: (orig, tag) => `case 99:${tag}="WEBHOOK";break;${orig}` }, prerequisite: webhookTag @@ -45,7 +45,7 @@ export const patches: Patch[] = [ { find: ".Types.ORIGINAL_POSTER", replace: { - match: /(.)=.\.Z\.Types\.ORIGINAL_POSTER\),/, + match: /(\i)=\i\.\i\.Types\.ORIGINAL_POSTER\),/, replacement: (orig, type) => `${orig}(arguments[0].user?.bot&&arguments[0].message?.webhookId&&arguments[0].user?.isNonUserBot?.()&&(${type}=99)),` }, @@ -56,8 +56,8 @@ export const patches: Patch[] = [ { find: '("interactionAvatarProfile",', replace: { - match: /&&\(.\?.\.Z.show\({.+?:(.)\.Z.jumpToMessage/, - replacement: (_, mod) => `&&(${mod}.Z.jumpToMessage` + match: /&&\(\i\?\i\.\i.show\({.+?:(\i\.\i).jumpToMessage/, + replacement: (_, mod) => `&&(${mod}.jumpToMessage` }, prerequisite: () => moonlight.getConfigOption("chatTweaks", "jumpToBlocked") ?? true }, @@ -66,7 +66,7 @@ export const patches: Patch[] = [ { find: 'key:"pending-upload-".concat(', replace: { - match: /if\((.)\.type===(.\..{1,3})\.MESSAGE_GROUP_BLOCKED\|\|/, + match: /if\((\i)\.type===(\i\.\i)\.MESSAGE_GROUP_BLOCKED\|\|/, replacement: (orig, message, types) => `if(${message}.type===${types}.MESSAGE_GROUP_BLOCKED&&(moonlight.getConfigOption("chatTweaks","hideBlocked")??false))return;if(${message}.type===${types}.MESSAGE_GROUP_IGNORED&&(moonlight.getConfigOption("chatTweaks","hideIgnored")??false))return;${orig}` } @@ -76,7 +76,7 @@ export const patches: Patch[] = [ { find: ".lostPermission", replace: { - match: /=>null!=(.)&&.&&null==/, + match: /=>null!=(\i)&&\i&&null==/, replacement: (_, isOwner) => `=>null!=(${isOwner}=require("chatTweaks_ownerCrown").default(arguments[0]))&&${isOwner}&&null==` } @@ -86,7 +86,7 @@ export const patches: Patch[] = [ { find: '.insertText("](".concat', replace: { - match: /if\((null!=.&&null==.)\){/, + match: /if\((null!=\i&&null==\i)\){/, replacement: (_, linkCheck) => `if((moonlight.getConfigOption("chatTweaks","noMaskedLinkPaste")??true)?false:${linkCheck}){` } diff --git a/src/mediaTweaks/index.ts b/src/mediaTweaks/index.ts index 488c716..78a9d22 100644 --- a/src/mediaTweaks/index.ts +++ b/src/mediaTweaks/index.ts @@ -5,7 +5,7 @@ export const patches: Patch[] = [ { find: "allowLinks:!!", replace: { - match: /,(\(null!=.\?.:.\)\.embeds\)\),)/, + match: /,(\(null!=\i\?\i:\i\)\.embeds\)\),)/, replacement: (_, orig) => `,moonlight.getConfigOption("mediaTweaks","imageUrls")??true?{}:${orig}` } }, @@ -14,7 +14,7 @@ export const patches: Patch[] = [ { find: ".TOGGLE_GIF_PICKER,handler:", replace: { - match: /[A-Za-z_$][\w$]*===[A-Za-z_$][\w$]*\.[A-Za-z_$][\w$]*\.CREATE_FORUM_POST/, + match: /\i===\i\.\i\.CREATE_FORUM_POST/, replacement: (orig: string) => `(moonlight.getConfigOption("mediaTweaks","noGifAutosend")??true?true:${orig})` } }, @@ -24,7 +24,7 @@ export const patches: Patch[] = [ find: "renderMetadata()", replace: { match: - /(?<=(.===.\.VIDEO)\?.+?(\(0,.\.jsx\))\("div",{className:(.+?\.overlayContentHidden]:).\|\|.\}\),children:.\(\)}\):null)]/, + /(?<=(\i===\i\.VIDEO)\?.+?(\(0,\i\.jsx\))\("div",{className:(.+?\.overlayContentHidden]:)\i\|\|\i\}\),children:\i\(\)}\):null)]/, replacement: (_, videoCheck, createElement, className) => `,${videoCheck}&&(moonlight.getConfigOption("mediaTweaks","videoMetadata")??true)?${createElement}("div",{className:${className}this.state.playing&&!this.state.hovering}),children:${createElement}(require("mediaTweaks_videoMetadata").default,this.props)}):null]` } @@ -34,7 +34,7 @@ export const patches: Patch[] = [ { find: 'location:"MessageAccessories"', replace: { - match: /=(\(0,.\..{1,2}\))\((.),({shouldRedactExplicitContent:.,shouldHideMediaOptions:.}),("Media Mosaic")\),/, + match: /=(\(0,\i\.\i\))\((\i),({shouldRedactExplicitContent:\i,shouldHideMediaOptions:\i}),("Media Mosaic")\),/, replacement: (_, createCarousel, attachments, props, analytics) => `=${createCarousel}((moonlight.getConfigOption("mediaTweaks","inlineMosaicPlayback")??true)?${attachments}.filter(x=>x.type!="VIDEO"):${attachments},${props},${analytics}),` } @@ -48,14 +48,14 @@ export const patches: Patch[] = [ replace: [ // Send the full item over { - match: /,downloadURL:(.)\.downloadUrl,/, + match: /,downloadURL:(\i)\.downloadUrl,/, replacement: (orig, item) => `,item:${item}${orig}` }, // Add button { match: - /(?<=isVisualMediaType:.,channelId:.+?}=(.);.+?"MosaicItemHoverButtons"\);)(?=.&&null!=.&&(.)\.push\((\(0,.\.jsx\)))/, + /(?<=isVisualMediaType:\i,channelId:.+?}=(\i);.+?"MosaicItemHoverButtons"\);)(?=\i&&null!=\i&&(\i)\.push\((\(0,\i\.jsx\)))/, replacement: (_, props, buttons, createElement) => `${buttons}.push(${createElement}(require("mediaTweaks_enlargeVideoButton").default,${props},"mediaTweaks_enlargeVideoButton"));` } @@ -72,9 +72,9 @@ export const patches: Patch[] = [ // No WebP and No Thumbnail Size { - find: /\(.{1,2}\+="\?"\+.{1,2}\.stringify\(.{1,2}\)\)/, + find: /\(\i\+="\?"\+\i\.stringify\(\i\)\)/, replace: { - match: /if\((.)\.sourceWidth<.\.targetWidth\){/, + match: /if\((\i)\.sourceWidth<.\.targetWidth\){/, replacement: (orig, props) => `require("mediaTweaks_imagePropsProcessor").default(${props});${orig}` } }, @@ -83,7 +83,7 @@ export const patches: Patch[] = [ { find: ',"chat input type must be set");', replace: { - match: /(?<=!.&&\()(\(0,.\..{1,2}\)\(.+?\.drafts\.type\))\?/, + match: /(?<=!\i&&\()(\(0,\i\.\i\)\(.+?\.drafts\.type\))\?/, replacement: (_, orig) => `((moonlight.getConfigOption("mediaTweaks","noStickerAutosend")??true)?true:${orig})?` } } diff --git a/src/noRpc/index.ts b/src/noRpc/index.ts index 3d93ae1..d16b082 100644 --- a/src/noRpc/index.ts +++ b/src/noRpc/index.ts @@ -19,7 +19,7 @@ export const patches: Patch[] = [ find: '"RunningGameStore"', replace: [ { - match: /.\.[a-zA-Z]+\.dispatch(\({type:"RUNNING_GAMES_CHANGE",games:.,added:.,removed:.}\))/, + match: /\i\.\i\.dispatch(\({type:"RUNNING_GAMES_CHANGE",games:\i,added:\i,removed:\i}\))/, // this isn't just a removal because haha removing breaks quietLoggers // and i dont feel like fixing (nor should i even have to fix, if you // pretend that im just a standard extension dev in this scenario) diff --git a/src/platformIcons/index.ts b/src/platformIcons/index.ts index aefb5e5..b94183e 100644 --- a/src/platformIcons/index.ts +++ b/src/platformIcons/index.ts @@ -8,7 +8,7 @@ export const patches: Patch[] = [ { find: '},"new-member")),', replace: { - match: /(?<=(\(0,.\.jsx\)).+?)\.BADGES]=(.);/, + match: /(?<=(\(0,\i\.jsx\)).+?)\.BADGES]=(.);/, replacement: (_, createElement, badges) => `.BADGES]=[${createElement}(require("platformIcons_icons").default,{user:arguments[0].message.author,configKey:"messages",extraClasses:["platform-icons-message"],size:"sm"}),...${badges}];` } @@ -19,7 +19,7 @@ export const patches: Patch[] = [ { find: ".lostPermission", replace: { - match: /(\(0,.\.jsxs\))\(.\.Fragment,{children:\[.{1,2}\(\),/, + match: /(\(0,\i\.jsxs\))\(\i\.Fragment,{children:\[\i\(\),/, replacement: (orig: string, createElement) => `${orig}${createElement}(require("platformIcons_icons").default,{user:arguments[0].user,configKey:"memberList",extraClasses:["platform-icons-member-list"]}),` } @@ -30,7 +30,7 @@ export const patches: Patch[] = [ { find: ".interactiveSystemDM]:", replace: { - match: /decorators:(.\.isSystemDM\(\)\?(\(0,.\.jsx\))\(.+?verified:!0}\):null)/, + match: /decorators:(\i\.isSystemDM\(\)\?(\(0,\i\.jsx\))\(.+?verified:!0}\):null)/, replacement: (_, orig, createElement) => `decorators:[${orig},${createElement}(require("platformIcons_icons").default,{user:arguments[0].user,configKey:"directMessages",extraClasses:["platform-icons-private-message"]})]` } @@ -41,7 +41,7 @@ export const patches: Patch[] = [ { find: ".userTagDiscriminator,hideBotTag:!0", replace: { - match: /,(\(0,.\.jsx\))\(.\.ZP,{userId:(.)\.id,.+?(.)\.clanTag}\),/, + match: /,(\(0,\i\.jsx\))\(\i\.\i,{userId:(\i)\.id,.+?(\i)\.clanTag}\),/, replacement: (orig: string, createElement, user, ProfileClasses) => `${orig}${createElement}(require("platformIcons_icons").default,{user:${user},configKey:"profiles",extraClasses:["platform-icons-profile", ${ProfileClasses}.clanTagContainer, ${ProfileClasses}.clanTag]}),` } @@ -51,7 +51,7 @@ export const patches: Patch[] = [ { find: ".listCollapse", replace: { - match: /(?<=(\(0,.\.jsxs\))\("div",{className:.\.iconGroup,onMouseEnter:.+?\(!1\)),children:\[/, + match: /(?<=(\(0,\i\.jsxs\))\("div",{className:\i\.iconGroup,onMouseEnter:.+?\(!1\)),children:\[/, replacement: (_, createElement) => `,children:[${createElement}(require("platformIcons_voice").default,arguments[0]),` } @@ -61,7 +61,7 @@ export const patches: Patch[] = [ { find: '"PresenceStore"', replace: { - match: /(?<=return null!=.&&.\[.\..{1,3}\.MOBILE\])===.\..{1,3}\.ONLINE/, + match: /(?<=return null!=\i&&\i\[\i\.\i\.MOBILE\])===\i\.\i\.ONLINE/, replacement: "!=null" }, prerequisite: alwaysShowMobile @@ -70,15 +70,15 @@ export const patches: Patch[] = [ find: '"getMaskId(): Unsupported type, size: "', replace: [ { - match: /&&.===.\..{1,3}\.ONLINE/, + match: /&&\i===\i\.\i\.ONLINE/, replacement: "" }, { - match: /\|\|.===.\..{1,3}\.ONLINE&&/, + match: /\|\|\i===\i\.\i\.ONLINE&&/, replacement: "&&" }, { - match: /if\(.===.\..{1,3}\.ONLINE&&/, + match: /if\(\i===\i\.\i\.ONLINE&&/, replacement: "if(" } ], @@ -88,12 +88,12 @@ export const patches: Patch[] = [ find: ')("useStatusFillColor")', replace: [ { - match: /(?<=\.STATUS_TYPING;)(switch.+?default:)(if\(.\)return .\.ZP\.Masks\.STATUS_ONLINE_MOBILE;)/, + match: /(?<=\.STATUS_TYPING;)(switch.+?default:)(if\(\i\)return \i\.\i\.Masks\.STATUS_ONLINE_MOBILE;)/, replacement: (_, body, mobileCheck) => `${mobileCheck}${body}` }, { // why is this check there twice, are they stupid? - match: /.===.\..{1,3}\.ONLINE&&/g, + match: /\i===\i\.\i\.ONLINE&&/g, replacement: "" } ], diff --git a/src/platformStyles/index.ts b/src/platformStyles/index.ts index 0a5a3db..0ee7b52 100644 --- a/src/platformStyles/index.ts +++ b/src/platformStyles/index.ts @@ -3,9 +3,9 @@ import { PlatformStyle, PlatformUtils } from "./types"; export const patches: Patch[] = [ { - find: /switch\((.{1,2})\){case (.{1,2})\.PlatformTypes\.WINDOWS:/g, + find: ".window.USE_OSX_NATIVE_TRAFFIC_LIGHTS", replace: { - match: /switch\((.{1,2})\){case (.{1,2})\.PlatformTypes\.WINDOWS:/, + match: /switch\((\i)\){case (\i)\.PlatformTypes\.WINDOWS:/, replacement: (_, platformType, platformUtils) => `${platformType}=require("platformStyles_helper").platformBorders(${platformUtils});switch(${platformType}){case ${platformUtils}.PlatformTypes.WINDOWS:` } @@ -13,7 +13,7 @@ export const patches: Patch[] = [ { find: '" platform-overlay"', replace: { - match: /(.)="platform-web"\),/, + match: /(\i)="platform-web"\),/, replacement: (orig, className) => `${orig}(${className}=require("platformStyles_helper").platformClass()??${className}),` } @@ -21,7 +21,7 @@ export const patches: Patch[] = [ { find: ".ensureIsInPosition=", replace: { - match: /(.{1,2})=.{1,2}!==(.{1,2})\.PlatformTypes\.WEB&&this\.inPopout\?22:0;/, + match: /(\i)=\i!==(\i)\.PlatformTypes\.WEB&&this\.inPopout\?22:0;/, replacement: (_, pipOffset, platformUtil) => `${pipOffset}=require("platformStyles_helper").platformBorders(${platformUtil})!==${platformUtil}.PlatformTypes.WEB&&this.inPopout?22:0;` } diff --git a/src/unminifyReactErrors/index.ts b/src/unminifyReactErrors/index.ts index 3025ad6..bc7940b 100644 --- a/src/unminifyReactErrors/index.ts +++ b/src/unminifyReactErrors/index.ts @@ -1,10 +1,9 @@ import { Patch, ExtensionWebpackModule } from "@moonlight-mod/types"; -// @ts-expect-error import ERROR_CODES from "./codes.json"; const ERROR_MATCH = - /function (.)\(.\){for\(var .="https:\/\/reactjs\.org\/docs\/error-decoder\.html\?invariant="\+.,.=1;. = { run: function (module, exports, require) { module.exports = function unminify(code: string, ...args: any[]) { let index = 0; - return ERROR_CODES[code].replace(/%s/g, () => { - const arg = args[index]; - index++; - return arg; - }); + return ( + (ERROR_CODES as Record)[code]?.replace(/%s/g, () => { + const arg = args[index]; + index++; + return arg; + }) ?? `` + ); }; } }