mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-21 15:15:48 +02:00
Remove "scripts" folder and JS/CSS minification
This commit is contained in:
parent
6a421292b3
commit
c91f1d0e5e
Program.csPostBuild.fsxScriptLoaderDebug.csTweetDuck.csproj
Resources
Plugins
clear-columns
edit-design
emoji-keyboard
reply-account
templates
bld
@ -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");
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user