Skip to content

Commit 07529ee

Browse files
committed
Merge branch 'main' into chore/alpha-polish
2 parents a32817d + 0a10e61 commit 07529ee

File tree

13 files changed

+228
-134
lines changed

13 files changed

+228
-134
lines changed

.github/workflows/dev-packages.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The version is pulled from the CHANGELOG.md file of the package.
2+
# Add a `-dev.xxx` suffix to the version.
3+
name: Create Dev Release
4+
5+
on: workflow_dispatch
6+
7+
jobs:
8+
dev-release:
9+
name: Publish Dev Packages
10+
runs-on: windows-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup .NET SDK
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: '8.0'
20+
21+
- name: Download PowerSync extension
22+
run: dotnet run --project Tools/Setup
23+
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
27+
- name: Extract Version from CHANGELOG.md
28+
id: extract_version
29+
shell: bash
30+
run: |
31+
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
32+
echo "Detected Version: $VERSION"
33+
echo "VERSION=$VERSION" >> $GITHUB_ENV
34+
35+
- name: Run Pack
36+
run: dotnet pack -c Release -o ${{ github.workspace }}/output
37+
38+
- name: Run Push
39+
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
40+

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The version is pulled from the CHANGELOG.md file of the package.
2+
name: Release
3+
4+
on: workflow_dispatch
5+
6+
jobs:
7+
release:
8+
name: Release
9+
runs-on: windows-latest
10+
if: github.ref == 'refs/heads/main'
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup .NET SDK
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: '8.0'
20+
21+
- name: Download PowerSync extension
22+
run: dotnet run --project Tools/Setup
23+
24+
- name: Restore dependencies
25+
run: dotnet restore
26+
27+
- name: Extract Version from CHANGELOG.md
28+
id: extract_version
29+
shell: bash
30+
run: |
31+
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
32+
echo "Detected Version: $VERSION"
33+
echo "VERSION=$VERSION" >> $GITHUB_ENV
34+
35+
- name: Run Pack
36+
run: dotnet pack -c Release -o ${{ github.workspace }}/output
37+
38+
- name: Run Push
39+
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
40+

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Test Packages
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
name: Test Packages
9+
runs-on: windows-latest
10+
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Setup .NET SDK
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: '8.0'
19+
20+
- name: Download PowerSync extension
21+
run: dotnet run --project Tools/Setup
22+
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
26+
- name: Run tests
27+
run: dotnet test -v n --framework net8.0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## 0.0.2-alpha.1
2+
3+
- Introduce package. Support for Desktop .NET use cases.
4+
5+
### Platform Runtime Support Added
6+
* linux-arm64
7+
* linux-x64
8+
* osx-arm64
9+
* osx-x64
10+
* wind-x64

PowerSync/PowerSync.Common/Client/PowerSyncDatabase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public async Task<T> WriteTransaction<T>(Func<ITransaction, Task<T>> fn, DBLockO
603603
/// </summary>
604604
public Task Watch<T>(string query, object[]? parameters, WatchHandler<T> handler, SQLWatchOptions? options = null)
605605
{
606-
var tcs = new TaskCompletionSource();
606+
var tcs = new TaskCompletionSource<bool>();
607607
Task.Run(async () =>
608608
{
609609
try
@@ -633,7 +633,7 @@ public Task Watch<T>(string query, object[]? parameters, WatchHandler<T> handler
633633
Signal = options?.Signal,
634634
ThrottleMs = options?.ThrottleMs
635635
});
636-
tcs.SetResult();
636+
tcs.SetResult(true);
637637
}
638638
catch (Exception ex)
639639
{

PowerSync/PowerSync.Common/PowerSync.Common.csproj

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@
55
<LangVersion>12</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<VersionPrefix>0.0.1</VersionPrefix>
9-
<VersionSuffix>alpha</VersionSuffix>
8+
<PackageId>PowerSync.Common</PackageId>
9+
<Title>PowerSync.Common</Title>
10+
<Description>PowerSync.Common is a package that enables local-first and real-time reactive apps with embedded SQLite for .NET clients</Description>
11+
<Authors>PowerSync</Authors>
12+
<owners>powersync</owners>
13+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
14+
<RepositoryUrl>https://github.com/powersync-ja/powersync-dotnet</RepositoryUrl>
15+
<PackageProjectUrl>https://powersync.com</PackageProjectUrl>
16+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
17+
<PackageReleaseNotes>https://github.com/powersync-ja/powersync-dotnet/PowerSync/PowerSync.Common/CHANGELOG.md</PackageReleaseNotes>
18+
<PackageTags>powersync local-first local-storage state-management offline sql db persistence sqlite sync </PackageTags>
19+
<PackageIcon>icon.png</PackageIcon>
20+
<NoWarn>NU5100</NoWarn>
21+
<PackageReadmeFile>README.md</PackageReadmeFile>
1022
</PropertyGroup>
1123

1224
<ItemGroup>
@@ -18,10 +30,21 @@
1830
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
1931
</ItemGroup>
2032

33+
<!-- For monorepo, test if we can remove this in monorepo -->
2134
<ItemGroup>
2235
<Content Include="runtimes\**\*.*">
2336
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2437
</Content>
2538
</ItemGroup>
2639

40+
<!-- For releasing runtimes -->
41+
<ItemGroup>
42+
<None Include="runtimes\**\*.*" Pack="true" PackagePath="runtimes\" />
43+
</ItemGroup>
44+
45+
46+
<ItemGroup>
47+
<None Include="..\..\icon.png" Pack="true" PackagePath=""/>
48+
<None Include="README.md" Pack="true" PackagePath=""/>
49+
</ItemGroup>
2750
</Project>

PowerSync/PowerSync.Common/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
This package contains a .NET implementation of a PowerSync database connector and streaming sync bucket implementation.
44

5+
## ⚠️ Project Status & Release Note
6+
7+
This package is currently in an alpha state, intended strictly for testing. Expect breaking changes and instability as development continues.
8+
9+
Do not rely on this package for production use.
10+
11+
## Installation
12+
13+
This package is published on [NuGet](https://www.nuget.org/packages/PowerSync.Common).
14+
15+
```bash
16+
dotnet add package PowerSync.Common --prerelease
17+
```
18+
519
## Usage
620

721
### Simple Query

PowerSync/PowerSync.Common/Utils/EventStream.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,20 @@ public CancellationTokenSource RunListenerAsync(
5353
Func<T, Task> callback)
5454
{
5555
var cts = new CancellationTokenSource();
56+
var started = new TaskCompletionSource<bool>();
5657

5758
_ = Task.Run(async () =>
5859
{
60+
started.SetResult(true);
5961
await foreach (var value in ListenAsync(cts.Token))
6062
{
6163
await callback(value);
6264
}
6365

6466
}, cts.Token);
6567

68+
started.Task.GetAwaiter().GetResult();
69+
6670
return cts;
6771
}
6872

@@ -76,15 +80,19 @@ public IAsyncEnumerable<T> ListenAsync(CancellationToken cancellationToken)
7680
public CancellationTokenSource RunListener(Action<T> callback)
7781
{
7882
var cts = new CancellationTokenSource();
83+
var started = new TaskCompletionSource<bool>();
7984

8085
_ = Task.Run(() =>
8186
{
87+
started.SetResult(true);
8288
foreach (var value in Listen(cts.Token))
8389
{
8490
callback(value);
8591
}
8692
}, cts.Token);
8793

94+
started.Task.GetAwaiter().GetResult();
95+
8896
return cts;
8997
}
9098

PowerSync/PowerSync.Common/Utils/PowerSyncPathResolver.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ public static class PowerSyncPathResolver
66
{
77
public static string GetNativeLibraryPath(string packagePath)
88
{
9+
10+
// .NET Framework 4.8 on Windows requires a different path (not supporting versions prior to this)
11+
if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework 4.8") && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
12+
{
13+
return Path.Combine(AppContext.BaseDirectory, "powersync.dll");
14+
}
15+
916
string rid = GetRuntimeIdentifier();
1017
string nativeDir = Path.Combine(packagePath, "runtimes", rid, "native");
1118

README.md

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ _[PowerSync](https://www.powersync.com) is a sync engine for building local-firs
88

99
`powersync-dotnet` is the monorepo for PowerSync .NET SDKs.
1010

11-
## ⚠️ Project Status & Release Note
12-
13-
This package is part of a monorepo that is not yet officially released or published. It is currently in a pre-alpha state, intended strictly for closed testing. Expect breaking changes and instability as development continues.
14-
15-
Do not rely on this package for production use.
16-
1711
## Monorepo Structure: Packages
1812

13+
Packages are published to [NuGet](https://www.nuget.org/profiles/PowerSync).
14+
1915
- [PowerSync/Common](./PowerSync/Common/README.md)
2016

2117
- Core package: .NET implementation of a PowerSync database connector and streaming sync bucket implementation. Packages meant for specific platforms will extend functionality of `Common`.
@@ -54,6 +50,18 @@ This PowerSync SDK currently targets the following .NET versions:
5450
<PackageReference Include="System.Net.Http" Version="4.3.4" />
5551
</ItemGroup>
5652
```
53+
54+
and create a `IsExternalInit.cs` file in your project with the following contents:
55+
56+
```cs
57+
using System.ComponentModel;
58+
59+
namespace System.Runtime.CompilerServices
60+
{
61+
[EditorBrowsable(EditorBrowsableState.Never)]
62+
internal class IsExternalInit { }
63+
}
64+
```
5765

5866
-------
5967

@@ -87,29 +95,7 @@ Run a specific test
8795
dotnet test -v n --framework net8.0 --filter "test-file-pattern"
8896
```
8997

90-
## Using the PowerSync.Common package in your project (temporary)
91-
A NuGet package will be available soon, until then you clone this repo and follow these steps:
92-
93-
Add the dependency to your project's .csproj:
94-
```.xml
95-
<ItemGroup>
96-
<ProjectReference Include="..\..\powersync-dotnet\PowerSync\Powersync.Common\PowerSync.Common.csproj" />
97-
</ItemGroup>
98-
```
99-
100-
Which assumes the following directory structure:
101-
```
102-
code/
103-
powersync-dotnet (X)
104-
├── PowerSync/PowerSync.Common
105-
│ ├── PowerSync.Common.csproj
106-
│ ├── Class1.cs
107-
│ └── Utils.cs
108-
└── root.sln
109-
110-
your-project
111-
├── demo
112-
│ ├── Program.csproj
113-
│ └── Program.cs
114-
├── root.sln
98+
## Using the PowerSync.Common package in your project
99+
```bash
100+
dotnet add package PowerSync.Common --prerelease
115101
```

0 commit comments

Comments
 (0)