diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs
index 4d367f4..5a64307 100644
--- a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs
+++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.Designer.cs
@@ -132,6 +132,24 @@ namespace WelsonJS.Launcher.Properties {
}
}
+ ///
+ /// https://esm.run/과(와) 유사한 지역화된 문자열을 찾습니다.
+ ///
+ internal static string EsmRunPrefix {
+ get {
+ return ResourceManager.GetString("EsmRunPrefix", resourceCulture);
+ }
+ }
+
+ ///
+ /// https://esm.sh/과(와) 유사한 지역화된 문자열을 찾습니다.
+ ///
+ internal static string EsmShPrefix {
+ get {
+ return ResourceManager.GetString("EsmShPrefix", resourceCulture);
+ }
+ }
+
///
/// (아이콘)과(와) 유사한 System.Drawing.Icon 형식의 지역화된 리소스를 찾습니다.
///
@@ -232,6 +250,24 @@ namespace WelsonJS.Launcher.Properties {
}
}
+ ///
+ /// https://code.jquery.com/과(와) 유사한 지역화된 문자열을 찾습니다.
+ ///
+ internal static string JqueryCdnPrefix {
+ get {
+ return ResourceManager.GetString("JqueryCdnPrefix", resourceCulture);
+ }
+ }
+
+ ///
+ /// https://cdn.jsdelivr.net/과(와) 유사한 지역화된 문자열을 찾습니다.
+ ///
+ internal static string JsDeliverPrefix {
+ get {
+ return ResourceManager.GetString("JsDeliverPrefix", resourceCulture);
+ }
+ }
+
///
/// https://github.com/gnh1201/welsonjs과(와) 유사한 지역화된 문자열을 찾습니다.
///
@@ -250,6 +286,24 @@ namespace WelsonJS.Launcher.Properties {
}
}
+ ///
+ /// https://www.skypack.dev/과(와) 유사한 지역화된 문자열을 찾습니다.
+ ///
+ internal static string SkypackPrefix {
+ get {
+ return ResourceManager.GetString("SkypackPrefix", resourceCulture);
+ }
+ }
+
+ ///
+ /// https://unpkg.com/과(와) 유사한 지역화된 문자열을 찾습니다.
+ ///
+ internal static string UnpkgPrefix {
+ get {
+ return ResourceManager.GetString("UnpkgPrefix", resourceCulture);
+ }
+ }
+
///
/// 141.101.82.1과(와) 유사한 지역화된 문자열을 찾습니다.
///
diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx
index bf5af31..e939c48 100644
--- a/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx
+++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Properties/Resources.resx
@@ -187,4 +187,22 @@
https://cdnjs.cloudflare.com/
+
+ https://esm.run/
+
+
+ https://esm.sh/
+
+
+ https://code.jquery.com/
+
+
+ https://cdn.jsdelivr.net/
+
+
+ https://www.skypack.dev/
+
+
+ https://unpkg.com/
+
\ No newline at end of file
diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceServer.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceServer.cs
index cd21f07..3d8c96f 100644
--- a/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceServer.cs
+++ b/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceServer.cs
@@ -7,6 +7,7 @@ using System.Net.Http;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -182,18 +183,42 @@ namespace WelsonJS.Launcher
}
}
- // use the cdn-js
- if (path.StartsWith("ajax/libs/"))
+ // use CDN sources
+ if (await TryServeFromCdn(context, path))
{
- if (await ServeBlob(context, path, Program.GetAppConfig("CdnJsPrefix"))) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private async Task TryServeFromCdn(HttpListenerContext context, string path)
+ {
+ bool isNodePackageExpression = Regex.IsMatch(path, @"^[^/@]+@[^/]+/");
+
+ var sources = new (bool isMatch, string configKey, Func transform)[]
+ {
+ (path.StartsWith("ajax/libs/"), "CdnJsPrefix", p => p),
+ (isNodePackageExpression, "UnpkgPrefix", p => p),
+ (isNodePackageExpression, "SkypackPrefix", p => p),
+ (isNodePackageExpression, "EsmShPrefix", p => p),
+ (isNodePackageExpression, "EsmRunPrefix", p => p),
+ (path.StartsWith("npm/") || path.StartsWith("gh/") || path.StartsWith("wp/"), "JsDeliverPrefix", p => p),
+ (path.StartsWith("jquery/"), "JqueryCdnPrefix", p => p.Substring("jquery/".Length)),
+ (true, "BlobStoragePrefix", p => p) // fallback
+ };
+
+ foreach (var (isMatch, configKey, transform) in sources)
+ {
+ if (isMatch)
+ {
+ string prefix = Program.GetAppConfig(configKey);
+ if (await ServeBlob(context, transform(path), prefix))
+ {
return true;
}
}
-
- // use the blob stroage
- if (await ServeBlob(context, path, Program.GetAppConfig("BlobStoragePrefix"))) {
- return true;
- }
}
return false;
diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/app.config b/WelsonJS.Toolkit/WelsonJS.Launcher/app.config
index 729e7ad..8cc77e5 100644
--- a/WelsonJS.Toolkit/WelsonJS.Launcher/app.config
+++ b/WelsonJS.Toolkit/WelsonJS.Launcher/app.config
@@ -14,6 +14,12 @@
+
+
+
+
+
+