create-vidra-app 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -201,6 +201,14 @@ var newestNet10Sdk = (listSdksOutput) => splitLines(listSdksOutput).map((line) =
201
201
  (a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" })
202
202
  ).pop();
203
203
  var outputMentionsMaui = (workloadListOutput) => MAUI_WORKLOAD.test(workloadListOutput);
204
+ var outputMentionsMauiTarget = (workloadListOutput, target) => {
205
+ if (!target) return outputMentionsMaui(workloadListOutput);
206
+ const targetWorkload = target === "macos" ? "maui-maccatalyst" : target === "windows" ? "maui-windows" : "maui-android";
207
+ return new RegExp(
208
+ `(?:\\[(?:maui|${targetWorkload})\\]|^\\s*(?:maui|${targetWorkload})\\s)`,
209
+ "m"
210
+ ).test(workloadListOutput);
211
+ };
204
212
  var checkDotnetSdk = () => {
205
213
  const name = ".NET SDK";
206
214
  const res = run(DOTNET, ["--list-sdks"]);
@@ -226,9 +234,13 @@ var checkDotnetSdk = () => {
226
234
  fix: INSTALL_NET_10_FIX
227
235
  };
228
236
  };
229
- var isMauiWorkloadInstalled = () => outputMentionsMaui(run(DOTNET, ["workload", "list"]).stdout);
230
- var installWorkload = (csprojPath) => {
231
- const args = csprojPath ? ["workload", "restore", csprojPath] : ["workload", "install", "maui"];
237
+ var isMauiWorkloadInstalled = (target) => outputMentionsMauiTarget(
238
+ run(DOTNET, ["workload", "list"]).stdout,
239
+ target
240
+ );
241
+ var mauiWorkloadFor = (target) => target === "android" ? "maui-android" : target === "windows" ? "maui-windows" : target === "macos" ? "maui-maccatalyst" : "maui";
242
+ var installWorkload = (csprojPath, target) => {
243
+ const args = target ? ["workload", "install", mauiWorkloadFor(target)] : csprojPath ? ["workload", "restore", csprojPath] : ["workload", "install", "maui"];
232
244
  console.log();
233
245
  console.log(
234
246
  row({
@@ -255,7 +267,9 @@ var installWorkload = (csprojPath) => {
255
267
  )
256
268
  )
257
269
  );
258
- console.error(fixLine("sudo dotnet workload install maui"));
270
+ console.error(
271
+ fixLine(`sudo dotnet workload install ${mauiWorkloadFor(target)}`)
272
+ );
259
273
  console.error();
260
274
  return false;
261
275
  }
@@ -277,7 +291,7 @@ var ensureMauiWorkload = async (opts = {}) => {
277
291
  return false;
278
292
  }
279
293
  if (dotnet.status === "unknown") return true;
280
- if (isMauiWorkloadInstalled()) return true;
294
+ if (isMauiWorkloadInstalled(opts.target)) return true;
281
295
  console.log();
282
296
  console.log(
283
297
  row({
@@ -301,7 +315,7 @@ var ensureMauiWorkload = async (opts = {}) => {
301
315
  install = false;
302
316
  }
303
317
  if (install) {
304
- if (installWorkload(opts.csprojPath) && isMauiWorkloadInstalled()) {
318
+ if (installWorkload(opts.csprojPath, opts.target) && isMauiWorkloadInstalled(opts.target)) {
305
319
  console.log(
306
320
  row({
307
321
  glyph: "done",
@@ -314,7 +328,9 @@ var ensureMauiWorkload = async (opts = {}) => {
314
328
  return false;
315
329
  }
316
330
  }
317
- console.log(fixLine("dotnet workload install maui", "run:"));
331
+ console.log(
332
+ fixLine(`dotnet workload install ${mauiWorkloadFor(opts.target)}`, "run:")
333
+ );
318
334
  console.log(fixLine(MAUI_DOCS, "docs:"));
319
335
  return false;
320
336
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vidra-app",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "Scaffold a new Vidra application (React + .NET MAUI)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  # {{appTitle}}
2
2
 
3
- A desktop application built with [Vidra](https://vidra.build): a React UI and a
3
+ A cross-platform application built with [Vidra](https://vidra.build): a React UI and a
4
4
  C#/.NET native host.
5
5
 
6
6
  ## Requirements
@@ -9,8 +9,11 @@ C#/.NET native host.
9
9
  - .NET MAUI workload: `dotnet workload install maui`
10
10
  - [Node.js](https://nodejs.org/) 22 or newer
11
11
  - Xcode for macOS builds
12
+ - JDK 17 and the Android SDK for Android builds
12
13
 
13
- Windows targets must be built on Windows.
14
+ Windows targets must be built on Windows. Android targets can be built on
15
+ Windows, macOS, or Linux; connect an emulator/device and run
16
+ `npm run dev -- --target android`.
14
17
 
15
18
  ## Development
16
19
 
@@ -23,6 +26,13 @@ npm run dev
23
26
  reload through Vite; supported C# changes reload through the .NET development
24
27
  loop.
25
28
 
29
+ For Android, `vidra dev` selects the connected device (or `ANDROID_SERIAL`),
30
+ installs the app, and reads readiness from logcat. It prefers `adb reverse`,
31
+ then falls back to `10.0.2.2` on an emulator or the development machine's LAN
32
+ address on a physical device. Set `VIDRA_ANDROID_HOST` when automatic interface
33
+ selection picks a VPN or container network. The page respects system safe areas; hardware
34
+ Back navigates WebView history before exiting.
35
+
26
36
  ## Build
27
37
 
28
38
  ```bash
@@ -8,6 +8,7 @@
8
8
  "dev:ui": "npm run dev --prefix ui",
9
9
  "dev:host:macos": "vidra run --target macos",
10
10
  "dev:host:windows": "vidra run --target windows",
11
+ "dev:host:android": "vidra run --target android",
11
12
  "doctor": "vidra doctor"
12
13
  },
13
14
  "devDependencies": {
@@ -6,6 +6,12 @@ public class MainPage : VidraPage
6
6
  {
7
7
  public MainPage()
8
8
  {
9
+ AppWebView.Navigated += OnFirstNavigated;
10
+ }
11
+
12
+ private void OnFirstNavigated(object? sender, WebNavigatedEventArgs e)
13
+ {
14
+ AppWebView.Navigated -= OnFirstNavigated;
9
15
  StartCounterTimer();
10
16
  }
11
17
 
@@ -27,14 +27,17 @@ public static class MauiProgram
27
27
  // A bundle only installs when its contract fingerprints match this build,
28
28
  // so JS can never call a bridge the installed binary lacks.
29
29
  //
30
- // Whole app: native code included, via Velopack. Its other half is the
31
- // `VelopackApp` line in Platforms/*/Program.cs, which has to run before
32
- // the UI framework starts.
30
+ // Whole app (desktop): native code included, via Velopack. Its other
31
+ // half is the `VelopackApp` line in the desktop Program.cs files, which
32
+ // has to run before the UI framework starts. Google Play owns Android
33
+ // app updates; only the web-bundle tier runs there.
33
34
  builder
34
35
  .UseMauiApp<App>()
35
36
  .UseVidra()
36
37
  .UseVidraUpdates()
38
+ #if !ANDROID
37
39
  .UseVidraNativeUpdates()
40
+ #endif
38
41
  .ConfigureFonts(fonts =>
39
42
  {
40
43
  fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5
+ <uses-permission android:name="android.permission.BATTERY_STATS" />
6
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
7
+ <application android:allowBackup="true"
8
+ android:supportsRtl="true" />
9
+ </manifest>
@@ -0,0 +1,37 @@
1
+ using Android.App;
2
+ using Android.Content.PM;
3
+ using Android.OS;
4
+ using Vidra.Hosting;
5
+
6
+ namespace {{projectName}};
7
+
8
+ [Activity(
9
+ Theme = "@style/Maui.SplashTheme",
10
+ MainLauncher = true,
11
+ LaunchMode = LaunchMode.SingleTop,
12
+ ConfigurationChanges = ConfigChanges.ScreenSize
13
+ | ConfigChanges.Orientation
14
+ | ConfigChanges.UiMode
15
+ | ConfigChanges.ScreenLayout
16
+ | ConfigChanges.SmallestScreenSize
17
+ | ConfigChanges.Density)]
18
+ public class MainActivity : MauiAppCompatActivity
19
+ {
20
+ protected override void OnCreate(Bundle? savedInstanceState)
21
+ {
22
+ ApplyDebugLaunchOverrides(Intent);
23
+ base.OnCreate(savedInstanceState);
24
+ }
25
+
26
+ protected override void OnNewIntent(Android.Content.Intent? intent)
27
+ {
28
+ base.OnNewIntent(intent);
29
+ ApplyDebugLaunchOverrides(intent);
30
+ }
31
+
32
+ private void ApplyDebugLaunchOverrides(Android.Content.Intent? intent)
33
+ {
34
+ if ((ApplicationInfo?.Flags & ApplicationInfoFlags.Debuggable) != 0)
35
+ VidraRuntimeSettings.ApplyAndroidIntentExtras(intent);
36
+ }
37
+ }
@@ -0,0 +1,17 @@
1
+ using Android.App;
2
+ using Android.Runtime;
3
+
4
+ namespace {{projectName}};
5
+
6
+ #if DEBUG
7
+ [Application(UsesCleartextTraffic = true)]
8
+ #elif VIDRA_ANDROID_TEST_RUNTIME
9
+ [Application(Debuggable = true, UsesCleartextTraffic = true)]
10
+ #else
11
+ [Application]
12
+ #endif
13
+ public class MainApplication(nint handle, JniHandleOwnership ownership)
14
+ : MauiApplication(handle, ownership)
15
+ {
16
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
17
+ }
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <vector xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:width="24dp"
4
+ android:height="24dp"
5
+ android:viewportWidth="24"
6
+ android:viewportHeight="24">
7
+ <path
8
+ android:fillColor="#FFFFFFFF"
9
+ android:pathData="M12,22a2.5,2.5 0,0 0,2.45 -2h-4.9A2.5,2.5 0,0 0,12 22zM19,17v-6a7,7 0,0 0,-5.5 -6.84V3a1.5,1.5 0,0 0,-3 0v1.16A7,7 0,0 0,5 11v6l-2,2h18z" />
10
+ </vector>
@@ -8,12 +8,22 @@
8
8
  restore can read an assets file with no x64 target and fail with
9
9
  NETSDK1047. Naming the set here makes every restore write both. -->
10
10
  <RuntimeIdentifiers Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
11
- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">net10.0-maccatalyst</TargetFrameworks>
12
- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net10.0-windows10.0.19041.0</TargetFrameworks>
11
+ <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">net10.0-maccatalyst;net10.0-android</TargetFrameworks>
12
+ <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net10.0-windows10.0.19041.0;net10.0-android</TargetFrameworks>
13
+ <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('linux'))">net10.0-android</TargetFrameworks>
13
14
  <ValidateXcodeVersion>false</ValidateXcodeVersion>
14
15
  <OutputType>Exe</OutputType>
15
16
  <RootNamespace>{{projectName}}</RootNamespace>
17
+ <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
18
+ <DefineConstants Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' And '$(VidraAndroidTestRuntime)' == 'true'">$(DefineConstants);VIDRA_ANDROID_TEST_RUNTIME</DefineConstants>
16
19
  <UseMaui>true</UseMaui>
20
+ <!--
21
+ Left unset, MauiVersion is whatever the installed maui workload ships,
22
+ which can be older than the Microsoft.Maui.Controls floor that the
23
+ Vidra packages declare; restore then fails with NU1605. Keep this at or
24
+ above that floor.
25
+ -->
26
+ <MauiVersion>10.0.120</MauiVersion>
17
27
  <SingleProject>true</SingleProject>
18
28
  <ImplicitUsings>enable</ImplicitUsings>
19
29
  <Nullable>enable</Nullable>
@@ -48,7 +58,7 @@
48
58
  -->
49
59
  <CodesignEntitlements Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">Entitlements.plist</CodesignEntitlements>
50
60
 
51
- <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
61
+ <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">17.0</SupportedOSPlatformVersion>
52
62
  <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
53
63
 
54
64
  <!--
@@ -104,7 +114,9 @@
104
114
  having to retrofit an entry point, a package reference and a builder call
105
115
  into an app that has already shipped.
106
116
  -->
107
- <PackageReference Include="Vidra.Updates.Native" Version="{{vidraVersion}}" />
117
+ <PackageReference Include="Vidra.Updates.Native"
118
+ Version="{{vidraVersion}}"
119
+ Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android'" />
108
120
  </ItemGroup>
109
121
 
110
122
  </Project>
@@ -42,6 +42,7 @@ const App = () => {
42
42
  // Emitted by the native host when `vidra dev` hot reloads edited C#.
43
43
  const unsubscribeHotReloaded = runtime.onHotReloaded(
44
44
  (data) => {
45
+ (window as any).__vidraEventProof = true;
45
46
  const typeName = data?.updatedTypes?.[0]?.split(".").pop();
46
47
  setCsReloaded(typeName ? `C# reloaded · ${typeName}` : "C# reloaded");
47
48
  window.clearTimeout(reloadFlashTimer.current);
@@ -63,6 +64,7 @@ const App = () => {
63
64
  void appWindow
64
65
  .getSupport()
65
66
  .then((result: WindowSupport) => {
67
+ (window as any).__vidraNativeCallProof = true;
66
68
  setWindowSupport(result);
67
69
  })
68
70
  .catch(() => {
@@ -268,8 +270,12 @@ const App = () => {
268
270
 
269
271
  <div className="actions">
270
272
  <button onClick={handleGetWindowInfo}>Get Window Info</button>
271
- <button onClick={handleRenameWindow}>Rename Window</button>
272
- <button onClick={handleResizeWindow}>Resize Window</button>
273
+ {windowSupport?.setTitle && (
274
+ <button onClick={handleRenameWindow}>Rename Window</button>
275
+ )}
276
+ {windowSupport?.configure && (
277
+ <button onClick={handleResizeWindow}>Resize Window</button>
278
+ )}
273
279
  {windowSupport?.center && (
274
280
  <button onClick={handleCenterWindow}>Center Window</button>
275
281
  )}
@@ -288,9 +294,9 @@ const App = () => {
288
294
 
289
295
  {!showsAdvancedWindowActions && windowSupport && (
290
296
  <p className="note">
291
- This runtime currently supports title and size updates only.
292
297
  Unsupported window actions are hidden automatically based on native
293
- support metadata.
298
+ support metadata. Android exposes current window information but no
299
+ desktop window controls.
294
300
  </p>
295
301
  )}
296
302
  </section>
@@ -0,0 +1,7 @@
1
+ // Auto-generated by vidra-codegen. Do not edit.
2
+
3
+ export const native = {
4
+ } as const;
5
+
6
+ export const events = {
7
+ } as const;
@@ -1,10 +1,9 @@
1
1
  // Auto-generated by vidra-codegen. Do not edit.
2
- import type { VidraClient } from "@vidra-dev/sdk";
2
+ import type { VidraBridge } from "@vidra-dev/sdk";
3
3
 
4
- export class CounterHandlers {
5
- constructor(private client: VidraClient) {}
4
+ export const createCounterHandlers = (bridge: VidraBridge) => ({
5
+ increment: (handler: () => number | Promise<number>): (() => void) =>
6
+ bridge.unsafe.handle("counter", "increment", handler),
7
+ });
6
8
 
7
- increment(handler: () => number | Promise<number>): () => void {
8
- return this.client.unsafe.handle("counter", "increment", handler);
9
- }
10
- }
9
+ export type CounterHandlers = ReturnType<typeof createCounterHandlers>;
@@ -1,9 +1,10 @@
1
1
  // Auto-generated by vidra-codegen. Do not edit.
2
- import { vidra } from "@vidra-dev/sdk";
3
- import { CounterHandlers } from "./counter.js";
2
+ import { bridge, expectations } from "@vidra-dev/sdk";
3
+ import { createCounterHandlers } from "./counter.js";
4
4
 
5
- vidra.registerGeneratedManifest("app", "d3044812d17c42049962d730fced04a6ecd711e287cdd0da7b218b327ee6cd56");
5
+ expectations.declare("app", "d3044812d17c42049962d730fced04a6ecd711e287cdd0da7b218b327ee6cd56");
6
6
 
7
- export const counterHandlers = new CounterHandlers(vidra);
7
+ export const counterHandlers = createCounterHandlers(bridge);
8
8
 
9
9
  export * from "./counter.js";
10
+ export { native, events } from "./access.js";
@@ -1,6 +1,4 @@
1
1
  // Generated by the Vidra CLI. Do not edit.
2
- import { vidra } from "@vidra-dev/sdk";
2
+ import { expectations } from "@vidra-dev/sdk";
3
3
 
4
- vidra.registerExpectedAccessFingerprint(
5
- "f8e12289e430f3ecfce80c132a8b23e9539c041a0912b7c116feae722f510f68",
6
- );
4
+ expectations.declare("access", "f8e12289e430f3ecfce80c132a8b23e9539c041a0912b7c116feae722f510f68");