Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
09be506b
U
Uno
项目概览
lindexi_gd
/
Uno
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
Uno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
09be506b
编写于
4月 05, 2023
作者:
E
Elie Bariche
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Initialize WindowManager asynchronously
上级
d010280f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
42 addition
and
66 deletion
+42
-66
src/Uno.UI/UI/Xaml/Application.wasm.cs
src/Uno.UI/UI/Xaml/Application.wasm.cs
+22
-9
src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs
src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs
+10
-19
src/Uno.UI/ts/MonoSupport.ts
src/Uno.UI/ts/MonoSupport.ts
+0
-1
src/Uno.UI/ts/WindowManager.ts
src/Uno.UI/ts/WindowManager.ts
+10
-22
src/Uno.UI/tsBindings/WindowManagerInitParams.ts
src/Uno.UI/tsBindings/WindowManagerInitParams.ts
+0
-15
未找到文件。
src/Uno.UI/UI/Xaml/Application.wasm.cs
浏览文件 @
09be506b
...
...
@@ -13,6 +13,7 @@ using Uno.Foundation;
using
Uno.Extensions
;
using
Uno.Foundation.Logging
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Uno.UI
;
using
Uno.UI.Xaml
;
using
Uno
;
...
...
@@ -84,19 +85,31 @@ namespace Windows.UI.Xaml
return
0
;
}
static
partial
void
StartPartial
(
ApplicationInitializationCallback
callback
)
static
async
partial
void
StartPartial
(
ApplicationInitializationCallback
callback
)
{
_startInvoked
=
true
;
try
{
_startInvoked
=
true
;
SynchronizationContext
.
SetSynchronizationContext
(
new
CoreDispatcherSynchronizationContext
(
CoreDispatcher
.
Main
,
CoreDispatcherPriority
.
Normal
)
);
var
isLoadEventsEnabled
=
!
FeatureConfiguration
.
FrameworkElement
.
WasmUseManagedLoadedUnloaded
;
WindowManagerInterop
.
Init
(
isLoadEventsEnabled
);
Windows
.
Storage
.
ApplicationData
.
Init
();
var
isLoadEventsEnabled
=
!
FeatureConfiguration
.
FrameworkElement
.
WasmUseManagedLoadedUnloaded
;
SynchronizationContext
.
SetSynchronizationContext
(
new
CoreDispatcherSynchronizationContext
(
CoreDispatcher
.
Main
,
CoreDispatcherPriority
.
Normal
)
);
await
WindowManagerInterop
.
InitAsync
(
isLoadEventsEnabled
);
callback
(
new
ApplicationInitializationCallbackParams
());
Windows
.
Storage
.
ApplicationData
.
Init
();
callback
(
new
ApplicationInitializationCallbackParams
());
}
catch
(
Exception
exception
)
{
if
(
typeof
(
Application
).
Log
().
IsEnabled
(
LogLevel
.
Error
))
{
typeof
(
Application
).
Log
().
LogError
(
"Application initialization failed."
,
exception
);
}
}
}
partial
void
ObserveSystemThemeChanges
()
...
...
src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs
浏览文件 @
09be506b
...
...
@@ -27,25 +27,13 @@ namespace Uno.UI.Xaml
//When users set double.MaxValue to scroll to the end of the page Javascript doesn't scroll.
private
const
double
MAX_SCROLLING_OFFSET
=
1
_000_000_000_000_000_000
;
#
region
Init
internal
static
void
Init
(
bool
isLoadEventsEnabled
)
{
var
parms
=
new
WindowManagerInitParams
{
IsLoadEventsEnabled
=
isLoadEventsEnabled
};
TSInteropMarshaller
.
InvokeJS
(
"UnoStatic:initNative"
,
parms
);
}
[
TSInteropMessage
]
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
4
)]
private
struct
WindowManagerInitParams
{
public
bool
IsLoadEventsEnabled
;
}
#
endregion
internal
static
Task
InitAsync
(
bool
isLoadEventsEnabled
)
=>
#if NET7_0_OR_GREATER
NativeMethods
.
InitAsync
(
isLoadEventsEnabled
);
#else
WebAssemblyRuntime
.
InvokeAsync
(
$"Uno.UI.WindowManager.init(
{(
isLoadEventsEnabled
?
"true"
:
"false"
)}
)"
);
#endif
internal
static
string
FindLaunchArguments
()
=>
...
...
@@ -1314,6 +1302,9 @@ namespace Uno.UI.Xaml
[
JSImport
(
"globalThis.Uno.UI.WindowManager.current.getProperty"
)]
internal
static
partial
string
GetProperty
(
IntPtr
htmlId
,
string
name
);
[
JSImport
(
"globalThis.Uno.UI.WindowManager.init"
)]
internal
static
partial
Task
InitAsync
(
bool
isLoadEventsEnabled
);
[
JSImport
(
"globalThis.Uno.UI.WindowManager.current.measureViewNativeFast"
)]
internal
static
partial
void
MeasureView
(
IntPtr
htmlId
,
double
availableWidth
,
double
availableHeight
,
bool
measureContent
,
IntPtr
pReturn
);
...
...
src/Uno.UI/ts/MonoSupport.ts
浏览文件 @
09be506b
...
...
@@ -29,7 +29,6 @@ namespace MonoSupport {
}
else
{
if
(
!
jsCallDispatcher
.
_isUnoRegistered
)
{
jsCallDispatcher
.
registerScope
(
"
UnoStatic
"
,
Uno
.
UI
.
WindowManager
);
jsCallDispatcher
.
registerScope
(
"
UnoStatic_Windows_Storage_StorageFolder
"
,
Windows
.
Storage
.
StorageFolder
);
jsCallDispatcher
.
registerScope
(
"
UnoStatic_Windows_Storage_ApplicationDataContainer
"
,
Windows
.
Storage
.
ApplicationDataContainer
);
jsCallDispatcher
.
registerScope
(
"
UnoStatic_Windows_ApplicationModel_DataTransfer_DragDrop_Core_DragDropExtension
"
,
Windows
.
ApplicationModel
.
DataTransfer
.
DragDrop
.
Core
.
DragDropExtension
);
...
...
src/Uno.UI/ts/WindowManager.ts
浏览文件 @
09be506b
...
...
@@ -20,17 +20,16 @@ namespace Uno.UI {
private
static
readonly
unoUnarrangedClassName
=
"
uno-unarranged
"
;
private
static
readonly
unoCollapsedClassName
=
"
uno-visibility-collapsed
"
;
private
static
_cctor
=
(()
=>
{
WindowManager
.
initMethods
();
HtmlDom
.
initPolyfills
();
})();
/**
* Initialize the WindowManager
* @param containerElementId The ID of the container element for the Xaml UI
* @param loadingElementId The ID of the loading element to remove once ready
*/
public
static
init
(
isLoadEventsEnabled
:
boolean
,
containerElementId
:
string
=
"
uno-body
"
,
loadingElementId
:
string
=
"
uno-loading
"
):
void
{
public
static
async
init
(
isLoadEventsEnabled
:
boolean
,
containerElementId
:
string
=
"
uno-body
"
,
loadingElementId
:
string
=
"
uno-loading
"
)
{
HtmlDom
.
initPolyfills
();
await
WindowManager
.
initMethods
();
WindowManager
.
_isLoadEventsEnabled
=
isLoadEventsEnabled
;
...
...
@@ -48,7 +47,7 @@ namespace Uno.UI {
private
static
buildReadyPromise
():
Promise
<
boolean
>
{
return
new
Promise
<
boolean
>
(
resolve
=>
{
Promise
.
all
(
[
WindowManager
.
buildSplashScreen
()
,
ExportManager
.
initialize
()
]
[
WindowManager
.
buildSplashScreen
()]
).
then
(()
=>
resolve
(
true
))
});
}
...
...
@@ -112,20 +111,6 @@ namespace Uno.UI {
});
}
/**
* Initialize the WindowManager
* @param containerElementId The ID of the container element for the Xaml UI
* @param loadingElementId The ID of the loading element to remove once ready
*/
public
static
initNative
(
pParams
:
number
):
boolean
{
const
params
=
WindowManagerInitParams
.
unmarshal
(
pParams
);
WindowManager
.
init
(
params
.
IsLoadEventsEnabled
);
return
true
;
}
private
containerElement
:
HTMLDivElement
;
private
rootElement
:
HTMLElement
;
...
...
@@ -1582,7 +1567,10 @@ namespace Uno.UI {
);
}
private
static
initMethods
()
{
private
static
async
initMethods
()
{
await
ExportManager
.
initialize
();
if
(
!
WindowManager
.
resizeMethod
)
{
WindowManager
.
resizeMethod
=
(
<
any
>
Module
).
mono_bind_static_method
(
"
[Uno.UI] Windows.UI.Xaml.Window:Resize
"
);
}
...
...
src/Uno.UI/tsBindings/WindowManagerInitParams.ts
已删除
100644 → 0
浏览文件 @
d010280f
/* TSBindingsGenerator Generated code -- this code is regenerated on each build */
class
WindowManagerInitParams
{
/* Pack=4 */
public
IsLoadEventsEnabled
:
boolean
;
public
static
unmarshal
(
pData
:
number
)
:
WindowManagerInitParams
{
const
ret
=
new
WindowManagerInitParams
();
{
ret
.
IsLoadEventsEnabled
=
Boolean
(
Module
.
getValue
(
pData
+
0
,
"
i32
"
));
}
return
ret
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录