diff --git a/src/Butil/Bit.Butil.Demo/Pages/ConsolePage.razor b/src/Butil/Bit.Butil.Demo/Pages/ConsolePage.razor index 8e2a7d3476..5f3ca7d1e6 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/ConsolePage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/ConsolePage.razor @@ -19,14 +19,35 @@ } -

Open the DevTools

- -
-
-

-

-

-

-

-

-
+
+
+ +

Open the DevTools and start clicking on buttons

+ +
+
+ +Value: + +
+
+
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
diff --git a/src/Butil/Bit.Butil.Demo/Pages/ElementPage.razor b/src/Butil/Bit.Butil.Demo/Pages/ElementPage.razor index bcaf25ad3a..cfc23a3c3b 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/ElementPage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/ElementPage.razor @@ -18,10 +18,12 @@

-
-

Open the DevTools

+

Open the DevTools and start clicking on buttons

+ +

+
Element

diff --git a/src/Butil/Bit.Butil.Demo/Pages/HistoryPage.razor b/src/Butil/Bit.Butil.Demo/Pages/HistoryPage.razor index 8b38650515..98672be442 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/HistoryPage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/HistoryPage.razor @@ -19,10 +19,12 @@

-
-

Open the DevTools

+

Open the DevTools and start clicking on buttons

+ +

+
diff --git a/src/Butil/Bit.Butil.Demo/Pages/Index.razor b/src/Butil/Bit.Butil.Demo/Pages/Index.razor index 8d20168b1b..30be6a0406 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/Index.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/Index.razor @@ -2,4 +2,4 @@ Index -

Hello, world!

+

Hello Butil users!

diff --git a/src/Butil/Bit.Butil.Demo/Pages/KeyboardPage.razor b/src/Butil/Bit.Butil.Demo/Pages/KeyboardPage.razor index ef4f84428a..0f853e95b2 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/KeyboardPage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/KeyboardPage.razor @@ -17,8 +17,14 @@ } +
+
+

Open the DevTools console and start pressing F5 or Ctrl+Alt+F10

+
+
+ @code { protected override async Task OnInitializedAsync() { diff --git a/src/Butil/Bit.Butil.Demo/Pages/NavigatorPage.razor b/src/Butil/Bit.Butil.Demo/Pages/NavigatorPage.razor index 50311b8f9b..c5aac2aa55 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/NavigatorPage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/NavigatorPage.razor @@ -18,10 +18,12 @@

-
-

Open the DevTools

+

Open the DevTools and start clicking on buttons

+ +

+ diff --git a/src/Butil/Bit.Butil.Demo/Pages/StoragePage.razor b/src/Butil/Bit.Butil.Demo/Pages/StoragePage.razor index 2bb6b0d57c..3ffb1d2a5c 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/StoragePage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/StoragePage.razor @@ -21,7 +21,6 @@
-

Open the DevTools and click on buttons

diff --git a/src/Butil/Bit.Butil.Demo/Pages/WindowPage.razor b/src/Butil/Bit.Butil.Demo/Pages/WindowPage.razor index 0b05858ca2..8f23163d0d 100644 --- a/src/Butil/Bit.Butil.Demo/Pages/WindowPage.razor +++ b/src/Butil/Bit.Butil.Demo/Pages/WindowPage.razor @@ -19,10 +19,12 @@

-
-

Open the DevTools and start pressing keys on your keyboard

+

Open the DevTools and start pressing keys or clicking on buttons

+ +

+  

@@ -37,6 +39,12 @@
Is BeforeUnload Registered? @isBeforeUnloadRegistered
+
+
+
+ +  + @code { private bool isKeyDownRegistered; private bool isBeforeUnloadRegistered; @@ -74,6 +82,16 @@ isBeforeUnloadRegistered = false; } + private async Task GetInnerHeight() + { + await console.Log("Window InnerHeight =", await window.GetInnerHeight()); + } + + private async Task GetInnerWidth() + { + await console.Log("Window InnerWidth =", await window.GetInnerWidth()); + } + public void Dispose() { if (isKeyDownRegistered) diff --git a/src/Butil/Bit.Butil/Internals/JsInterops/ConsoleJsInterop.cs b/src/Butil/Bit.Butil/Internals/JsInterops/ConsoleJsInterop.cs index dce73f8663..447e85222b 100644 --- a/src/Butil/Bit.Butil/Internals/JsInterops/ConsoleJsInterop.cs +++ b/src/Butil/Bit.Butil/Internals/JsInterops/ConsoleJsInterop.cs @@ -44,14 +44,11 @@ internal static async Task ConsoleInfo(this IJSRuntime js, params object?[]? arg internal static async Task ConsoleLog(this IJSRuntime js, params object?[]? args) => await js.InvokeVoidAsync("BitButil.console.log", args); - internal static async Task ConsoleMemory(this IJSRuntime js) - => await js.InvokeVoidAsync("BitButil.console.memory"); + internal static async Task ConsoleProfile(this IJSRuntime js, string? name) + => await js.InvokeVoidAsync("BitButil.console.profile", name); - internal static async Task ConsoleProfile(this IJSRuntime js) - => await js.InvokeVoidAsync("BitButil.console.profile"); - - internal static async Task ConsoleProfileEnd(this IJSRuntime js) - => await js.InvokeVoidAsync("BitButil.console.profileEnd"); + internal static async Task ConsoleProfileEnd(this IJSRuntime js, string? name) + => await js.InvokeVoidAsync("BitButil.console.profileEnd", name); internal static async Task ConsoleTable(this IJSRuntime js, object? data, object? properties) => await js.InvokeVoidAsync("BitButil.console.table", data, properties); diff --git a/src/Butil/Bit.Butil/Internals/JsInterops/ElementJsInterop.cs b/src/Butil/Bit.Butil/Internals/JsInterops/ElementJsInterop.cs index d4a3088226..e97a41000d 100644 --- a/src/Butil/Bit.Butil/Internals/JsInterops/ElementJsInterop.cs +++ b/src/Butil/Bit.Butil/Internals/JsInterops/ElementJsInterop.cs @@ -15,8 +15,8 @@ internal static async Task ElementGetAttribute(this IJSRuntime js, Eleme internal static async Task ElementGetAttributeNames(this IJSRuntime js, ElementReference element) => await js.InvokeAsync("BitButil.element.getAttribute", element); - internal static async Task ElementGetBoundingClientRect(this IJSRuntime js, ElementReference element) - => await js.InvokeAsync("BitButil.element.getBoundingClientRect", element); + internal static async Task ElementGetBoundingClientRect(this IJSRuntime js, ElementReference element) + => await js.InvokeAsync("BitButil.element.getBoundingClientRect", element); internal static async Task ElementHasAttribute(this IJSRuntime js, ElementReference element, string name) => await js.InvokeAsync("BitButil.element.hasAttribute", element, name); diff --git a/src/Butil/Bit.Butil/Internals/JsInterops/EventsJsInterop.cs b/src/Butil/Bit.Butil/Internals/JsInterops/EventsJsInterop.cs index 93fb4b7e2f..88b134439f 100644 --- a/src/Butil/Bit.Butil/Internals/JsInterops/EventsJsInterop.cs +++ b/src/Butil/Bit.Butil/Internals/JsInterops/EventsJsInterop.cs @@ -15,8 +15,7 @@ internal static async Task AddEventListener(this IJSRuntime js, object? options = null, bool preventDefault = false, bool stopPropagation = false) - { - await js.InvokeVoidAsync("BitButil.events.addEventListener", + => await js.InvokeVoidAsync("BitButil.events.addEventListener", elementName, eventName, methodName, @@ -25,18 +24,15 @@ await js.InvokeVoidAsync("BitButil.events.addEventListener", options, preventDefault, stopPropagation); - } internal static async Task RemoveEventListener(this IJSRuntime js, string elementName, string eventName, Guid[] listenerIds, object? options = null) - { - await js.InvokeVoidAsync("BitButil.events.removeEventListener", + => await js.InvokeVoidAsync("BitButil.events.removeEventListener", elementName, eventName, listenerIds, options); - } } diff --git a/src/Butil/Bit.Butil/Internals/JsInterops/KeyboardJsInterop.cs b/src/Butil/Bit.Butil/Internals/JsInterops/KeyboardJsInterop.cs index 1f2fe5709e..39ffa4cf78 100644 --- a/src/Butil/Bit.Butil/Internals/JsInterops/KeyboardJsInterop.cs +++ b/src/Butil/Bit.Butil/Internals/JsInterops/KeyboardJsInterop.cs @@ -17,8 +17,7 @@ internal static async Task KeyboardAdd(this IJSRuntime js, bool preventDefault = false, bool stopPropagation = false, bool repeat = false) - { - await js.InvokeVoidAsync("BitButil.keyboard.add", + => await js.InvokeVoidAsync("BitButil.keyboard.add", methodName, listenerId, code, @@ -29,10 +28,7 @@ await js.InvokeVoidAsync("BitButil.keyboard.add", preventDefault, stopPropagation, repeat); - } internal static async Task KeyboardRemove(this IJSRuntime js, Guid[] ids) - { - await js.InvokeVoidAsync("BitButil.keyboard.remove", ids); - } + => await js.InvokeVoidAsync("BitButil.keyboard.remove", ids); } diff --git a/src/Butil/Bit.Butil/Publics/Console.cs b/src/Butil/Bit.Butil/Publics/Console.cs index 210d7cfc2d..89a5c17dd5 100644 --- a/src/Butil/Bit.Butil/Publics/Console.cs +++ b/src/Butil/Bit.Butil/Publics/Console.cs @@ -5,72 +5,186 @@ namespace Bit.Butil; public class Console(IJSRuntime js) { + /// + /// Log a message and stack trace to console if the first argument is false. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/assert_static + ///
public async Task Assert(bool? condition, params object?[]? args) => await js.ConsoleAssert(condition, args); + /// + /// Clear the console. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/clear_static + ///
public async Task Clear() => await js.ConsoleClear(); + /// + /// Log the number of times this line has been called with the given label. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/count_static + ///
public async Task Count(string? label) => await js.ConsoleCount(label); + /// + /// Resets the value of the counter with the given label. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/countreset_static + ///
public async Task CountReset(string? label) => await js.ConsoleCountReset(label); + /// + /// Outputs a message to the console with the log level debug. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static + ///
public async Task Debug(params object?[]? args) => await js.ConsoleDebug(args); + /// + /// Displays an interactive listing of the properties of a specified JavaScript object. + /// This listing lets you use disclosure triangles to examine the contents of child objects. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/dir_static + ///
public async Task Dir(object? item, object? options) => await js.ConsoleDir(item, options); + /// + /// Displays an XML/HTML Element representation of the specified object if possible + /// or the JavaScript Object view if it is not possible. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/dirxml_static + ///
public async Task Dirxml(params object?[]? args) => await js.ConsoleDirxml(args); + /// + /// Outputs an error message. You may use string substitution and additional arguments with this method. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/error_static + ///
public async Task Error(params object?[]? args) => await js.ConsoleError(args); + /// + /// Creates a new inline group, indenting all following output by another level. + /// To move back out a level, call console.groupEnd(). + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/group_static + ///
public async Task Group(params object?[]? args) => await js.ConsoleGroup(args); + /// + /// Creates a new inline group, indenting all following output by another level. However, unlike console.group() + /// this starts with the inline group collapsed requiring the use of a disclosure button to expand it. + /// To move back out a level, call console.groupEnd(). + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/groupcollapsed_static + ///
public async Task GroupCollapsed(params object?[]? args) => await js.ConsoleGroupCollapsed(args); + /// + /// Exits the current inline group. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/groupend_static + ///
public async Task GroupEnd() => await js.ConsoleGroupEnd(); + /// + /// Informative logging of information. You may use string substitution and additional arguments with this method. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/info_static + ///
public async Task Info(params object?[]? args) => await js.ConsoleInfo(args); + /// + /// For general output of logging information. You may use string substitution and additional arguments with this method. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/log_static + ///
public async Task Log(params object?[]? args) => await js.ConsoleLog(args); - public async Task Memory() - => await js.ConsoleMemory(); - - public async Task Profile() - => await js.ConsoleProfile(); - - public async Task ProfileEnd() - => await js.ConsoleProfileEnd(); - + /// + /// Starts the browser's built-in profiler (for example, the Firefox performance tool). + /// You can specify an optional name for the profile. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/profile_static + ///
+ public async Task Profile(string? name) + => await js.ConsoleProfile(name); + + /// + /// Stops the profiler. You can see the resulting profile in the browser's performance tool + /// (for example, the Firefox performance tool). + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/profileend_static + ///
+ public async Task ProfileEnd(string? name) + => await js.ConsoleProfileEnd(name); + + /// + /// Displays tabular data as a table. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/table_static + ///
public async Task Table(object? data, object? properties) => await js.ConsoleTable(data, properties); + /// + /// Starts a timer with a name specified as an input parameter. Up to 10,000 simultaneous timers can run on a given page. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/time_static + ///
public async Task Time(string? label) => await js.ConsoleTime(label); + /// + /// Stops the specified timer and logs the elapsed time in milliseconds since it started. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/timeend_static + ///
public async Task TimeEnd(string? label) => await js.ConsoleTimeEnd(label); + /// + /// Logs the value of the specified timer to the console. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/timelog_static + ///
public async Task TimeLog(string? label, params object?[]? args) => await js.ConsoleTimeLog(label, args); + /// + /// Adds a marker to the browser performance tool's timeline. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/timestamp_static + ///
public async Task TimeStamp(string? label) => await js.ConsoleTimeStamp(label); + /// + /// Outputs a stack trace. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static + ///
public async Task Trace(params object?[]? args) => await js.ConsoleTrace(args); + /// + /// Outputs a warning message. + ///
+ /// https://developer.mozilla.org/en-US/docs/Web/API/console/warn_static + ///
public async Task Warn(params object?[]? args) => await js.ConsoleWarn(args); } diff --git a/src/Butil/Bit.Butil/Publics/Element.cs b/src/Butil/Bit.Butil/Publics/Element.cs index 1a65379bdb..cdecfbf7e8 100644 --- a/src/Butil/Bit.Butil/Publics/Element.cs +++ b/src/Butil/Bit.Butil/Publics/Element.cs @@ -36,7 +36,7 @@ public async Task GetAttributeNames(ElementReference element) /// /// Returns the size of an element and its position relative to the viewport. /// - public async Task GetBoundingClientRect(ElementReference element) + public async Task GetBoundingClientRect(ElementReference element) => await js.ElementGetBoundingClientRect(element); /// diff --git a/src/Butil/Bit.Butil/Publics/Element/DomRect.cs b/src/Butil/Bit.Butil/Publics/Element/Rect.cs similarity index 88% rename from src/Butil/Bit.Butil/Publics/Element/DomRect.cs rename to src/Butil/Bit.Butil/Publics/Element/Rect.cs index 4098f7d025..d74d382210 100644 --- a/src/Butil/Bit.Butil/Publics/Element/DomRect.cs +++ b/src/Butil/Bit.Butil/Publics/Element/Rect.cs @@ -1,6 +1,6 @@ namespace Bit.Butil; -public class DomRect +public class Rect { public double Height { get; set; } public double Width { get; set; } diff --git a/src/Butil/Bit.Butil/Publics/Events/ButilKeyboardEventArgs.cs b/src/Butil/Bit.Butil/Publics/Events/ButilKeyboardEventArgs.cs index 42fbe67d32..152cc9348c 100644 --- a/src/Butil/Bit.Butil/Publics/Events/ButilKeyboardEventArgs.cs +++ b/src/Butil/Bit.Butil/Publics/Events/ButilKeyboardEventArgs.cs @@ -2,7 +2,6 @@ namespace Bit.Butil; - // see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent /// /// Contains properties of the event describing user interaction with the keyboard. diff --git a/src/Butil/Bit.Butil/Publics/History.cs b/src/Butil/Bit.Butil/Publics/History.cs index 5ffa1433fc..044d9735d5 100644 --- a/src/Butil/Bit.Butil/Publics/History.cs +++ b/src/Butil/Bit.Butil/Publics/History.cs @@ -19,55 +19,64 @@ public class History(IJSRuntime js) : IDisposable /// Returns an Integer representing the number of elements in the session history, including the currently loaded page. /// For example, for a page loaded in a new tab this property returns 1. /// - public async Task GetLength() => await js.HistoryGetLength(); + public async Task GetLength() + => await js.HistoryGetLength(); /// /// Gets default scroll restoration behavior on history navigation. This property can be either auto or manual. /// - public async Task GetScrollRestoration() => await js.HistoryGetScrollRestoration(); + public async Task GetScrollRestoration() + => await js.HistoryGetScrollRestoration(); /// /// Allows web applications to explicitly set default scroll restoration behavior on history navigation. This property can be either auto or manual. /// - public async Task SetScrollRestoration(ScrollRestoration value) => await js.HistorySetScrollRestoration(value); + public async Task SetScrollRestoration(ScrollRestoration value) + => await js.HistorySetScrollRestoration(value); /// /// Returns an any value representing the state at the top of the history stack. /// - public async Task GetState() => await js.HistoryGetState(); + public async Task GetState() + => await js.HistoryGetState(); /// /// This asynchronous method goes to the previous page in session history, the same action as when the user clicks the browser's Back button. /// Calling this method to go back beyond the first page in the session history has no effect and doesn't raise an exception. /// - public async Task GoBack() => await js.HistoryGoBack(); + public async Task GoBack() + => await js.HistoryGoBack(); /// /// This asynchronous method goes to the next page in session history, the same action as when the user clicks the browser's Forward button. /// Calling this method to go forward beyond the most recent page in the session history has no effect and doesn't raise an exception. /// /// - public async Task GoForward() => await js.HistoryGoForward(); + public async Task GoForward() + => await js.HistoryGoForward(); /// /// Asynchronously loads a page from the session history, identified by its relative location to the current page, for example -1 for the previous page or 1 for the next page. /// Calling this method without parameters or a value of 0 reloads the current page. /// - public async Task Go(int? delta = null) => await js.HistoryGo(delta); + public async Task Go(int? delta = null) + => await js.HistoryGo(delta); /// /// Pushes the given data onto the session history stack with the specified title (and, if provided, URL). /// /// The state object can be anything that can be serialized. /// The new history entry's URL. The new URL must be of the same origin as the current URL; otherwise PushState throws an exception. - public async Task PushState(object? state = null, string? url = null) => await js.HistoryPushState(state, string.Empty, url); + public async Task PushState(object? state = null, string? url = null) + => await js.HistoryPushState(state, string.Empty, url); /// /// Updates the most recent entry on the history stack to have the specified data, title, and, if provided, URL. /// /// An object which is associated with the history entry passed to the ReplaceState() method. The state object can be null. /// The URL of the history entry. The new URL must be of the same origin as the current URL; otherwise ReplaceState throws an exception. - public async Task ReplaceState(object? state = null, string? url = null) => await js.HistoryReplaceState(state, string.Empty, url); + public async Task ReplaceState(object? state = null, string? url = null) + => await js.HistoryReplaceState(state, string.Empty, url); /// /// The popstate event of the Window interface is fired when the active history entry changes while the user navigates the session history. diff --git a/src/Butil/Bit.Butil/Publics/LocalStorage.cs b/src/Butil/Bit.Butil/Publics/LocalStorage.cs index 01243268aa..7c15896dcc 100644 --- a/src/Butil/Bit.Butil/Publics/LocalStorage.cs +++ b/src/Butil/Bit.Butil/Publics/LocalStorage.cs @@ -7,4 +7,4 @@ namespace Bit.Butil; ///
/// More info: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage ///
-public class LocalStorage(IJSRuntime js) : DomStorage(js, "localStorage") { } +public class LocalStorage(IJSRuntime js) : ButilStorage(js, "localStorage") { } diff --git a/src/Butil/Bit.Butil/Publics/SessionStorage.cs b/src/Butil/Bit.Butil/Publics/SessionStorage.cs index 14090a32b7..96dcf8c194 100644 --- a/src/Butil/Bit.Butil/Publics/SessionStorage.cs +++ b/src/Butil/Bit.Butil/Publics/SessionStorage.cs @@ -7,4 +7,4 @@ namespace Bit.Butil; ///
/// More info: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage /// -public class SessionStorage(IJSRuntime js) : DomStorage(js, "sessionStorage") { } +public class SessionStorage(IJSRuntime js) : ButilStorage(js, "sessionStorage") { } diff --git a/src/Butil/Bit.Butil/Publics/Storage/DomStorage.cs b/src/Butil/Bit.Butil/Publics/Storage/ButilStorage.cs similarity index 97% rename from src/Butil/Bit.Butil/Publics/Storage/DomStorage.cs rename to src/Butil/Bit.Butil/Publics/Storage/ButilStorage.cs index 1adecde0b2..0909c3298a 100644 --- a/src/Butil/Bit.Butil/Publics/Storage/DomStorage.cs +++ b/src/Butil/Bit.Butil/Publics/Storage/ButilStorage.cs @@ -9,7 +9,7 @@ namespace Bit.Butil; ///
/// More info: https://developer.mozilla.org/en-US/docs/Web/API/Storage /// -public class DomStorage(IJSRuntime js, string storageName) +public class ButilStorage(IJSRuntime js, string storageName) { /// /// Returns an integer representing the number of data items stored in the Storage object. diff --git a/src/Butil/Bit.Butil/Scripts/console.ts b/src/Butil/Bit.Butil/Scripts/console.ts index f8446a7a2c..6f231fcd6c 100644 --- a/src/Butil/Bit.Butil/Scripts/console.ts +++ b/src/Butil/Bit.Butil/Scripts/console.ts @@ -2,99 +2,27 @@ var BitButil = BitButil || {}; (function (butil: any) { butil.console = { - assert, clear, count, countReset, debug, dir, dirxml, error, group, groupCollapsed, groupEnd, - info, log, memory, profile, profileEnd, table, time, timeEnd, timeLog, timeStamp, trace, warn + assert(...data: any[]) { console.assert(...data) }, + clear() { console.clear() }, + count(label?: string) { console.count(label) }, + countReset(label?: string) { console.countReset(label) }, + debug(...data: any[]) { console.debug(...data) }, + dir(item?: any, options?: any) { console.dir(item, options) }, + dirxml(...data: any[]) { console.dirxml(...data) }, + error(...data: any[]) { console.error(...data) }, + group(...data: any[]) { console.group(...data) }, + groupCollapsed(...data: any[]) { console.groupCollapsed(...data) }, + groupEnd() { console.groupEnd() }, + info(...data: any[]) { console.info(...data) }, + log(...data: any[]) { console.log(...data) }, + profile(name: string) { (console as any).profile(name) }, + profileEnd(name: string) { (console as any).profileEnd(name) }, + table(data?: any, properties?: string[]) { console.table(data, properties) }, + time(label?: string) { console.time(label) }, + timeEnd(label?: string) { console.timeEnd(label) }, + timeLog(...data: any[]) { console.timeLog(...data) }, + timeStamp(label?: string) { console.timeStamp(label) }, + trace(...data: any[]) { console.trace(...data) }, + warn(...data: any[]) { console.warn(...data) } }; - - function assert(...data: any[]) { - console.assert(...data); - } - - function clear() { - console.clear(); - } - - function count(label?: string) { - console.count(label); - } - - function countReset(label?: string) { - console.countReset(label); - } - - function debug(...data: any[]) { - console.debug(...data); - } - - function dir(item?: any, options?: any) { - console.dir(item, options); - } - - function dirxml(...data: any[]) { - console.dirxml(...data); - } - - function error(...data: any[]) { - console.error(...data); - } - - function group(...data: any[]) { - console.group(...data); - } - - function groupCollapsed(...data: any[]) { - console.groupCollapsed(...data); - } - - function groupEnd() { - console.groupEnd(); - } - - function info(...data: any[]) { - console.info(...data); - } - - function log(...data: any[]) { - console.log(...data); - } - - function memory() { - (console as any).memory; - } - - function profile() { - (console as any).profile(); - } - - function profileEnd() { - (console as any).profileEnd(); - } - - function table(data?: any, properties?: string[]) { - console.table(data, properties); - } - - function time(label?: string) { - console.time(label); - } - - function timeEnd(label?: string) { - console.timeEnd(label); - } - - function timeLog(...data: any[]) { - console.timeLog(...data); - } - - function timeStamp(label?: string) { - console.timeStamp(label); - } - - function trace(...data: any[]) { - console.trace(...data); - } - - function warn(...data: any[]) { - console.warn(...data); - } }(BitButil)); \ No newline at end of file diff --git a/src/Butil/Bit.Butil/Scripts/document.ts b/src/Butil/Bit.Butil/Scripts/document.ts index 2e57efb794..b351dbbaa2 100644 --- a/src/Butil/Bit.Butil/Scripts/document.ts +++ b/src/Butil/Bit.Butil/Scripts/document.ts @@ -1,8 +1,6 @@ var BitButil = BitButil || {}; (function (butil: any) { - const _handlers = {}; - butil.document = { characterSet() { return document.characterSet }, compatMode() { return document.compatMode }, @@ -17,7 +15,6 @@ var BitButil = BitButil || {}; URL() { return document.URL }, setTitle(value: string) { document.title = value }, exitFullscreen() { return document.exitFullscreen() }, - exitPointerLock() { return document.exitPointerLock() }, - + exitPointerLock() { return document.exitPointerLock() } }; }(BitButil)); \ No newline at end of file diff --git a/src/Butil/Bit.Butil/Scripts/history.ts b/src/Butil/Bit.Butil/Scripts/history.ts index 4f5606a2b1..5c0b480d76 100644 --- a/src/Butil/Bit.Butil/Scripts/history.ts +++ b/src/Butil/Bit.Butil/Scripts/history.ts @@ -4,55 +4,19 @@ var BitButil = BitButil || {}; const _handlers = {}; butil.history = { - length, - scrollRestoration, - setScrollRestoration, - state, - back, - forward, - go, - pushState, - replaceState, + length() { return window.history.length }, + scrollRestoration() { return window.history.scrollRestoration }, + setScrollRestoration(value) { window.history.scrollRestoration = value }, + state() { return window.history.state }, + back() { window.history.back() }, + forward() { window.history.forward() }, + go(delta) { window.history.go(delta) }, + pushState(state, unused, url) { window.history.pushState(state, unused, url) }, + replaceState(state, unused, url) { window.history.replaceState(state, unused, url) }, addPopState, removePopState }; - function length() { - return window.history.length; - } - - function scrollRestoration() { - return window.history.scrollRestoration; - } - - function setScrollRestoration(value) { - window.history.scrollRestoration = value; - } - - function state() { - return window.history.state; - } - - function back() { - window.history.back(); - } - - function forward() { - window.history.forward(); - } - - function go(delta) { - window.history.go(delta); - } - - function pushState(state, unused, url) { - window.history.pushState(state, unused, url); - } - - function replaceState(state, unused, url) { - window.history.replaceState(state, unused, url); - } - function addPopState(methodName, listenerId) { const handler = e => { DotNet.invokeMethodAsync('Bit.Butil', methodName, listenerId, e.state); diff --git a/src/Butil/Bit.Butil/Scripts/navigator.ts b/src/Butil/Bit.Butil/Scripts/navigator.ts index 7f3b5162ce..3a56004fa8 100644 --- a/src/Butil/Bit.Butil/Scripts/navigator.ts +++ b/src/Butil/Bit.Butil/Scripts/navigator.ts @@ -2,80 +2,20 @@ var BitButil = BitButil || {}; (function (butil: any) { butil.navigator = { - deviceMemory, - hardwareConcurrency, - language, - languages, - maxTouchPoints, - onLine, - pdfViewerEnabled, - userAgent, - webdriver, - canShare, - clearAppBadge, - sendBeacon, - setAppBadge, - share, - vibrate + deviceMemory() { return (window.navigator as any).deviceMemory }, + hardwareConcurrency() { return window.navigator.hardwareConcurrency }, + language() { return window.navigator.language }, + languages() { return window.navigator.languages }, + maxTouchPoints() { return window.navigator.maxTouchPoints }, + onLine() { return window.navigator.onLine }, + pdfViewerEnabled() { return window.navigator.pdfViewerEnabled }, + userAgent() { return window.navigator.userAgent }, + webdriver() { return window.navigator.webdriver }, + canShare() { return window.navigator.canShare() }, + clearAppBadge() { return window.navigator.clearAppBadge() }, + sendBeacon(url: string, data) { return window.navigator.sendBeacon(url, data) }, + setAppBadge(contents) { return window.navigator.setAppBadge(contents) }, + share(data) { return window.navigator.share(data) }, + vibrate(pattern) { return window.navigator.vibrate(pattern) } }; - - function deviceMemory() { - return (window.navigator as any).deviceMemory; - } - - function hardwareConcurrency() { - return window.navigator.hardwareConcurrency; - } - - function language() { - return window.navigator.language; - } - - function languages() { - return window.navigator.languages; - } - - function maxTouchPoints() { - return window.navigator.maxTouchPoints; - } - - function onLine() { - return window.navigator.onLine; - } - - function pdfViewerEnabled() { - return window.navigator.pdfViewerEnabled; - } - - function userAgent() { - return window.navigator.userAgent; - } - - function webdriver() { - return window.navigator.webdriver; - } - - function canShare() { - return window.navigator.canShare(); - } - - function clearAppBadge() { - return window.navigator.clearAppBadge(); - } - - function sendBeacon(url: string, data) { - return window.navigator.sendBeacon(url, data) - } - - function setAppBadge(contents) { - return window.navigator.setAppBadge(contents); - } - - function share(data) { - return window.navigator.share(data); - } - - function vibrate(pattern) { - return window.navigator.vibrate(pattern); - } }(BitButil)); \ No newline at end of file diff --git a/src/Butil/Bit.Butil/Scripts/screen.ts b/src/Butil/Bit.Butil/Scripts/screen.ts index f0b10ef5b0..b937e636ca 100644 --- a/src/Butil/Bit.Butil/Scripts/screen.ts +++ b/src/Butil/Bit.Butil/Scripts/screen.ts @@ -15,8 +15,6 @@ var BitButil = BitButil || {}; removeChange }; - - function addChange(methodName, listenerId) { const handler = e => { DotNet.invokeMethodAsync('Bit.Butil', methodName, listenerId);