diff --git a/Program.cs b/Program.cs index 263ac211..d92f8fc7 100644 --- a/Program.cs +++ b/Program.cs @@ -31,7 +31,6 @@ static class Program { public static readonly bool IsPortable = File.Exists(Path.Combine(ProgramPath, "makeportable")); - public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts"); public static readonly string ResourcesPath = Path.Combine(ProgramPath, "resources"); public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins"); diff --git a/Resources/Plugins/clear-columns/browser.js b/Resources/Plugins/clear-columns/browser.js index 645e7fa0..7fb3328e 100644 --- a/Resources/Plugins/clear-columns/browser.js +++ b/Resources/Plugins/clear-columns/browser.js @@ -49,7 +49,9 @@ enabled(){ }; this.eventKeyDown = function(e){ - return if !(document.activeElement === null || document.activeElement === document.body); + if (!(document.activeElement === null || document.activeElement === document.body)) { + return; + } updateShiftState(e.shiftKey); diff --git a/Resources/Plugins/edit-design/browser.js b/Resources/Plugins/edit-design/browser.js index 0ab65a71..16ec6136 100644 --- a/Resources/Plugins/edit-design/browser.js +++ b/Resources/Plugins/edit-design/browser.js @@ -106,14 +106,20 @@ enabled(){ // settings click event this.onSettingsMenuClickedEvent = () => { - return if this.config === null; + if (this.config === null) { + return; + } setTimeout(() => { let menu = $(".js-dropdown-content").children("ul").first(); - return if menu.length === 0; + if (menu.length === 0) { + return; + } let itemTD = menu.children("[data-tweetduck]").first(); - return if itemTD.length === 0; + if (itemTD.length === 0) { + return; + } if (!itemTD.prev().hasClass("drp-h-divider")){ itemTD.before('<li class="drp-h-divider"></li>'); @@ -648,7 +654,9 @@ ${notificationScrollbarColor ? ` }; this.uiDrawerActiveEvent = (e, data) => { - return if data.activeDrawer === null || this.config.composerWidth === "default"; + if (data.activeDrawer === null || this.config.composerWidth === "default") { + return; + } const ele = $(".js-app-content").addClass("tduck-is-opening"); setTimeout(() => ele.removeClass("tduck-is-opening"), 250); diff --git a/Resources/Plugins/emoji-keyboard/browser.js b/Resources/Plugins/emoji-keyboard/browser.js index d5c2696d..79470660 100644 --- a/Resources/Plugins/emoji-keyboard/browser.js +++ b/Resources/Plugins/emoji-keyboard/browser.js @@ -305,13 +305,19 @@ enabled(){ let val = ele.val(); let firstColon = val.lastIndexOf(':', ele[0].selectionStart); - return if firstColon === -1; + if (firstColon === -1) { + return; + } let search = val.substring(firstColon+1, ele[0].selectionStart).toLowerCase(); - return if !/^[a-z_]+$/.test(search); + if (!/^[a-z_]+$/.test(search)) { + return; + } let keywords = search.split("_").filter(kw => kw.length > 0).map(kw => kw.toLowerCase()); - return if keywords.length === 0; + if (keywords.length === 0) { + return; + } let foundNames = me.emojiNames.filter(name => keywords.every(kw => name.includes(kw))); diff --git a/Resources/Plugins/reply-account/browser.js b/Resources/Plugins/reply-account/browser.js index 8c0f5c77..e33853f8 100644 --- a/Resources/Plugins/reply-account/browser.js +++ b/Resources/Plugins/reply-account/browser.js @@ -6,7 +6,9 @@ enabled(){ this.lastSelectedAccount = null; this.uiComposeTweetEvent = (e, data) => { - return if !(data.type === "reply" || (data.type === "tweet" && "quotedTweet" in data)) || data.popFromInline || !("element" in data); + if (!(data.type === "reply" || (data.type === "tweet" && "quotedTweet" in data)) || data.popFromInline || !("element" in data)) { + return; + } let query; @@ -96,7 +98,9 @@ enabled(){ break; case "#last": - return if this.lastSelectedAccount === null; + if (this.lastSelectedAccount === null) { + return; + } identifier = this.lastSelectedAccount; break; diff --git a/Resources/Plugins/templates/browser.js b/Resources/Plugins/templates/browser.js index b9dd3cd7..5affe0f5 100644 --- a/Resources/Plugins/templates/browser.js +++ b/Resources/Plugins/templates/browser.js @@ -148,7 +148,9 @@ enabled(){ const useTemplate = (contents, append) => { let ele = $(".js-compose-text"); - return if ele.length === 0; + if (ele.length === 0) { + return; + } let value = append ? ele.val()+contents : contents; let prevLength = value.length; diff --git a/Resources/PostBuild.fsx b/Resources/PostBuild.fsx index f5ac2a2a..220ab94c 100644 --- a/Resources/PostBuild.fsx +++ b/Resources/PostBuild.fsx @@ -2,7 +2,6 @@ open System open System.Collections.Generic open System.Diagnostics open System.IO -open System.Text.RegularExpressions open System.Threading.Tasks // "$(DevEnvDir)CommonExtensions\Microsoft\FSharp\fsi.exe" "$(ProjectDir)Resources\PostBuild.fsx" --exec --nologo -- "$(TargetDir)\" "$(ProjectDir)\" "$(ConfigurationName)" @@ -49,27 +48,9 @@ let main (argv: string[]) = printfn "--------------------------" let localesDir = targetDir +/ "locales" - let scriptsDir = targetDir +/ "scripts" let resourcesDir = targetDir +/ "resources" let pluginsDir = targetDir +/ "plugins" - // Functions (Strings) - - let filterNotEmpty = - Seq.filter (not << String.IsNullOrEmpty) - - let replaceRegex (pattern: string) (replacement: string) input = - Regex.Replace(input, pattern, replacement) - - let collapseLines separator (sequence: string seq) = - String.Join(separator, sequence) - - let splitLines (separator: char) (str: string) = - str.Split(separator) |> Seq.ofArray - - let trimStart (line: string) = - line.TrimStart() - // Functions (File Management) let copyFile source target = @@ -122,10 +103,7 @@ let main (argv: string[]) = let writeFile (fullPath: string) (lines: string seq) = let relativePath = fullPath.[(targetDir.Length)..] - let includeVersion = relativePath.StartsWith(@"scripts\") - let finalLines = if includeVersion then seq { yield "#" + version; yield! lines } else lines - - File.WriteAllLines(fullPath, finalLines |> Seq.toArray) + File.WriteAllLines(fullPath, lines |> Seq.toArray) printfn "Processed %s" relativePath let processFiles (files: string seq) (extProcessors: IDictionary<string, (string seq -> string seq)>) = @@ -142,7 +120,6 @@ let main (argv: string[]) = copyFile (projectDir +/ "bld/Resources/LICENSES.txt") (targetDir +/ "LICENSES.txt") - copyDirectoryContents (projectDir +/ "Resources/Scripts") scriptsDir copyDirectoryContents (projectDir +/ "Resources/Content") resourcesDir createDirectory (pluginsDir +/ "official") @@ -161,7 +138,7 @@ let main (argv: string[]) = if Directory.Exists(localesDir) || configuration = "Release" then Directory.EnumerateFiles(localesDir, "*.pak") |> exceptEndingWith @"\en-US.pak" - |> Seq.iter (File.Delete) + |> Seq.iter File.Delete // Validation @@ -174,41 +151,16 @@ let main (argv: string[]) = let fileProcessors = dict [ - ".js", (fun (lines: string seq) -> - lines - |> Seq.map (fun line -> - line - |> replaceRegex @"^(.*?)((?<=^|[;{}()])\s?//(?:\s.*|$))?$" "$1" - |> replaceRegex @"(?<!\w)(return|throw)(\s.*?)? if (.*?);" "if ($3)$1$2;" - ) - ); - - ".css", (fun (lines: string seq) -> - lines - |> Seq.map (fun line -> - line - |> replaceRegex @"\s*/\*.*?\*/" "" - |> replaceRegex @"^(\S.*) {$" "$1 { " - |> replaceRegex @"^\s+(.+?):\s*(.+?)(?:\s*(!important))?;$" "$1:$2$3;" - ) - |> filterNotEmpty - |> collapseLines " " - |> replaceRegex @"([{};])\s" "$1" - |> replaceRegex @";?}" " }\n" - |> splitLines '\n' - ); - - ".html", (fun (lines: string seq) -> - lines - ); - + ".js", id; + ".css", id; + ".html", id; ".meta", (fun (lines: string seq) -> lines |> Seq.map (fun line -> line.Replace("{version}", version)) ); ] - processFiles ((byPattern targetDir "*.js") |> exceptEndingWith @"\configuration.default.js") fileProcessors + processFiles (byPattern targetDir "*.js") fileProcessors processFiles (byPattern targetDir "*.css") fileProcessors processFiles (byPattern targetDir "*.html") fileProcessors processFiles (byPattern pluginsDir "*.meta") fileProcessors diff --git a/Resources/ScriptLoaderDebug.cs b/Resources/ScriptLoaderDebug.cs index 56046aa9..b16dfc3b 100644 --- a/Resources/ScriptLoaderDebug.cs +++ b/Resources/ScriptLoaderDebug.cs @@ -33,7 +33,7 @@ public override void OnReloadTriggered() { protected override string LocateFile(string path) { if (Directory.Exists(HotSwapTargetDir)) { Debug.WriteLine($"Hot swap active, redirecting {path}"); - return Path.Combine(HotSwapTargetDir, "scripts", path); + return Path.Combine(HotSwapTargetDir, "resources", path); } return base.LocateFile(path); diff --git a/TweetDuck.csproj b/TweetDuck.csproj index b2dc312b..34d6cd06 100644 --- a/TweetDuck.csproj +++ b/TweetDuck.csproj @@ -468,9 +468,6 @@ <Content Include="Resources\Content\update\update.js" /> <Content Include="Resources\Content\update\update.css" /> </ItemGroup> - <ItemGroup> - <Folder Include="Resources\Scripts" /> - </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>rmdir "$(ProjectDir)bin\Debug" diff --git a/bld/gen_full.iss b/bld/gen_full.iss index a806b199..32bd8d89 100644 --- a/bld/gen_full.iss +++ b/bld/gen_full.iss @@ -57,7 +57,6 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang Type: files; Name: "{app}\*.*" Type: filesandordirs; Name: "{app}\resources" Type: filesandordirs; Name: "{app}\locales" -Type: filesandordirs; Name: "{app}\scripts" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache" diff --git a/bld/gen_upd.iss b/bld/gen_upd.iss index a845b5ad..86cd783b 100644 --- a/bld/gen_upd.iss +++ b/bld/gen_upd.iss @@ -47,7 +47,6 @@ Source: "..\bin\x86\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignorever Source: "..\bin\x86\Release\TweetDuck.*"; DestDir: "{app}"; Flags: ignoreversion Source: "..\bin\x86\Release\TweetLib.*"; DestDir: "{app}"; Flags: ignoreversion Source: "..\bin\x86\Release\resources\*.*"; DestDir: "{app}\resources"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "..\bin\x86\Release\scripts\*.*"; DestDir: "{app}\scripts"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\bin\x86\Release\plugins\*.*"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs createallsubdirs [Icons] @@ -60,7 +59,6 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang Type: files; Name: "{app}\*.*" Type: filesandordirs; Name: "{app}\locales" Type: filesandordirs; Name: "{app}\resources" -Type: filesandordirs; Name: "{app}\scripts" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"