1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-30 05:34:06 +02:00

Remove "scripts" folder and JS/CSS minification

This commit is contained in:
chylex 2021-12-23 16:21:13 +01:00
parent 6a421292b3
commit c91f1d0e5e
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
11 changed files with 40 additions and 73 deletions

View File

@ -31,7 +31,6 @@ static class Program {
public static readonly bool IsPortable = File.Exists(Path.Combine(ProgramPath, "makeportable")); 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 ResourcesPath = Path.Combine(ProgramPath, "resources");
public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins"); public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins");

View File

@ -49,7 +49,9 @@ enabled(){
}; };
this.eventKeyDown = function(e){ 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); updateShiftState(e.shiftKey);

View File

@ -106,14 +106,20 @@ enabled(){
// settings click event // settings click event
this.onSettingsMenuClickedEvent = () => { this.onSettingsMenuClickedEvent = () => {
return if this.config === null; if (this.config === null) {
return;
}
setTimeout(() => { setTimeout(() => {
let menu = $(".js-dropdown-content").children("ul").first(); 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(); let itemTD = menu.children("[data-tweetduck]").first();
return if itemTD.length === 0; if (itemTD.length === 0) {
return;
}
if (!itemTD.prev().hasClass("drp-h-divider")){ if (!itemTD.prev().hasClass("drp-h-divider")){
itemTD.before('<li class="drp-h-divider"></li>'); itemTD.before('<li class="drp-h-divider"></li>');
@ -648,7 +654,9 @@ ${notificationScrollbarColor ? `
}; };
this.uiDrawerActiveEvent = (e, data) => { 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"); const ele = $(".js-app-content").addClass("tduck-is-opening");
setTimeout(() => ele.removeClass("tduck-is-opening"), 250); setTimeout(() => ele.removeClass("tduck-is-opening"), 250);

View File

@ -305,13 +305,19 @@ enabled(){
let val = ele.val(); let val = ele.val();
let firstColon = val.lastIndexOf(':', ele[0].selectionStart); 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(); 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()); 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))); let foundNames = me.emojiNames.filter(name => keywords.every(kw => name.includes(kw)));

View File

@ -6,7 +6,9 @@ enabled(){
this.lastSelectedAccount = null; this.lastSelectedAccount = null;
this.uiComposeTweetEvent = (e, data) => { 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; let query;
@ -96,7 +98,9 @@ enabled(){
break; break;
case "#last": case "#last":
return if this.lastSelectedAccount === null; if (this.lastSelectedAccount === null) {
return;
}
identifier = this.lastSelectedAccount; identifier = this.lastSelectedAccount;
break; break;

View File

@ -148,7 +148,9 @@ enabled(){
const useTemplate = (contents, append) => { const useTemplate = (contents, append) => {
let ele = $(".js-compose-text"); let ele = $(".js-compose-text");
return if ele.length === 0; if (ele.length === 0) {
return;
}
let value = append ? ele.val()+contents : contents; let value = append ? ele.val()+contents : contents;
let prevLength = value.length; let prevLength = value.length;

View File

@ -2,7 +2,6 @@ open System
open System.Collections.Generic open System.Collections.Generic
open System.Diagnostics open System.Diagnostics
open System.IO open System.IO
open System.Text.RegularExpressions
open System.Threading.Tasks open System.Threading.Tasks
// "$(DevEnvDir)CommonExtensions\Microsoft\FSharp\fsi.exe" "$(ProjectDir)Resources\PostBuild.fsx" --exec --nologo -- "$(TargetDir)\" "$(ProjectDir)\" "$(ConfigurationName)" // "$(DevEnvDir)CommonExtensions\Microsoft\FSharp\fsi.exe" "$(ProjectDir)Resources\PostBuild.fsx" --exec --nologo -- "$(TargetDir)\" "$(ProjectDir)\" "$(ConfigurationName)"
@ -49,27 +48,9 @@ let main (argv: string[]) =
printfn "--------------------------" printfn "--------------------------"
let localesDir = targetDir +/ "locales" let localesDir = targetDir +/ "locales"
let scriptsDir = targetDir +/ "scripts"
let resourcesDir = targetDir +/ "resources" let resourcesDir = targetDir +/ "resources"
let pluginsDir = targetDir +/ "plugins" 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) // Functions (File Management)
let copyFile source target = let copyFile source target =
@ -122,10 +103,7 @@ let main (argv: string[]) =
let writeFile (fullPath: string) (lines: string seq) = let writeFile (fullPath: string) (lines: string seq) =
let relativePath = fullPath.[(targetDir.Length)..] let relativePath = fullPath.[(targetDir.Length)..]
let includeVersion = relativePath.StartsWith(@"scripts\") File.WriteAllLines(fullPath, lines |> Seq.toArray)
let finalLines = if includeVersion then seq { yield "#" + version; yield! lines } else lines
File.WriteAllLines(fullPath, finalLines |> Seq.toArray)
printfn "Processed %s" relativePath printfn "Processed %s" relativePath
let processFiles (files: string seq) (extProcessors: IDictionary<string, (string seq -> string seq)>) = 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") copyFile (projectDir +/ "bld/Resources/LICENSES.txt") (targetDir +/ "LICENSES.txt")
copyDirectoryContents (projectDir +/ "Resources/Scripts") scriptsDir
copyDirectoryContents (projectDir +/ "Resources/Content") resourcesDir copyDirectoryContents (projectDir +/ "Resources/Content") resourcesDir
createDirectory (pluginsDir +/ "official") createDirectory (pluginsDir +/ "official")
@ -161,7 +138,7 @@ let main (argv: string[]) =
if Directory.Exists(localesDir) || configuration = "Release" then if Directory.Exists(localesDir) || configuration = "Release" then
Directory.EnumerateFiles(localesDir, "*.pak") Directory.EnumerateFiles(localesDir, "*.pak")
|> exceptEndingWith @"\en-US.pak" |> exceptEndingWith @"\en-US.pak"
|> Seq.iter (File.Delete) |> Seq.iter File.Delete
// Validation // Validation
@ -174,41 +151,16 @@ let main (argv: string[]) =
let fileProcessors = let fileProcessors =
dict [ dict [
".js", (fun (lines: string seq) -> ".js", id;
lines ".css", id;
|> Seq.map (fun line -> ".html", id;
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
);
".meta", (fun (lines: string seq) -> ".meta", (fun (lines: string seq) ->
lines lines
|> Seq.map (fun line -> line.Replace("{version}", version)) |> 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 "*.css") fileProcessors
processFiles (byPattern targetDir "*.html") fileProcessors processFiles (byPattern targetDir "*.html") fileProcessors
processFiles (byPattern pluginsDir "*.meta") fileProcessors processFiles (byPattern pluginsDir "*.meta") fileProcessors

View File

@ -33,7 +33,7 @@ public override void OnReloadTriggered() {
protected override string LocateFile(string path) { protected override string LocateFile(string path) {
if (Directory.Exists(HotSwapTargetDir)) { if (Directory.Exists(HotSwapTargetDir)) {
Debug.WriteLine($"Hot swap active, redirecting {path}"); Debug.WriteLine($"Hot swap active, redirecting {path}");
return Path.Combine(HotSwapTargetDir, "scripts", path); return Path.Combine(HotSwapTargetDir, "resources", path);
} }
return base.LocateFile(path); return base.LocateFile(path);

View File

@ -468,9 +468,6 @@
<Content Include="Resources\Content\update\update.js" /> <Content Include="Resources\Content\update\update.js" />
<Content Include="Resources\Content\update\update.css" /> <Content Include="Resources\Content\update\update.css" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Resources\Scripts" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>rmdir "$(ProjectDir)bin\Debug" <PostBuildEvent>rmdir "$(ProjectDir)bin\Debug"

View File

@ -57,7 +57,6 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
Type: files; Name: "{app}\*.*" Type: files; Name: "{app}\*.*"
Type: filesandordirs; Name: "{app}\resources" Type: filesandordirs; Name: "{app}\resources"
Type: filesandordirs; Name: "{app}\locales" Type: filesandordirs; Name: "{app}\locales"
Type: filesandordirs; Name: "{app}\scripts"
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache"
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"

View File

@ -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\TweetDuck.*"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\bin\x86\Release\TweetLib.*"; 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\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 Source: "..\bin\x86\Release\plugins\*.*"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons] [Icons]
@ -60,7 +59,6 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
Type: files; Name: "{app}\*.*" Type: files; Name: "{app}\*.*"
Type: filesandordirs; Name: "{app}\locales" Type: filesandordirs; Name: "{app}\locales"
Type: filesandordirs; Name: "{app}\resources" Type: filesandordirs; Name: "{app}\resources"
Type: filesandordirs; Name: "{app}\scripts"
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache"
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache" Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"