formaui-net.AddOns.Share.Targets 1.0.0-preview.27

Prefix Reserved
This is a prerelease version of formaui-net.AddOns.Share.Targets.
dotnet add package formaui-net.AddOns.Share.Targets --version 1.0.0-preview.27
                    
NuGet\Install-Package formaui-net.AddOns.Share.Targets -Version 1.0.0-preview.27
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="formaui-net.AddOns.Share.Targets" Version="1.0.0-preview.27" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="formaui-net.AddOns.Share.Targets" Version="1.0.0-preview.27" />
                    
Directory.Packages.props
<PackageReference Include="formaui-net.AddOns.Share.Targets" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add formaui-net.AddOns.Share.Targets --version 1.0.0-preview.27
                    
#r "nuget: formaui-net.AddOns.Share.Targets, 1.0.0-preview.27"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package formaui-net.AddOns.Share.Targets@1.0.0-preview.27
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=formaui-net.AddOns.Share.Targets&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=formaui-net.AddOns.Share.Targets&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Tool

Forma.AddOns.Share.Targets

Ready-made share targets for FormaShareMenu: the social networks, Messenger and Discord, the cloud drives, TikTok and Mastodon. Each is an IShareTarget on the Forma.Framework.Share contracts with a registrar of its own, and joins the menu for the items it accepts.

Install

dotnet add package formaui-net.AddOns.Share.Targets --prerelease

Register

A host registers the targets it wants, from the Forma.Framework.Share.Targets namespace.

Networks

using Forma.Framework.Share.Targets;

builder.Services.AddFormaShareNetworks();

Registers Facebook, X, WhatsApp, Telegram, Bluesky, Reddit, Snapchat, LinkedIn and Pinterest. Each opens the network's composer in a new tab on a link or a picture that has an address; Pinterest pins pictures.

The host's app or channel

Registrar Options Target
AddFormaMessengerSharing(configure) MessengerShareOptions: AppId, the host's Facebook app id, and RedirectAddress, where the dialog returns to Opens Messenger's send dialog on a link or a picture that has an address.
AddFormaDiscordSharing(webhookAddress) or AddFormaDiscordSharing(configure) DiscordShareOptions: WebhookAddress, the channel webhook's address Posts the item's name and address into the channel.

The configure delegate sets options on top of any the host binds from configuration, and the options are validated when the application starts.

The user's account

using Forma.Framework.Share;
using Forma.Framework.Share.Targets;

builder.Services.AddScoped<IShareTokenSource, UserShareTokens>();
builder.Services.AddFormaDropboxSharing();
builder.Services.AddFormaGoogleDriveSharing();
builder.Services.AddFormaOneDriveSharing();
builder.Services.AddFormaTikTokSharing();

Each shares under the access token the host's IShareTokenSource answers for the target's id: Dropbox saves the item's resource, Google Drive and OneDrive upload it, and TikTok publishes it as a video. They take an item whose resource is at a public http or https address, which the service fetches it from. The targets are scoped, beside the scoped token source.

using Forma.Framework.Share;

public sealed class UserShareTokens(IUserCredentials credentials) : IShareTokenSource
{
    public ValueTask<string?> GetTokenAsync(string targetId, CancellationToken cancellationToken = default)
        => credentials.GetAccessTokenAsync(targetId, cancellationToken);
}

The user's server

using Forma.Framework.Share;
using Forma.Framework.Share.Targets;

builder.Services.AddScoped<IShareServerSource, UserShareServers>();
builder.Services.AddFormaMastodonSharing();

Mastodon opens the composer of the server the host's IShareServerSource answers, on a link or a picture that has an address. With IShareConnections registered, the menu offers to connect a server until the user names one.

Target ids

The token and server sources are asked by these ids.

Target Id Target Id
Facebook facebook Messenger messenger
X x Discord discord
WhatsApp whatsapp Mastodon mastodon
Telegram telegram Dropbox dropbox
Bluesky bluesky Google Drive google-drive
Reddit reddit OneDrive onedrive
Snapchat snapchat TikTok tiktok
LinkedIn linkedin
Pinterest pinterest

Example

The networks for every user, a Discord channel the host owns, and Dropbox under the user's account:

builder.Services.AddFormaShareNetworks();
builder.Services.AddFormaDiscordSharing(new Uri("https://discord.com/api/webhooks/123/abc"));
builder.Services.AddScoped<IShareTokenSource, UserShareTokens>();
builder.Services.AddFormaDropboxSharing();

A file at a public address, which Discord and Dropbox accept:

<FormaShareMenu Item="@_kit" />

@code {
    private readonly ShareItem _kit = new()
    {
        Kind = ShareItemKind.File,
        Name = "kit.zip",
        Meta = "ZIP archive, 4 MB",
        Address = "https://example.com/files/kit",
        Resource = new ResourceInfo("https://example.com/files/kit.zip"),
    };
}

License

Apache License 2.0, under the repository's LICENSE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.27 43 12/3/2026
1.0.0-preview.26 44 12/3/2026
1.0.0-preview.25 50 12/2/2026
1.0.0-preview.24 49 12/1/2026
1.0.0-preview.23 66 11/30/2026
1.0.0-preview.22 61 11/30/2026
1.0.0-preview.21 58 11/29/2026
1.0.0-preview.20 65 11/26/2026
1.0.0-preview.19 64 11/26/2026
1.0.0-preview.18 61 11/26/2026
1.0.0-preview.17 58 11/26/2026
1.0.0-preview.16 56 11/24/2026
1.0.0-preview.15 57 11/23/2026
1.0.0-preview.14 54 11/23/2026
1.0.0-preview.13 58 11/21/2026
1.0.0-preview.12 62 11/20/2026
1.0.0-preview.11 58 11/18/2026
1.0.0-preview.10 65 11/17/2026
1.0.0-preview.9 55 11/17/2026
1.0.0-preview.8 54 11/17/2026
Loading failed

What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md