diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs
index c278f8382c6d..f5d4e8afa881 100644
--- a/src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs
+++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Internal/TSBindings/TSBindingsGenerator.cs
@@ -288,15 +288,8 @@ private static void GenerateUnmarshaler(INamedTypeSymbol parametersType, Indente
if (isElementString)
{
- using (sb.BlockInvariant("if(value !== 0)"))
- {
- sb.AppendLineIndented($"ret.{field.Name}.push({elementTSType}(MonoRuntime.conv_string(value)));");
- }
- sb.AppendLineIndented("else");
- using (sb.BlockInvariant(""))
- {
- sb.AppendLineIndented($"ret.{field.Name}.push(null);");
- }
+ // array string conversion has been removed from net9
+ throw new NotSupportedException("String is not supported anymore");
}
else
{
diff --git a/src/Uno.Foundation.Runtime.WebAssembly/Interop/Runtime.wasm.cs b/src/Uno.Foundation.Runtime.WebAssembly/Interop/Runtime.wasm.cs
index 16d1077e3737..982c579ddc24 100644
--- a/src/Uno.Foundation.Runtime.WebAssembly/Interop/Runtime.wasm.cs
+++ b/src/Uno.Foundation.Runtime.WebAssembly/Interop/Runtime.wasm.cs
@@ -43,7 +43,7 @@ private static IntPtr GetMethodId(string methodName)
{
if (!MethodMap.TryGetValue(methodName, out var methodId))
{
- MethodMap[methodName] = methodId = WebAssembly.JSInterop.InternalCalls.InvokeJSUnmarshalled(out _, methodName, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
+ MethodMap[methodName] = methodId = WebAssembly.Runtime.InvokeJSUnmarshalled(methodName, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
}
return methodId;
@@ -129,22 +129,15 @@ private static bool InnerInvokeJSUnmarshalled(string functionIdentifier, IntPtr
exception = null;
var methodId = GetMethodId(functionIdentifier);
- var res = WebAssembly.JSInterop.InternalCalls.InvokeJSUnmarshalled(out var exceptionMessage, null, methodId, arg0, IntPtr.Zero);
-
- if (!string.IsNullOrEmpty(exceptionMessage))
+ try
{
- if (_trace.IsEnabled)
- {
- _trace.WriteEvent(
- TraceProvider.InvokeException,
- new object[] { functionIdentifier, exceptionMessage }
- );
- }
-
- exception = new Exception(exceptionMessage);
+ return WebAssembly.Runtime.InvokeJSUnmarshalled(null, methodId, arg0, IntPtr.Zero) != 0;
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ return false;
}
-
- return res != IntPtr.Zero;
}
///
@@ -181,22 +174,7 @@ private static bool InnerInvokeJSUnmarshalled(string functionIdentifier, IntPtr
{
var methodId = GetMethodId(functionIdentifier);
- var res = WebAssembly.JSInterop.InternalCalls.InvokeJSUnmarshalled(out var exception, null, methodId, arg0, arg1);
-
- if (exception != null)
- {
- if (_trace.IsEnabled)
- {
- _trace.WriteEvent(
- TraceProvider.InvokeException,
- new object[] { functionIdentifier, exception.ToString() }
- );
- }
-
- throw new Exception(exception);
- }
-
- return res != IntPtr.Zero;
+ return WebAssembly.Runtime.InvokeJSUnmarshalled(null, methodId, arg0, arg1) != 0;
}
#pragma warning disable CA2211
diff --git a/src/Uno.Foundation.Runtime.WebAssembly/Interop/WebAssembly.Runtime.cs b/src/Uno.Foundation.Runtime.WebAssembly/Interop/WebAssembly.Runtime.cs
index 359ab371fbe3..1f122fb06c23 100644
--- a/src/Uno.Foundation.Runtime.WebAssembly/Interop/WebAssembly.Runtime.cs
+++ b/src/Uno.Foundation.Runtime.WebAssembly/Interop/WebAssembly.Runtime.cs
@@ -1,61 +1,31 @@
-using System;
+#nullable enable
+
+using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices.JavaScript;
using Uno.Foundation.Runtime.WebAssembly.Interop;
namespace WebAssembly
{
[Obfuscation(Feature = "renaming", Exclude = true)]
- internal sealed class Runtime
+ internal sealed partial class Runtime
{
- internal static bool RethrowNativeExceptions { get; set; } = true;
-
- ///
- /// Mono specific internal call.
- ///
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern string InvokeJS(string str, out int exceptional_result);
-
- // Disable inlining to avoid the interpreter to evaluate an internal call that may not be available
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static string NetCoreInvokeJS(string str, out int exceptionResult)
- => Interop.Runtime.InvokeJS(str, out exceptionResult);
-
///
/// Invokes Javascript code in the hosting environment
///
- internal static string InvokeJS(string str)
- {
- int exceptionResult;
- var result = NetCoreInvokeJS(str, out exceptionResult);
+ [JSImport("globalThis.Uno.UI.Interop.Runtime.InvokeJS")]
+ internal static partial string InvokeJS(string value);
- if (exceptionResult != 0)
- {
- var errorMessage = $"Error #{exceptionResult} \"{result}\" executing javascript: \"{str}\"";
- if (RethrowNativeExceptions)
- {
- throw new InvalidOperationException(errorMessage);
- }
- else
- {
- Console.Error.WriteLine(errorMessage);
- }
- }
- return result;
- }
+ [JSImport("globalThis.MonoSupport.jsCallDispatcher.invokeJSUnmarshalled")]
+ internal static partial IntPtr InvokeJSUnmarshalled(string? functionIdentifier, IntPtr arg0, IntPtr arg1, IntPtr arg2);
}
namespace JSInterop
{
internal static class InternalCalls
{
- // Matches this signature:
- // https://github.com/mono/mono/blob/f24d652d567c4611f9b4e3095be4e2a1a2ab23a4/sdks/wasm/driver.c#L21
- [MethodImpl(MethodImplOptions.InternalCall)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static extern IntPtr InvokeJSUnmarshalled(out string exceptionMessage, string functionIdentifier, IntPtr arg0, IntPtr arg1, IntPtr arg2);
-
// Uno-Specific implementation for https://github.com/dotnet/runtime/issues/69409.
// To be removed when the runtime will support the main SynchronizationContext.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
diff --git a/src/Uno.Foundation/FoundationFeatureConfiguration.cs b/src/Uno.Foundation/FoundationFeatureConfiguration.cs
index b1b433ca7f48..5ea990c914e9 100644
--- a/src/Uno.Foundation/FoundationFeatureConfiguration.cs
+++ b/src/Uno.Foundation/FoundationFeatureConfiguration.cs
@@ -38,8 +38,9 @@ public static class Runtime
///
public static bool RethrowNativeExceptions
{
- get => WebAssembly.Runtime.RethrowNativeExceptions;
- set => WebAssembly.Runtime.RethrowNativeExceptions = value;
+ // Obsolete, remove in next major
+ get => true;
+ set { }
}
}
#endif
diff --git a/src/Uno.UI.Wasm.Tests/Tests/TSBindingsTests.cs b/src/Uno.UI.Wasm.Tests/Tests/TSBindingsTests.cs
index 921c4da4c019..35ca49b3ca56 100644
--- a/src/Uno.UI.Wasm.Tests/Tests/TSBindingsTests.cs
+++ b/src/Uno.UI.Wasm.Tests/Tests/TSBindingsTests.cs
@@ -136,62 +136,6 @@ public void When_NullArrayOfInt()
Assert.AreEqual("true", ret.Value);
}
-
- [TestMethod]
- public void When_ArrayOfStrings()
- {
- var param = new When_ArrayOfStringsParams()
- {
- MyArray_Length = 4,
- MyArray = new[] { "1", "2", "3", "42" }
- };
-
- var ret = (GenericReturn)TSInteropMarshaller.InvokeJS("TSBindingsUnitTests:When_ArrayOfStrings", param, typeof(GenericReturn));
-
- Assert.AreEqual("1;2;3;42", ret.Value);
- }
-
- [TestMethod]
- public void When_ArrayOfUnicodeStrings()
- {
- var param = new When_ArrayOfStringsParams()
- {
- MyArray_Length = 1,
- MyArray = new[] { "🎉🤣😊👆🎁" }
- };
-
- var ret = (GenericReturn)TSInteropMarshaller.InvokeJS("TSBindingsUnitTests:When_ArrayOfUnicodeStrings", param, typeof(GenericReturn));
-
- Assert.AreEqual(param.MyArray[0], ret.Value);
- }
-
- [TestMethod]
- public void When_NullArrayOfStrings()
- {
- var param = new When_ArrayOfStringsParams()
- {
- MyArray_Length = 0,
- MyArray = null
- };
-
- var ret = (GenericReturn)TSInteropMarshaller.InvokeJS("TSBindingsUnitTests:When_NullArrayOfStrings", param, typeof(GenericReturn));
-
- Assert.AreEqual("true", ret.Value);
- }
-
- [TestMethod]
- public void When_ArrayOfNullStrings()
- {
- var param = new When_ArrayOfStringsParams()
- {
- MyArray_Length = 4,
- MyArray = new string[4]
- };
-
- var ret = (GenericReturn)TSInteropMarshaller.InvokeJS("TSBindingsUnitTests:When_ArrayOfNullStrings", param, typeof(GenericReturn));
-
- Assert.AreEqual("true;true;true;true", ret.Value);
- }
}
partial class TestImport
@@ -200,16 +144,6 @@ partial class TestImport
internal static partial string When_SingleStringNet7(string value);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- public struct When_ArrayOfStringsParams
- {
- public int MyArray_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = TSInteropMarshaller.LPUTF8Str)]
- public string[] MyArray;
- }
-
[TSInteropMessage]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct When_ArrayOfIntParams
diff --git a/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs b/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs
index 405279c7613c..860a49b9b48c 100644
--- a/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs
+++ b/src/Uno.UI/UI/Xaml/Window/WindowManagerInterop.wasm.cs
@@ -58,64 +58,10 @@ internal static void CreateContent(IntPtr htmlId, string htmlTag, IntPtr handle,
NativeMethods.CreateContent(htmlId, htmlTag, uiElementRegistrationId, isFocusable, htmlTagIsSvg);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerCreateContentParams
- {
- public IntPtr HtmlId;
-
- [MarshalAs(TSInteropMarshaller.LPUTF8Str)]
- public string TagName;
-
- public IntPtr Handle;
-
- public int UIElementRegistrationId;
-
- public bool IsSvg;
- public bool IsFocusable;
- }
-
#endregion
- #region CreateContent
internal static int RegisterUIElement(string typeName, string[] classNames, bool isFrameworkElement)
- {
- var parms = new WindowManagerRegisterUIElementParams
- {
- TypeName = typeName,
- IsFrameworkElement = isFrameworkElement,
- Classes_Length = classNames.Length,
- Classes = classNames,
- };
-
- var ret = (WindowManagerRegisterUIElementReturn)TSInteropMarshaller.InvokeJS("Uno:registerUIElementNative", parms, typeof(WindowManagerRegisterUIElementReturn));
-
- return ret.RegistrationId;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerRegisterUIElementParams
- {
- [MarshalAs(TSInteropMarshaller.LPUTF8Str)]
- public string TypeName;
-
- public bool IsFrameworkElement;
-
- public int Classes_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = TSInteropMarshaller.LPUTF8Str)]
- public string[] Classes;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerRegisterUIElementReturn
- {
- public int RegistrationId;
- }
-
- #endregion
+ => NativeMethods.RegisterUIElement(typeName, isFrameworkElement, classNames);
#region SetElementTransform
@@ -124,20 +70,6 @@ internal static void SetElementTransform(IntPtr htmlId, Matrix3x2 matrix)
NativeMethods.SetElementTransform(htmlId, matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 8)]
- private struct WindowManagerSetElementTransformParams
- {
- public IntPtr HtmlId;
-
- public double M11;
- public double M12;
- public double M21;
- public double M22;
- public double M31;
- public double M32;
- }
-
#endregion
#region SetPointerEvents
@@ -161,16 +93,7 @@ internal static Size MeasureView(IntPtr htmlId, Size availableSize, bool measure
return new Size(result.DesiredWidth, result.DesiredHeight);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 8)]
- private struct WindowManagerMeasureViewParams
- {
- public IntPtr HtmlId;
- public double AvailableWidth;
- public double AvailableHeight;
- public bool MeasureContent;
- }
[TSInteropMessage]
[StructLayout(LayoutKind.Sequential, Pack = 8)]
@@ -179,8 +102,6 @@ private struct WindowManagerMeasureViewReturn
public double DesiredWidth;
public double DesiredHeight;
}
-
-
#endregion
#region SetStyleDouble
@@ -216,17 +137,6 @@ internal static void SetStyleString(IntPtr htmlId, string name, string value)
NativeMethods.SetStyleString(htmlId, name, value);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetStyleStringParams
- {
- public IntPtr HtmlId;
-
- public string Name;
-
- public string Value;
- }
-
#endregion
#region SetRectanglePosition
@@ -274,18 +184,6 @@ internal static void SetStyles(IntPtr htmlId, (string name, string value)[] styl
NativeMethods.SetStyles(htmlId, pairs);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetStylesParams
- {
- public IntPtr HtmlId;
-
- public int Pairs_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)]
- public string[] Pairs;
- }
-
#endregion
#region IsCssFeatureSupported
@@ -297,67 +195,13 @@ internal static bool IsCssFeatureSupported(string supportCondition)
#endregion
- #region SetUnsetCssClasses
internal static void SetUnsetCssClasses(IntPtr htmlId, string[] cssClassesToSet, string[] cssClassesToUnset)
- {
- var parms = new WindowManagerSetUnsetClassesParams
- {
- HtmlId = htmlId,
- CssClassesToSet = cssClassesToSet,
- CssClassesToSet_Length = cssClassesToSet?.Length ?? 0,
- CssClassesToUnset = cssClassesToUnset,
- CssClassesToUnset_Length = cssClassesToUnset?.Length ?? 0
- };
-
- TSInteropMarshaller.InvokeJS("Uno:setUnsetClassesNative", parms);
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetUnsetClassesParams
- {
- public IntPtr HtmlId;
-
- public int CssClassesToSet_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)]
- public string[] CssClassesToSet;
-
- public int CssClassesToUnset_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)]
- public string[] CssClassesToUnset;
- }
- #endregion
+ => NativeMethods.SetUnsetCssClasses(htmlId, cssClassesToSet, cssClassesToUnset);
#region SetClasses
internal static void SetClasses(IntPtr htmlId, string[] cssClasses, int index)
- {
- var parms = new WindowManagerSetClassesParams
- {
- HtmlId = htmlId,
- CssClasses = cssClasses,
- CssClasses_Length = cssClasses.Length,
- Index = index
- };
-
- TSInteropMarshaller.InvokeJS("Uno:setClassesNative", parms);
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetClassesParams
- {
- public IntPtr HtmlId;
-
- public int CssClasses_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)]
- public string[] CssClasses;
-
- public int Index;
- }
+ => NativeMethods.SetClasses(htmlId, cssClasses, index);
#endregion
@@ -401,47 +245,11 @@ internal static void SetAttributes(IntPtr htmlId, (string name, string value)[]
NativeMethods.SetAttributes(htmlId, pairs);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetAttributesParams
- {
- public IntPtr HtmlId;
-
- public int Pairs_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = TSInteropMarshaller.LPUTF8Str)]
- public string[] Pairs;
- }
-
#endregion
- #region SetAttribute
internal static void SetAttribute(IntPtr htmlId, string name, string value)
- {
- var parms = new WindowManagerSetAttributeParams()
- {
- HtmlId = htmlId,
- Name = name,
- Value = value,
- };
+ => NativeMethods.SetAttribute(htmlId, name, value);
- TSInteropMarshaller.InvokeJS("Uno:setAttributeNative", parms);
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetAttributeParams
- {
- public IntPtr HtmlId;
-
- [MarshalAs(TSInteropMarshaller.LPUTF8Str)]
- public string Name;
-
- [MarshalAs(TSInteropMarshaller.LPUTF8Str)]
- public string Value;
- }
-
- #endregion
#region GetAttribute
internal static string GetAttribute(IntPtr htmlId, string name)
@@ -529,20 +337,10 @@ internal static void SetVisibility(IntPtr htmlId, bool visible)
NativeMethods.SetVisibility(htmlId, visible);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetVisibilityParams
- {
- public IntPtr HtmlId;
-
- public bool Visible;
- }
#endregion
internal static string GetProperty(IntPtr htmlId, string name)
- {
- return NativeMethods.GetProperty(htmlId, name);
- }
+ => NativeMethods.GetProperty(htmlId, name);
#region SetProperty
@@ -560,32 +358,7 @@ internal static void SetProperty(IntPtr htmlId, (string name, string value)[] pr
}
internal static void SetProperty(IntPtr htmlId, string name, string value)
- {
- NativeMethods.SetProperty(htmlId, name, value);
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetSinglePropertyParams
- {
- public IntPtr HtmlId;
-
- public string Name;
-
- public string Value;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerSetPropertyParams
- {
- public IntPtr HtmlId;
-
- public int Pairs_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = TSInteropMarshaller.LPUTF8Str)]
- public string[] Pairs;
- }
+ => NativeMethods.SetProperty(htmlId, name, value);
#endregion
@@ -707,26 +480,7 @@ internal static void ResetStyle(IntPtr htmlId, string[] names)
return;
}
- var parms = new WindowManagerResetStyleParams()
- {
- HtmlId = htmlId,
- Styles = names,
- Styles_Length = names.Length,
- };
-
- TSInteropMarshaller.InvokeJS("Uno:resetStyleNative", parms);
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerResetStyleParams
- {
- public IntPtr HtmlId;
-
- public int Styles_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = TSInteropMarshaller.LPUTF8Str)]
- public string[] Styles;
+ NativeMethods.ResetStyle(htmlId, names);
}
#endregion
@@ -837,24 +591,6 @@ internal static void ArrangeElement(IntPtr htmlId, Rect rect, Rect? clipRect)
clipRectValue.Right);
}
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct WindowManagerArrangeElementParams
- {
- public double Top;
- public double Left;
- public double Width;
- public double Height;
-
- public double ClipTop;
- public double ClipLeft;
- public double ClipBottom;
- public double ClipRight;
-
- public IntPtr HtmlId;
- public bool Clip;
- }
-
#endregion
@@ -1095,6 +831,9 @@ internal static partial void ArrangeElement(
[JSImport("globalThis.Uno.UI.WindowManager.current.setAttributesNativeFast")]
internal static partial void SetAttributes(IntPtr htmlId, string[] pairs);
+ [JSImport("globalThis.Uno.UI.WindowManager.current.setAttribute")]
+ internal static partial void SetAttribute(IntPtr htmlId, string name, string value);
+
[JSImport("globalThis.Uno.UI.WindowManager.current.setElementTransformNativeFast")]
internal static partial void SetElementTransform(IntPtr htmlId, float m11, float m12, float m21, float m22, float m31, float m32);
@@ -1139,6 +878,18 @@ internal static partial void ArrangeElement(
[JSImport("globalThis.Uno.UI.WindowManager.current.containsPoint")]
internal static partial bool ContainsPoint(IntPtr htmlId, double x, double y, bool considerFill, bool considerStroke);
+
+ [JSImport("globalThis.Uno.UI.WindowManager.current.registerUIElement")]
+ internal static partial int RegisterUIElement(string typeName, bool isFrameworkElement, string[] classNames);
+
+ [JSImport("globalThis.Uno.UI.WindowManager.current.resetStyle")]
+ internal static partial void ResetStyle(IntPtr htmlId, string[] names);
+
+ [JSImport("globalThis.Uno.UI.WindowManager.current.setClasses")]
+ internal static partial void SetClasses(IntPtr htmlId, string[] cssClasses, int index);
+
+ [JSImport("globalThis.Uno.UI.WindowManager.current.setUnsetCssClasses")]
+ internal static partial void SetUnsetCssClasses(IntPtr htmlId, string[] cssClassesToSet, string[] cssClassesToUnset);
}
}
}
diff --git a/src/Uno.UI/ts/Interop/Runtime.ts b/src/Uno.UI/ts/Interop/Runtime.ts
index 2d269098047e..962c55e19041 100644
--- a/src/Uno.UI/ts/Interop/Runtime.ts
+++ b/src/Uno.UI/ts/Interop/Runtime.ts
@@ -5,5 +5,11 @@
private static init(): any {
return "";
}
+
+ public static InvokeJS(command: string): string {
+ // Preseve the original emscripten marshalling semantics
+ // to always return a valid string.
+ return String(eval(command) || "");
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Uno.UI/ts/MonoSupport.ts b/src/Uno.UI/ts/MonoSupport.ts
index faa7ad6c07bd..949427808fae 100644
--- a/src/Uno.UI/ts/MonoSupport.ts
+++ b/src/Uno.UI/ts/MonoSupport.ts
@@ -22,6 +22,23 @@ namespace MonoSupport {
jsCallDispatcher.registrations.set(identifier, instance);
}
+ public static invokeJSUnmarshalled(funcName: string, arg0: any, arg1: any, arg2: any): void | number {
+ const funcInstance = jsCallDispatcher.findJSFunction(funcName);
+
+ let ret = funcInstance.call(null, arg0, arg1, arg2);
+
+ switch (typeof ret) {
+ case "boolean":
+ return ret ? 1 : 0;
+ case "undefined":
+ return 0;
+ case "number":
+ return ret;
+ default:
+ throw new Error(`Function ${funcName} returned an unsupported type: ${typeof ret}`);
+ }
+ }
+
public static findJSFunction(identifier: string): any {
if (!identifier) {
diff --git a/src/Uno.UI/ts/WindowManager.ts b/src/Uno.UI/ts/WindowManager.ts
index a0ae82cdf15e..dcecfe5dc850 100644
--- a/src/Uno.UI/ts/WindowManager.ts
+++ b/src/Uno.UI/ts/WindowManager.ts
@@ -249,24 +249,6 @@ namespace Uno.UI {
*
* You need to call addView to connect it to the DOM.
*/
- public createContentNative(pParams: number): boolean {
-
- const params = WindowManagerCreateContentParams.unmarshal(pParams);
-
- const def = {
- id: this.handleToString(params.HtmlId),
- handle: params.Handle,
- isFocusable: params.IsFocusable,
- isSvg: params.IsSvg,
- tagName: params.TagName,
- uiElementRegistrationId: params.UIElementRegistrationId,
- } as IContentDefinition;
-
- this.createContentInternal(def);
-
- return true;
- }
-
public createContentNativeFast(
htmlId: number,
tagName: string,
@@ -336,19 +318,6 @@ namespace Uno.UI {
return registrationId;
}
- public registerUIElementNative(pParams: number, pReturn: number): boolean {
- const params = WindowManagerRegisterUIElementParams.unmarshal(pParams);
-
- const registrationId = this.registerUIElement(params.TypeName, params.IsFrameworkElement, params.Classes);
-
- const ret = new WindowManagerRegisterUIElementReturn();
- ret.RegistrationId = registrationId;
-
- ret.marshal(pReturn);
-
- return true;
- }
-
public getView(elementHandle: number): HTMLElement | SVGElement {
const element = this.allActiveElementsById[this.handleToString(elementHandle)];
if (!element) {
@@ -387,12 +356,6 @@ namespace Uno.UI {
this.getView(elementId).setAttribute("xuid", name);
}
- public setVisibilityNative(pParam: number): boolean {
- const params = WindowManagerSetVisibilityParams.unmarshal(pParam);
- this.setVisibilityInternal(params.HtmlId, params.Visible);
- return true;
- }
-
public setVisibilityNativeFast(htmlId: number, visible: boolean) {
this.setVisibilityInternal(htmlId, visible);
@@ -412,18 +375,6 @@ namespace Uno.UI {
/**
* Set an attribute for an element.
*/
- public setAttributesNative(pParams: number): boolean {
-
- const params = WindowManagerSetAttributesParams.unmarshal(pParams);
- const element = this.getView(params.HtmlId);
-
- for (let i = 0; i < params.Pairs_Length; i += 2) {
- element.setAttribute(params.Pairs[i], params.Pairs[i + 1]);
- }
-
- return true;
- }
-
public setAttributesNativeFast(htmlId: number, pairs: string[]) {
const element = this.getView(htmlId);
@@ -438,13 +389,9 @@ namespace Uno.UI {
/**
* Set an attribute for an element.
*/
- public setAttributeNative(pParams: number): boolean {
-
- const params = WindowManagerSetAttributeParams.unmarshal(pParams);
- const element = this.getView(params.HtmlId);
- element.setAttribute(params.Name, params.Value);
-
- return true;
+ public setAttribute(htmlId: number, name: string, value: string) {
+ const element = this.getView(htmlId);
+ element.setAttribute(name, value);
}
/**
@@ -470,15 +417,6 @@ namespace Uno.UI {
/**
* Set a property for an element.
*/
- public setPropertyNative(pParams: number): boolean {
-
- const params = WindowManagerSetPropertyParams.unmarshal(pParams);
-
- this.setPropertyNativeFast(params.HtmlId, params.Pairs);
-
- return true;
- }
-
public setPropertyNativeFast(htmlId: number, pairs: string[]) {
const element = this.getView(htmlId);
@@ -501,15 +439,6 @@ namespace Uno.UI {
}
}
- public setSinglePropertyNative(pParams: number): boolean {
-
- const params = WindowManagerSetSinglePropertyParams.unmarshal(pParams);
-
- this.setSinglePropertyNativeFast(params.HtmlId, params.Name, params.Value);
-
- return true;
- }
-
public setSinglePropertyNativeFast(htmlId: number, name: string, value: string) {
const element = this.getView(htmlId);
@@ -539,24 +468,6 @@ namespace Uno.UI {
* To remove a value, set it to empty string.
* @param styles A dictionary of styles to apply on html element.
*/
- public setStyleNative(pParams: number): boolean {
-
- const params = WindowManagerSetStylesParams.unmarshal(pParams);
- const element = this.getView(params.HtmlId);
-
- const elementStyle = element.style;
- const pairs = params.Pairs;
-
- for (let i = 0; i < params.Pairs_Length; i += 2) {
- const key = pairs[i];
- const value = pairs[i + 1];
-
- elementStyle.setProperty(key, value);
- }
-
- return true;
- }
-
public setStyleNativeFast(htmlId: number, styles: string[]) {
const elementStyle = this.getView(htmlId).style;
@@ -582,15 +493,6 @@ namespace Uno.UI {
return true;
}
- public setStyleStringNative(pParams: number): boolean {
-
- const params = WindowManagerSetStyleStringParams.unmarshal(pParams);
-
- this.getView(params.HtmlId).style.setProperty(params.Name, params.Value);
-
- return true;
- }
-
public setStyleStringNativeFast(htmlId: number, name: string, value: string) {
this.getView(htmlId).style.setProperty(name, value);
@@ -599,13 +501,7 @@ namespace Uno.UI {
/**
* Remove the CSS style of a html element.
*/
- public resetStyleNative(pParams: number): boolean {
- const params = WindowManagerResetStyleParams.unmarshal(pParams);
- this.resetStyleInternal(params.HtmlId, params.Styles);
- return true;
- }
-
- private resetStyleInternal(elementId: number, names: string[]): void {
+ public resetStyle(elementId: number, names: string[]): void {
const element = this.getView(elementId);
for (const name of names) {
@@ -616,11 +512,11 @@ namespace Uno.UI {
public isCssConditionSupported(supportCondition: string): boolean {
return CSS.supports(supportCondition);
}
+
/**
* Set + Unset CSS classes on an element
*/
-
- public setUnsetClasses(elementId: number, cssClassesToSet: string[], cssClassesToUnset: string[]) {
+ public setUnsetCssClasses(elementId: number, cssClassesToSet: string[], cssClassesToUnset: string[]) {
const element = this.getView(elementId);
if (cssClassesToSet) {
@@ -635,16 +531,10 @@ namespace Uno.UI {
}
}
- public setUnsetClassesNative(pParams: number): boolean {
- const params = WindowManagerSetUnsetClassesParams.unmarshal(pParams);
- this.setUnsetClasses(params.HtmlId, params.CssClassesToSet, params.CssClassesToUnset);
- return true;
- }
-
/**
* Set CSS classes on an element from a specified list
*/
- public setClasses(elementId: number, cssClassesList: string[], classIndex: number): string {
+ public setClasses(elementId: number, cssClassesList: string[], classIndex: number) {
const element = this.getView(elementId);
for (let i = 0; i < cssClassesList.length; i++) {
@@ -654,38 +544,12 @@ namespace Uno.UI {
element.classList.remove(cssClassesList[i]);
}
}
- return "ok";
- }
-
- public setClassesNative(pParams: number): boolean {
- const params = WindowManagerSetClassesParams.unmarshal(pParams);
- this.setClasses(params.HtmlId, params.CssClasses, params.Index);
- return true;
}
/**
* Arrange and clips a native elements
*
*/
- public arrangeElementNative(pParams: number): boolean {
-
- const params = WindowManagerArrangeElementParams.unmarshal(pParams);
-
- this.arrangeElementNativeFast(
- params.HtmlId,
- params.Top,
- params.Left,
- params.Width,
- params.Height,
- params.Clip,
- params.ClipTop,
- params.ClipLeft,
- params.ClipBottom,
- params.ClipRight);
-
- return true;
- }
-
public arrangeElementNativeFast(
htmlId: number,
top: number,
@@ -829,15 +693,6 @@ namespace Uno.UI {
* Sets the transform matrix of an element
*
*/
- public setElementTransformNative(pParams: number): boolean {
-
- const params = WindowManagerSetElementTransformParams.unmarshal(pParams);
-
- this.setElementTransformNativeFast(params.HtmlId, params.M11, params.M12, params.M21, params.M22, params.M31, params.M32);
-
- return true;
- }
-
public setElementTransformNativeFast(
htmlId: number,
m11: number,
@@ -1199,21 +1054,6 @@ namespace Uno.UI {
* @param maxWidth string containing width in pixels. Empty string means infinite.
* @param maxHeight string containing height in pixels. Empty string means infinite.
*/
- public measureViewNative(pParams: number, pReturn: number): boolean {
-
- const params = WindowManagerMeasureViewParams.unmarshal(pParams);
-
- const ret = this.measureViewInternal(params.HtmlId, params.AvailableWidth, params.AvailableHeight, params.MeasureContent);
-
- const ret2 = new WindowManagerMeasureViewReturn();
- ret2.DesiredWidth = ret[0];
- ret2.DesiredHeight = ret[1];
-
- ret2.marshal(pReturn);
-
- return true;
- }
-
public measureViewNativeFast(htmlId: number, availableWidth: number, availableHeight: number, measureContent: boolean, pReturn: number) {
const result = this.measureViewInternal(htmlId, availableWidth, availableHeight, measureContent);
diff --git a/src/Uno.UI/ts/Windows/Storage/ApplicationDataContainer.ts b/src/Uno.UI/ts/Windows/Storage/ApplicationDataContainer.ts
index 0c79c6ee25e4..50e89a00fe96 100644
--- a/src/Uno.UI/ts/Windows/Storage/ApplicationDataContainer.ts
+++ b/src/Uno.UI/ts/Windows/Storage/ApplicationDataContainer.ts
@@ -13,41 +13,24 @@ namespace Windows.Storage {
/**
* Try to get a value from localStorage
* */
- private static tryGetValue(pParams: number, pReturn: number): boolean {
- const params = ApplicationDataContainer_TryGetValueParams.unmarshal(pParams);
- const ret = new ApplicationDataContainer_TryGetValueReturn();
+ private static getValue(locality: string, key: string): string {
+ const storageKey = ApplicationDataContainer.buildStorageKey(locality, key);
- const storageKey = ApplicationDataContainer.buildStorageKey(params.Locality, params.Key);
-
- try {
- if (localStorage.hasOwnProperty(storageKey)) {
- ret.HasValue = true;
- ret.Value = localStorage.getItem(storageKey);
- } else {
- ret.Value = "";
- ret.HasValue = false;
- }
- } catch (e) {
- ret.Value = "";
- ret.HasValue = false;
- console.debug(`ApplicationDataContainer.tryGetValue failed: ${e}`);
+ if (localStorage.hasOwnProperty(storageKey)) {
+ return localStorage.getItem(storageKey);
+ } else {
+ throw `ApplicationDataContainer.getValue failed for ${storageKey}`;
}
-
- ret.marshal(pReturn);
-
- return true;
}
/**
* Set a value to localStorage
* */
- private static setValue(pParams: number): boolean {
+ private static setValue(locality: string, key: string, value: string): boolean {
try {
- const params = ApplicationDataContainer_SetValueParams.unmarshal(pParams);
-
- const storageKey = ApplicationDataContainer.buildStorageKey(params.Locality, params.Key);
+ const storageKey = ApplicationDataContainer.buildStorageKey(locality, key);
- localStorage.setItem(storageKey, params.Value);
+ localStorage.setItem(storageKey, value);
} catch (e) {
console.debug(`ApplicationDataContainer.setValue failed: ${e}`);
}
@@ -58,34 +41,23 @@ namespace Windows.Storage {
/**
* Determines if a key is contained in localStorage
* */
- private static containsKey(pParams: number, pReturn: number): boolean {
- const params = ApplicationDataContainer_ContainsKeyParams.unmarshal(pParams);
- const ret = new ApplicationDataContainer_ContainsKeyReturn();
-
- const storageKey = ApplicationDataContainer.buildStorageKey(params.Locality, params.Key);
+ private static containsKey(locality: string, key: string): boolean {
+ const storageKey = ApplicationDataContainer.buildStorageKey(locality, key);
try {
- ret.ContainsKey = localStorage.hasOwnProperty(storageKey);
+ return localStorage.hasOwnProperty(storageKey);
} catch (e) {
- ret.ContainsKey = false;
- console.debug(`ApplicationDataContainer.containsKey failed: ${e}`);
+ throw `ApplicationDataContainer.containsKey failed: ${e}`;
}
-
- ret.marshal(pReturn);
-
- return true;
}
/**
* Gets a key by index in localStorage
* */
- private static getKeyByIndex(pParams: number, pReturn: number): boolean {
- const params = ApplicationDataContainer_GetKeyByIndexParams.unmarshal(pParams);
- const ret = new ApplicationDataContainer_GetKeyByIndexReturn();
-
+ private static getKeyByIndex(locality: string, index: number): string {
let localityIndex = 0;
let returnKey = "";
- const prefix = ApplicationDataContainer.buildStoragePrefix(params.Locality);
+ const prefix = ApplicationDataContainer.buildStoragePrefix(locality);
try {
for (let i = 0; i < localStorage.length; i++) {
@@ -93,58 +65,45 @@ namespace Windows.Storage {
if (storageKey.startsWith(prefix)) {
- if (localityIndex === params.Index) {
- returnKey = storageKey.substr(prefix.length);
+ if (localityIndex === index) {
+ return storageKey.substr(prefix.length);
}
localityIndex++;
}
}
} catch (e) {
- console.debug(`ApplicationDataContainer.getKeyByIndex failed: ${e}`);
+ throw `ApplicationDataContainer.getKeyByIndex failed: ${e}`;
}
-
- ret.Value = returnKey;
-
- ret.marshal(pReturn);
-
- return true;
}
/**
* Determines the number of items contained in localStorage
* */
- private static getCount(pParams: number, pReturn: number): boolean {
- const params = ApplicationDataContainer_GetCountParams.unmarshal(pParams);
- const ret = new ApplicationDataContainer_GetCountReturn();
-
- ret.Count = 0;
- const prefix = ApplicationDataContainer.buildStoragePrefix(params.Locality);
+ private static getCount(locality: string): number {
+ let count = 0;
+ const prefix = ApplicationDataContainer.buildStoragePrefix(locality);
try {
for (let i = 0; i < localStorage.length; i++) {
const storageKey = localStorage.key(i);
if (storageKey.startsWith(prefix)) {
- ret.Count++;
+ count++;
}
}
} catch (e) {
console.debug(`ApplicationDataContainer.getCount failed: ${e}`);
}
- ret.marshal(pReturn);
-
- return true;
+ return count;
}
/**
* Clears items contained in localStorage
* */
- private static clear(pParams: number): boolean {
- const params = ApplicationDataContainer_ClearParams.unmarshal(pParams);
-
- const prefix = ApplicationDataContainer.buildStoragePrefix(params.Locality);
+ private static clear(locality: string) {
+ const prefix = ApplicationDataContainer.buildStoragePrefix(locality);
const itemsToRemove: string[] = [];
@@ -161,47 +120,39 @@ namespace Windows.Storage {
localStorage.removeItem(itemsToRemove[item]);
}
} catch (e) {
- console.debug(`ApplicationDataContainer.clear failed: ${e}`);
+ throw `ApplicationDataContainer.clear failed: ${e}`;
}
-
- return true;
}
/**
* Removes an item contained in localStorage
* */
- private static remove(pParams: number, pReturn: number): boolean {
- const params = ApplicationDataContainer_RemoveParams.unmarshal(pParams);
- const ret = new ApplicationDataContainer_RemoveReturn();
+ private static remove(locality: string, key: string): boolean {
+ const storageKey = ApplicationDataContainer.buildStorageKey(locality, key);
- const storageKey = ApplicationDataContainer.buildStorageKey(params.Locality, params.Key);
+ let remove = false;
try {
- ret.Removed = localStorage.hasOwnProperty(storageKey);
+ remove = localStorage.hasOwnProperty(storageKey);
} catch (e) {
- ret.Removed = false;
+ remove = false;
console.debug(`ApplicationDataContainer.remove failed: ${e}`);
}
- if (ret.Removed) {
+ if (remove) {
localStorage.removeItem(storageKey);
}
- ret.marshal(pReturn);
-
- return true;
+ return remove;
}
/**
* Gets a key by index in localStorage
* */
- private static getValueByIndex(pParams: number, pReturn: number): boolean {
- const params = ApplicationDataContainer_GetValueByIndexParams.unmarshal(pParams);
- const ret = new ApplicationDataContainer_GetKeyByIndexReturn();
-
+ private static getValueByIndex(locality: string, index: number): string {
let localityIndex = 0;
let returnKey = "";
- const prefix = ApplicationDataContainer.buildStoragePrefix(params.Locality);
+ const prefix = ApplicationDataContainer.buildStoragePrefix(locality);
try {
for (let i = 0; i < localStorage.length; i++) {
@@ -209,23 +160,16 @@ namespace Windows.Storage {
if (storageKey.startsWith(prefix)) {
- if (localityIndex === params.Index) {
- returnKey = localStorage.getItem(storageKey);
+ if (localityIndex === index) {
+ return localStorage.getItem(storageKey);
}
localityIndex++;
}
}
} catch (e) {
- console.debug(`ApplicationDataContainer.getValueByIndex failed: ${e}`);
+ throw `ApplicationDataContainer.getValueByIndex failed: ${e}`;
}
-
- ret.Value = returnKey;
-
- ret.marshal(pReturn);
-
- return true;
}
-
}
}
diff --git a/src/Uno.UI/ts/Windows/Storage/StorageFolder.ts b/src/Uno.UI/ts/Windows/Storage/StorageFolder.ts
index 6c625e95d779..6e888b4fbeab 100644
--- a/src/Uno.UI/ts/Windows/Storage/StorageFolder.ts
+++ b/src/Uno.UI/ts/Windows/Storage/StorageFolder.ts
@@ -23,11 +23,9 @@ namespace Windows.Storage {
/**
* Setup the storage persistence of a given set of paths.
* */
- private static makePersistent(pParams: number): void {
- const params = StorageFolderMakePersistentParams.unmarshal(pParams);
-
- for (var i = 0; i < params.Paths.length; i++) {
- this.setupStorage(params.Paths[i])
+ private static makePersistent(paths: string[]): void {
+ for (var i = 0; i < paths.length; i++) {
+ this.setupStorage(paths[i]);
}
// Ensure to sync pseudo file system on unload (and periodically for safety)
diff --git a/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerEventArgs.ts b/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerEventArgs.ts
deleted file mode 100644
index 33a6b9d3ce9b..000000000000
--- a/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerEventArgs.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-namespace Microsoft.UI.Xaml
-{
- export class NativePointerEventArgs
- {
- /* Pack=4 */
- public HtmlId : number;
- public Event : number;
- public pointerId : number;
- public x : number;
- public y : number;
- public ctrl : boolean;
- public shift : boolean;
- public buttons : number;
- public buttonUpdate : number;
- public deviceType : number;
- public srcHandle : number;
- public timestamp : number;
- public pressure : number;
- public wheelDeltaX : number;
- public wheelDeltaY : number;
- public hasRelatedTarget : boolean;
- public marshal(pData:number)
- {
- Module.setValue(pData + 0, this.HtmlId, "*");
- Module.setValue(pData + 4, this.Event, "i8");
- Module.setValue(pData + 8, this.pointerId, "double");
- Module.setValue(pData + 16, this.x, "double");
- Module.setValue(pData + 24, this.y, "double");
- Module.setValue(pData + 32, this.ctrl, "i32");
- Module.setValue(pData + 36, this.shift, "i32");
- Module.setValue(pData + 40, this.buttons, "i32");
- Module.setValue(pData + 44, this.buttonUpdate, "i32");
- Module.setValue(pData + 48, this.deviceType, "i32");
- Module.setValue(pData + 52, this.srcHandle, "i32");
- Module.setValue(pData + 56, this.timestamp, "double");
- Module.setValue(pData + 64, this.pressure, "double");
- Module.setValue(pData + 72, this.wheelDeltaX, "double");
- Module.setValue(pData + 80, this.wheelDeltaY, "double");
- Module.setValue(pData + 88, this.hasRelatedTarget, "i32");
- }
- }
-}
diff --git a/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerEventResult.ts b/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerEventResult.ts
deleted file mode 100644
index 6759286e0866..000000000000
--- a/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerEventResult.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-namespace Microsoft.UI.Xaml
-{
- export class NativePointerEventResult
- {
- /* Pack=4 */
- public Result : number;
- public static unmarshal(pData:number) : NativePointerEventResult
- {
- const ret = new NativePointerEventResult();
-
- {
- ret.Result = Number(Module.getValue(pData + 0, "i8"));
- }
- return ret;
- }
- }
-}
diff --git a/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerSubscriptionParams.ts b/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerSubscriptionParams.ts
deleted file mode 100644
index d02080078d42..000000000000
--- a/src/Uno.UI/tsBindings/Microsoft_UI_Xaml_NativePointerSubscriptionParams.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-namespace Microsoft.UI.Xaml
-{
- export class NativePointerSubscriptionParams
- {
- /* Pack=4 */
- public HtmlId : number;
- public Events : number;
- public static unmarshal(pData:number) : NativePointerSubscriptionParams
- {
- const ret = new NativePointerSubscriptionParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.Events = Number(Module.getValue(pData + 4, "i8"));
- }
- return ret;
- }
- }
-}
diff --git a/src/Uno.UI/tsBindings/WindowManagerArrangeElementParams.ts b/src/Uno.UI/tsBindings/WindowManagerArrangeElementParams.ts
deleted file mode 100644
index de4d7ef72fb4..000000000000
--- a/src/Uno.UI/tsBindings/WindowManagerArrangeElementParams.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-class WindowManagerArrangeElementParams
-{
- /* Pack=4 */
- public Top : number;
- public Left : number;
- public Width : number;
- public Height : number;
- public ClipTop : number;
- public ClipLeft : number;
- public ClipBottom : number;
- public ClipRight : number;
- public HtmlId : number;
- public Clip : boolean;
- public static unmarshal(pData:number) : WindowManagerArrangeElementParams
- {
- const ret = new WindowManagerArrangeElementParams();
-
- {
- ret.Top = Number(Module.getValue(pData + 0, "double"));
- }
-
- {
- ret.Left = Number(Module.getValue(pData + 8, "double"));
- }
-
- {
- ret.Width = Number(Module.getValue(pData + 16, "double"));
- }
-
- {
- ret.Height = Number(Module.getValue(pData + 24, "double"));
- }
-
- {
- ret.ClipTop = Number(Module.getValue(pData + 32, "double"));
- }
-
- {
- ret.ClipLeft = Number(Module.getValue(pData + 40, "double"));
- }
-
- {
- ret.ClipBottom = Number(Module.getValue(pData + 48, "double"));
- }
-
- {
- ret.ClipRight = Number(Module.getValue(pData + 56, "double"));
- }
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 64, "*"));
- }
-
- {
- ret.Clip = Boolean(Module.getValue(pData + 68, "i32"));
- }
- return ret;
- }
-}
diff --git a/src/Uno.UI/tsBindings/WindowManagerCreateContentParams.ts b/src/Uno.UI/tsBindings/WindowManagerCreateContentParams.ts
deleted file mode 100644
index ee5c8215b5fd..000000000000
--- a/src/Uno.UI/tsBindings/WindowManagerCreateContentParams.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-class WindowManagerCreateContentParams
-{
- /* Pack=4 */
- public HtmlId : number;
- public TagName : string;
- public Handle : number;
- public UIElementRegistrationId : number;
- public IsSvg : boolean;
- public IsFocusable : boolean;
- public static unmarshal(pData:number) : WindowManagerCreateContentParams
- {
- const ret = new WindowManagerCreateContentParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- const ptr = Module.getValue(pData + 4, "*");
- if(ptr !== 0)
- {
- ret.TagName = String(Module.UTF8ToString(ptr));
- }
- else
-
- {
- ret.TagName = null;
- }
- }
-
- {
- ret.Handle = Number(Module.getValue(pData + 8, "*"));
- }
-
- {
- ret.UIElementRegistrationId = Number(Module.getValue(pData + 12, "i32"));
- }
-
- {
- ret.IsSvg = Boolean(Module.getValue(pData + 16, "i32"));
- }
-
- {
- ret.IsFocusable = Boolean(Module.getValue(pData + 20, "i32"));
- }
- return ret;
- }
-}
diff --git a/src/Uno.UI/tsBindings/WindowManagerDestroyViewParams.ts b/src/Uno.UI/tsBindings/WindowManagerDestroyViewParams.ts
deleted file mode 100644
index 529776a27cfd..000000000000
--- a/src/Uno.UI/tsBindings/WindowManagerDestroyViewParams.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-class WindowManagerDestroyViewParams
-{
- /* Pack=4 */
- public HtmlId : number;
- public static unmarshal(pData:number) : WindowManagerDestroyViewParams
- {
- const ret = new WindowManagerDestroyViewParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
- return ret;
- }
-}
diff --git a/src/Uno.UI/tsBindings/WindowManagerMeasureViewParams.ts b/src/Uno.UI/tsBindings/WindowManagerMeasureViewParams.ts
deleted file mode 100644
index c0e252702c1f..000000000000
--- a/src/Uno.UI/tsBindings/WindowManagerMeasureViewParams.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-class WindowManagerMeasureViewParams
-{
- /* Pack=8 */
- public HtmlId : number;
- public AvailableWidth : number;
- public AvailableHeight : number;
- public MeasureContent : boolean;
- public static unmarshal(pData:number) : WindowManagerMeasureViewParams
- {
- const ret = new WindowManagerMeasureViewParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.AvailableWidth = Number(Module.getValue(pData + 8, "double"));
- }
-
- {
- ret.AvailableHeight = Number(Module.getValue(pData + 16, "double"));
- }
-
- {
- ret.MeasureContent = Boolean(Module.getValue(pData + 24, "i32"));
- }
- return ret;
- }
-}
diff --git a/src/Uno.UI/tsBindings/WindowManagerRegisterPointerEventsOnViewParams.ts b/src/Uno.UI/tsBindings/WindowManagerRegisterPointerEventsOnViewParams.ts
deleted file mode 100644
index 2eb1db70cd24..000000000000
--- a/src/Uno.UI/tsBindings/WindowManagerRegisterPointerEventsOnViewParams.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-class WindowManagerRegisterPointerEventsOnViewParams
-{
- /* Pack=4 */
- public HtmlId : number;
- public static unmarshal(pData:number) : WindowManagerRegisterPointerEventsOnViewParams
- {
- const ret = new WindowManagerRegisterPointerEventsOnViewParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
- return ret;
- }
-}
diff --git a/src/Uno.UI/tsBindings/WindowManagerRegisterUIElementParams.ts b/src/Uno.UI/tsBindings/WindowManagerRegisterUIElementParams.ts
deleted file mode 100644
index e9d5c838ad0b..000000000000
--- a/src/Uno.UI/tsBindings/WindowManagerRegisterUIElementParams.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
-class WindowManagerRegisterUIElementParams
-{
- /* Pack=4 */
- public TypeName : string;
- public IsFrameworkElement : boolean;
- public Classes_Length : number;
- public Classes : Array;
- public static unmarshal(pData:number) : WindowManagerRegisterUIElementParams
- {
- const ret = new WindowManagerRegisterUIElementParams();
-
- {
- const ptr = Module.getValue(pData + 0, "*");
- if(ptr !== 0)
- {
- ret.TypeName = String(Module.UTF8ToString(ptr));
- }
- else
-
- {
- ret.TypeName = null;
- }
- }
-
- {
- ret.IsFrameworkElement = Boolean(Module.getValue(pData + 4, "i32"));
- }
-
- {
- ret.Classes_Length = Number(Module.getValue(pData + 8, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 12, "*");
- if(pArray !== 0)
- {
- ret.Classes = new Array();
- for(var i=0; i;
- public static unmarshal(pData:number) : WindowManagerResetStyleParams
- {
- const ret = new WindowManagerResetStyleParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.Styles_Length = Number(Module.getValue(pData + 4, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 8, "*");
- if(pArray !== 0)
- {
- ret.Styles = new Array();
- for(var i=0; i;
- public static unmarshal(pData:number) : WindowManagerSetAttributesParams
- {
- const ret = new WindowManagerSetAttributesParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.Pairs_Length = Number(Module.getValue(pData + 4, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 8, "*");
- if(pArray !== 0)
- {
- ret.Pairs = new Array();
- for(var i=0; i;
- public Index : number;
- public static unmarshal(pData:number) : WindowManagerSetClassesParams
- {
- const ret = new WindowManagerSetClassesParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.CssClasses_Length = Number(Module.getValue(pData + 4, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 8, "*");
- if(pArray !== 0)
- {
- ret.CssClasses = new Array();
- for(var i=0; i;
- public static unmarshal(pData:number) : WindowManagerSetPropertyParams
- {
- const ret = new WindowManagerSetPropertyParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.Pairs_Length = Number(Module.getValue(pData + 4, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 8, "*");
- if(pArray !== 0)
- {
- ret.Pairs = new Array();
- for(var i=0; i;
- public static unmarshal(pData:number) : WindowManagerSetStylesParams
- {
- const ret = new WindowManagerSetStylesParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.Pairs_Length = Number(Module.getValue(pData + 4, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 8, "*");
- if(pArray !== 0)
- {
- ret.Pairs = new Array();
- for(var i=0; i;
- public CssClassesToUnset_Length : number;
- public CssClassesToUnset : Array;
- public static unmarshal(pData:number) : WindowManagerSetUnsetClassesParams
- {
- const ret = new WindowManagerSetUnsetClassesParams();
-
- {
- ret.HtmlId = Number(Module.getValue(pData + 0, "*"));
- }
-
- {
- ret.CssClassesToSet_Length = Number(Module.getValue(pData + 4, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 8, "*");
- if(pArray !== 0)
- {
- ret.CssClassesToSet = new Array();
- for(var i=0; i();
- for(var i=0; i;
- public static unmarshal(pData:number) : StorageFolderMakePersistentParams
- {
- const ret = new StorageFolderMakePersistentParams();
-
- {
- ret.Paths_Length = Number(Module.getValue(pData + 0, "i32"));
- }
-
- {
- const pArray = Module.getValue(pData + 4, "*");
- if(pArray !== 0)
- {
- ret.Paths = new Array();
- for(var i=0; i SetValue(locality.ToStringInvariant(), key, value);
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_SetValueParams
- {
- public string Key;
- public string Value;
- public string Locality;
- }
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.setValue")]
+ private static partial void SetValue(string locality, string key, string value);
- #endregion
-
- #region ContainsKey
internal static bool ContainsKey(ApplicationDataLocality locality, string key)
- {
- var parms = new ApplicationDataContainer_ContainsKeyParams
- {
- Key = key,
- Locality = locality.ToStringInvariant()
- };
-
- var ret = (ApplicationDataContainer_ContainsKeyReturn)TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_ApplicationDataContainer:containsKey", parms, typeof(ApplicationDataContainer_ContainsKeyReturn));
- return ret.ContainsKey;
- }
+ => ContainsKey(locality.ToStringInvariant(), key);
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_ContainsKeyParams
- {
- public string Key;
- public string Value;
- public string Locality;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_ContainsKeyReturn
- {
- public bool ContainsKey;
- }
- #endregion
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.containsKey")]
+ private static partial bool ContainsKey(string locality, string key);
- #region GetKeyByIndex
internal static string GetKeyByIndex(ApplicationDataLocality locality, int index)
- {
- var parms = new ApplicationDataContainer_GetKeyByIndexParams
- {
- Locality = locality.ToStringInvariant(),
- Index = index
- };
-
- var ret = (ApplicationDataContainer_GetKeyByIndexReturn)TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_ApplicationDataContainer:getKeyByIndex", parms, typeof(ApplicationDataContainer_GetKeyByIndexReturn));
- return ret.Value;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_GetKeyByIndexParams
- {
- public string Locality;
- public int Index;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_GetKeyByIndexReturn
- {
- public string Value;
- }
- #endregion
+ => GetKeyByIndex(locality.ToStringInvariant(), index);
- #region GetCount
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.getKeyByIndex")]
+ private static partial string GetKeyByIndex(string locality, int index);
internal static int GetCount(ApplicationDataLocality locality)
- {
- var parms = new ApplicationDataContainer_GetCountParams
- {
- Locality = locality.ToStringInvariant()
- };
-
- var ret = (ApplicationDataContainer_GetCountReturn)TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_ApplicationDataContainer:getCount", parms, typeof(ApplicationDataContainer_GetCountReturn));
- return ret.Count;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_GetCountParams
- {
- public string Locality;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_GetCountReturn
- {
- public int Count;
- }
- #endregion
+ => GetCount(locality.ToStringInvariant());
- #region Clear
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.getCount")]
+ private static partial int GetCount(string locality);
internal static void Clear(ApplicationDataLocality locality)
- {
- var parms = new ApplicationDataContainer_ClearParams
- {
- Locality = locality.ToStringInvariant()
- };
-
- TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_ApplicationDataContainer:clear", parms);
- }
+ => Clear(locality.ToStringInvariant());
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_ClearParams
- {
- public string Locality;
- }
-
- #endregion
-
- #region Remove
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.clear")]
+ private static partial void Clear(string locality);
internal static bool Remove(ApplicationDataLocality locality, string key)
- {
- var parms = new ApplicationDataContainer_RemoveParams
- {
- Locality = locality.ToStringInvariant(),
- Key = key
- };
-
- var ret = (ApplicationDataContainer_RemoveReturn)TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_ApplicationDataContainer:remove", parms, typeof(ApplicationDataContainer_RemoveReturn));
- return ret.Removed;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_RemoveParams
- {
- public string Locality;
- public string Key;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- private struct ApplicationDataContainer_RemoveReturn
- {
- public bool Removed;
- }
-
- #endregion
+ => Remove(locality.ToStringInvariant(), key);
- #region GetValueByIndex
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.remove")]
+ private static partial bool Remove(string locality, string key);
internal static string GetValueByIndex(ApplicationDataLocality locality, int index)
- {
- var parms = new ApplicationDataContainer_GetValueByIndexParams
- {
- Locality = locality.ToStringInvariant(),
- Index = index
- };
+ => GetValueByIndex(locality.ToStringInvariant(), index);
- var ret = (ApplicationDataContainer_GetValueByIndexReturn)TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_ApplicationDataContainer:getValueByIndex", parms, typeof(ApplicationDataContainer_GetValueByIndexReturn));
- return ret.Value;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct ApplicationDataContainer_GetValueByIndexParams
- {
- public string Locality;
- public int Index;
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- private struct ApplicationDataContainer_GetValueByIndexReturn
- {
- public string Value;
- }
- #endregion
+ [JSImport("globalThis.Windows.Storage.ApplicationDataContainer.getValueByIndex")]
+ private static partial string GetValueByIndex(string locality, int index);
}
}
diff --git a/src/Uno.UWP/Storage/StorageFolder.native.Interop.wasm.cs b/src/Uno.UWP/Storage/StorageFolder.native.Interop.wasm.cs
index 93db9b80673b..da361b714c36 100644
--- a/src/Uno.UWP/Storage/StorageFolder.native.Interop.wasm.cs
+++ b/src/Uno.UWP/Storage/StorageFolder.native.Interop.wasm.cs
@@ -9,6 +9,9 @@ internal static partial class NativeMethods
{
private const string JsType = "globalThis.Uno.Storage.NativeStorageFolder";
+ [JSImport("globalThis.Windows.Storage.StorageFolder.makePersistent")]
+ internal static partial void MakePersistent(string[] folders);
+
[JSImport($"{JsType}.createFileAsync")]
internal static partial Task CreateFileAsync(string id, string name);
diff --git a/src/Uno.UWP/Storage/StorageFolder.wasm.cs b/src/Uno.UWP/Storage/StorageFolder.wasm.cs
index 39c800f28c59..84d33f47878b 100644
--- a/src/Uno.UWP/Storage/StorageFolder.wasm.cs
+++ b/src/Uno.UWP/Storage/StorageFolder.wasm.cs
@@ -9,6 +9,7 @@
using Uno.Extensions;
using System.Threading.Tasks;
using Uno.Foundation.Logging;
+using NativeMethods = __Windows.Storage.StorageFolder.NativeMethods;
namespace Windows.Storage
{
@@ -35,25 +36,7 @@ private static async Task TryInitializeStorage()
}
internal static void MakePersistent(params StorageFolder[] folders)
- {
- var parms = new StorageFolderMakePersistentParams()
- {
- Paths = folders.SelectToArray(f => f.Path),
- Paths_Length = folders.Length
- };
-
- TSInteropMarshaller.InvokeJS("UnoStatic_Windows_Storage_StorageFolder:makePersistent", parms);
- }
-
- [TSInteropMessage]
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- private struct StorageFolderMakePersistentParams
- {
- public int Paths_Length;
-
- [MarshalAs(UnmanagedType.LPArray, ArraySubType = TSInteropMarshaller.LPUTF8Str)]
- public string[] Paths;
- }
+ => NativeMethods.MakePersistent(folders.SelectToArray(f => f.Path));
[JSExport]
internal static void DispatchStorageInitialized()