summary refs log tree commit diff
path: root/ReferenceClientProxyImplementation/Patches/Implementations/JSPatches/LegacyJsPatches.cs
blob: e7f78a0d52b3d6c97b201d5977f4e29225b0bae9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// using System.Text;
// using System.Text.RegularExpressions;
//
// namespace ReferenceClientProxyImplementation.Patches.Implementations.JSPatches;
//
// public partial class LegacyJsPathces : IPatch {
//     public int GetOrder() => 1;
//
//     public string GetName() => "Patch deprecated JS constructs";
//     public bool Applies(string relativeName, byte[] content) => relativeName.EndsWith(".js");
//
//     public async Task<byte[]> Execute(string relativePath, byte[] content) {
//         var stringContent = Encoding.UTF8.GetString(content);
//
//         while(MozInputSourceRegex().IsMatch(stringContent)) {
//             var match = MozInputSourceRegex().Match(stringContent);
//             var replacement = match.Groups[1].Value switch {
//                 "0" => "",
//                 "1" => "mouse",
//                 "2" => "pen",
//                 "3" => "pen",
//                 "4" => "touch",
//                 _ => throw new InvalidOperationException("Unreachable")
//             };
//         }
//
//         return Encoding.UTF8.GetBytes(stringContent);
//     }
//
//     [GeneratedRegex(@"([0-6]) === (\w).mozInputSource", RegexOptions.Compiled)]
//     private static partial Regex MozInputSourceRegex();
// }