continue dev

This commit is contained in:
vanzue
2025-11-27 09:21:55 +08:00
parent e6cb99c8d5
commit 4f4dff8c2d
8 changed files with 1383 additions and 172 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -64,6 +64,8 @@
Square44x44Logo="Images\Square44x44Logo.png"> Square44x44Logo="Images\Square44x44Logo.png">
</uap:VisualElements> </uap:VisualElements>
</Application> </Application>
<!-- Temporarily disabled: PowerToys Command Palette Extension now packaged with its own manifest -->
<!--
<Application Id="CmdPalExt.PowerToys" <Application Id="CmdPalExt.PowerToys"
Executable="WinUI3Apps\CmdPalExtensions\Microsoft.CmdPal.Ext.PowerToys\Microsoft.CmdPal.Ext.PowerToys.exe" Executable="WinUI3Apps\CmdPalExtensions\Microsoft.CmdPal.Ext.PowerToys\Microsoft.CmdPal.Ext.PowerToys.exe"
EntryPoint="Windows.FullTrustApplication"> EntryPoint="Windows.FullTrustApplication">
@@ -81,7 +83,7 @@
<com:ExeServer Executable="WinUI3Apps\CmdPalExtensions\Microsoft.CmdPal.Ext.PowerToys\Microsoft.CmdPal.Ext.PowerToys.exe" <com:ExeServer Executable="WinUI3Apps\CmdPalExtensions\Microsoft.CmdPal.Ext.PowerToys\Microsoft.CmdPal.Ext.PowerToys.exe"
Arguments="-RegisterProcessAsComServer" Arguments="-RegisterProcessAsComServer"
DisplayName="PowerToys Command Palette Extension"> DisplayName="PowerToys Command Palette Extension">
<com:Class Id="F0A8B809-CE2C-475A-935F-64A0348B1D29" <com:Class Id="3D0F0E1F-6F0C-4D5C-91C0-5C4A4B1A5D55"
DisplayName="PowerToys Command Palette Extension" /> DisplayName="PowerToys Command Palette Extension" />
</com:ExeServer> </com:ExeServer>
</com:ComServer> </com:ComServer>
@@ -96,7 +98,7 @@
<CmdPalProvider xmlns="http://schemas.microsoft.com/commandpalette/2024/extension"> <CmdPalProvider xmlns="http://schemas.microsoft.com/commandpalette/2024/extension">
<Metadata DisplayName="PowerToys" Description="Built-in PowerToys commands." /> <Metadata DisplayName="PowerToys" Description="Built-in PowerToys commands." />
<Activation> <Activation>
<CreateInstance ClassId="F0A8B809-CE2C-475A-935F-64A0348B1D29" /> <CreateInstance ClassId="3D0F0E1F-6F0C-4D5C-91C0-5C4A4B1A5D55" />
</Activation> </Activation>
<SupportedInterfaces> <SupportedInterfaces>
<Commands /> <Commands />
@@ -107,5 +109,6 @@
</uap3:Extension> </uap3:Extension>
</Extensions> </Extensions>
</Application> </Application>
-->
</Applications> </Applications>
</Package> </Package>

View File

@@ -8,13 +8,13 @@
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<PublishProfile>win-$(Platform).pubxml</PublishProfile> <PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>false</UseWinUI> <UseWinUI>false</UseWinUI>
<WindowsPackageType>None</WindowsPackageType> <EnableMsixTooling>true</EnableMsixTooling>
<EnableMsixTooling>false</EnableMsixTooling> <GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<GenerateAppxPackageOnBuild>false</GenerateAppxPackageOnBuild>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalExtensions\$(MSBuildProjectName)\</OutputPath> <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalExtensions\$(MSBuildProjectName)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Platforms>x64;ARM64;AnyCPU</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -32,8 +32,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CommandPalette.Extensions" /> <ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
<PackageReference Include="Microsoft.WindowsAppSDK" />
<PackageReference Include="Microsoft.Windows.CsWin32"> <PackageReference Include="Microsoft.Windows.CsWin32">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
@@ -41,6 +40,15 @@
<PackageReference Include="Shmuelie.WinRTServer" /> <PackageReference Include="Shmuelie.WinRTServer" />
</ItemGroup> </ItemGroup>
<!-- Enable Single-project MSIX packaging support -->
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" /> <ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
</ItemGroup> </ItemGroup>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap3 rescap">
<Identity
Name="Microsoft.CmdPal.Ext.PowerToys"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="0.0.1.0" />
<Properties>
<DisplayName>PowerToys Command Palette Extension</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.19041.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="PowerToys Command Palette Extension"
Description="Expose PowerToys commands to Windows Command Palette"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.scale-200.png"
Square44x44Logo="Assets\Square44x44Logo.scale-200.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.scale-200.png" />
<uap:SplashScreen Image="Assets\SplashScreen.scale-200.png" />
</uap:VisualElements>
<Extensions>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:ExeServer Executable="$targetnametoken$.exe" Arguments="-RegisterProcessAsComServer" DisplayName="PowerToys Command Palette Extension">
<com:Class Id="3D0F0E1F-6F0C-4D5C-91C0-5C4A4B1A5D55" DisplayName="PowerToys Command Palette Extension" />
</com:ExeServer>
</com:ComServer>
</com:Extension>
<uap3:Extension Category="windows.appExtension">
<uap3:AppExtension Name="com.microsoft.commandpalette"
Id="PowerToys"
PublicFolder="Public"
DisplayName="PowerToys"
Description="Surface PowerToys commands inside Command Palette">
<uap3:Properties>
<CmdPalProvider>
<Activation>
<CreateInstance ClassId="3D0F0E1F-6F0C-4D5C-91C0-5C4A4B1A5D55" />
</Activation>
<SupportedInterfaces>
<Commands/>
</SupportedInterfaces>
</CmdPalProvider>
</uap3:Properties>
</uap3:AppExtension>
</uap3:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

View File

@@ -5,11 +5,12 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using ManagedCommon;
using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions;
namespace PowerToysExtension; namespace PowerToysExtension;
[Guid("F0A8B809-CE2C-475A-935F-64A0348B1D29")] [Guid("3D0F0E1F-6F0C-4D5C-91C0-5C4A4B1A5D55")]
public sealed partial class PowerToysExtension : IExtension, IDisposable public sealed partial class PowerToysExtension : IExtension, IDisposable
{ {
private readonly ManualResetEvent _extensionDisposedEvent; private readonly ManualResetEvent _extensionDisposedEvent;
@@ -19,10 +20,12 @@ public sealed partial class PowerToysExtension : IExtension, IDisposable
public PowerToysExtension(ManualResetEvent extensionDisposedEvent) public PowerToysExtension(ManualResetEvent extensionDisposedEvent)
{ {
this._extensionDisposedEvent = extensionDisposedEvent; this._extensionDisposedEvent = extensionDisposedEvent;
Logger.LogInfo("PowerToysExtension constructed.");
} }
public object? GetProvider(ProviderType providerType) public object? GetProvider(ProviderType providerType)
{ {
Logger.LogInfo($"GetProvider requested: {providerType}");
return providerType switch return providerType switch
{ {
ProviderType.Commands => _provider, ProviderType.Commands => _provider,
@@ -30,5 +33,9 @@ public sealed partial class PowerToysExtension : IExtension, IDisposable
}; };
} }
public void Dispose() => this._extensionDisposedEvent.Set(); public void Dispose()
{
Logger.LogInfo("PowerToysExtension disposing; signalling exit.");
this._extensionDisposedEvent.Set();
}
} }

View File

@@ -4,11 +4,8 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using ManagedCommon; using ManagedCommon;
using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions;
using Shmuelie.WinRTServer;
using Shmuelie.WinRTServer.CsWinRT;
namespace PowerToysExtension; namespace PowerToysExtension;
@@ -21,14 +18,18 @@ public class Program
{ {
// Initialize per-extension log under CmdPal/PowerToysExtension. // Initialize per-extension log under CmdPal/PowerToysExtension.
Logger.InitializeLogger("\\CmdPal\\PowerToysExtension\\Logs"); Logger.InitializeLogger("\\CmdPal\\PowerToysExtension\\Logs");
Logger.LogInfo("PowerToysExtension starting (args: " + string.Join(' ', args) + ")");
} }
catch catch
{ {
// Continue even if logging fails. // Continue even if logging fails.
} }
try
{
if (args.Length > 0 && args[0] == "-RegisterProcessAsComServer") if (args.Length > 0 && args[0] == "-RegisterProcessAsComServer")
{ {
Logger.LogInfo("RegisterProcessAsComServer mode detected.");
using ExtensionServer server = new(); using ExtensionServer server = new();
ManualResetEvent extensionDisposedEvent = new(false); ManualResetEvent extensionDisposedEvent = new(false);
@@ -38,14 +39,21 @@ public class Program
// If you want to instantiate a new instance each time the host asks, create the new instance inside the delegate. // If you want to instantiate a new instance each time the host asks, create the new instance inside the delegate.
PowerToysExtension extensionInstance = new(extensionDisposedEvent); PowerToysExtension extensionInstance = new(extensionDisposedEvent);
server.RegisterExtension(() => extensionInstance); server.RegisterExtension(() => extensionInstance);
Logger.LogInfo("Extension instance registered; waiting for disposal signal.");
// This will make the main thread wait until the event is signalled by the extension class. // This will make the main thread wait until the event is signalled by the extension class.
// Since we have single instance of the extension object, we exit as soon as it is disposed. // Since we have single instance of the extension object, we exit as soon as it is disposed.
extensionDisposedEvent.WaitOne(); extensionDisposedEvent.WaitOne();
Logger.LogInfo("Extension disposed signal received; exiting server loop.");
} }
else else
{ {
Console.WriteLine("Not being launched as a Extension... exiting."); Console.WriteLine("Not being launched as a Extension... exiting.");
Logger.LogInfo("Exited: not launched with -RegisterProcessAsComServer.");
}
}
finally
{
} }
} }
} }

View File

@@ -1,8 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="PowerToysCommandPaletteExtension.app"/> <assemblyIdentity version="1.0.0.0" name="PowerToysExtension.app" />
<msix xmlns="urn:schemas-microsoft-com:msix.v1"
packageName="Microsoft.PowerToys.SparseApp" <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
applicationId="CmdPalExt.PowerToys" <application>
publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" /> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly> </assembly>