@microsoft/power-apps-native-host 0.3.3 → 0.5.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.
Files changed (111) hide show
  1. package/README.md +60 -0
  2. package/compatibility/current.json +1 -1
  3. package/lib/NOTICE.txt +2957 -371
  4. package/lib/commonjs/auth/AuthContext.js +49 -22
  5. package/lib/commonjs/auth/targetAuthorization.js +53 -0
  6. package/lib/commonjs/bridge/NativePowerAppsBridge.js +33 -2
  7. package/lib/commonjs/bridge/PowerPagesBridge.js +1 -3
  8. package/lib/commonjs/bridge/setupNativeHost.js +6 -0
  9. package/lib/commonjs/config/expoConfig.js +14 -0
  10. package/lib/commonjs/config/runtimeTenantMode.js +16 -0
  11. package/lib/commonjs/config/runtimeTenantMode.web.js +9 -0
  12. package/lib/commonjs/config/tenantMode.js +68 -0
  13. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +24 -27
  14. package/lib/commonjs/connections/connectionMetadata.js +2 -2
  15. package/lib/commonjs/connections/resolveConnections.js +8 -3
  16. package/lib/commonjs/connections/types.js +9 -2
  17. package/lib/commonjs/connections/useConnectionRefs.js +19 -10
  18. package/lib/commonjs/index.js +41 -2
  19. package/lib/commonjs/platform/CanvasAppResolution.js +33 -0
  20. package/lib/commonjs/platform/CanvasAppResolutionApi.js +69 -0
  21. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +50 -13
  22. package/lib/commonjs/platform/GlobalDiscovery.js +40 -1
  23. package/lib/commonjs/provider/PowerAppsHostProvider.js +47 -8
  24. package/lib/commonjs/provider/PowerAppsProvider.js +175 -9
  25. package/lib/commonjs/target/DefaultPowerAppsExperience.js +564 -0
  26. package/lib/commonjs/target/PowerAppsExperience.js +41 -0
  27. package/lib/commonjs/target/PowerAppsTargetBootstrap.js +534 -0
  28. package/lib/commonjs/target/errors.js +24 -0
  29. package/lib/commonjs/target/types.js +1 -0
  30. package/lib/commonjs/telemetry/index.js +2 -2
  31. package/lib/module/auth/AuthContext.js +49 -22
  32. package/lib/module/auth/targetAuthorization.js +48 -0
  33. package/lib/module/bridge/NativePowerAppsBridge.js +33 -2
  34. package/lib/module/bridge/PowerPagesBridge.js +1 -3
  35. package/lib/module/bridge/setupNativeHost.js +5 -0
  36. package/lib/module/config/expoConfig.js +14 -0
  37. package/lib/module/config/runtimeTenantMode.js +12 -0
  38. package/lib/module/config/runtimeTenantMode.web.js +5 -0
  39. package/lib/module/config/tenantMode.js +61 -0
  40. package/lib/module/connections/PowerPlatformConnectionApi.js +24 -27
  41. package/lib/module/connections/connectionMetadata.js +2 -2
  42. package/lib/module/connections/resolveConnections.js +9 -4
  43. package/lib/module/connections/types.js +9 -2
  44. package/lib/module/connections/useConnectionRefs.js +20 -11
  45. package/lib/module/index.js +5 -2
  46. package/lib/module/platform/CanvasAppResolution.js +27 -0
  47. package/lib/module/platform/CanvasAppResolutionApi.js +65 -0
  48. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +49 -14
  49. package/lib/module/platform/GlobalDiscovery.js +37 -1
  50. package/lib/module/provider/PowerAppsHostProvider.js +47 -8
  51. package/lib/module/provider/PowerAppsProvider.js +179 -13
  52. package/lib/module/target/DefaultPowerAppsExperience.js +559 -0
  53. package/lib/module/target/PowerAppsExperience.js +34 -0
  54. package/lib/module/target/PowerAppsTargetBootstrap.js +529 -0
  55. package/lib/module/target/errors.js +19 -0
  56. package/lib/module/target/types.js +1 -0
  57. package/lib/module/telemetry/index.js +1 -1
  58. package/lib/typescript/commonjs/auth/AuthContext.d.ts +11 -2
  59. package/lib/typescript/commonjs/auth/targetAuthorization.d.ts +15 -0
  60. package/lib/typescript/commonjs/bridge/NativePowerAppsBridge.d.ts +6 -0
  61. package/lib/typescript/commonjs/bridge/setupNativeHost.d.ts +2 -0
  62. package/lib/typescript/commonjs/config/runtimeTenantMode.d.ts +3 -0
  63. package/lib/typescript/commonjs/config/runtimeTenantMode.web.d.ts +3 -0
  64. package/lib/typescript/commonjs/config/tenantMode.d.ts +14 -0
  65. package/lib/typescript/commonjs/connections/PowerPlatformConnectionApi.d.ts +5 -2
  66. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +1 -1
  67. package/lib/typescript/commonjs/connections/types.d.ts +7 -1
  68. package/lib/typescript/commonjs/connections/useConnectionRefs.d.ts +11 -2
  69. package/lib/typescript/commonjs/index.d.ts +7 -3
  70. package/lib/typescript/commonjs/platform/CanvasAppResolution.d.ts +4 -0
  71. package/lib/typescript/commonjs/platform/CanvasAppResolutionApi.d.ts +6 -0
  72. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +12 -2
  73. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +12 -0
  74. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +9 -1
  75. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +14 -16
  76. package/lib/typescript/commonjs/target/DefaultPowerAppsExperience.d.ts +6 -0
  77. package/lib/typescript/commonjs/target/PowerAppsExperience.d.ts +61 -0
  78. package/lib/typescript/commonjs/target/PowerAppsTargetBootstrap.d.ts +15 -0
  79. package/lib/typescript/commonjs/target/errors.d.ts +13 -0
  80. package/lib/typescript/commonjs/target/types.d.ts +34 -0
  81. package/lib/typescript/commonjs/telemetry/index.d.ts +2 -2
  82. package/lib/typescript/module/auth/AuthContext.d.ts +11 -2
  83. package/lib/typescript/module/auth/targetAuthorization.d.ts +15 -0
  84. package/lib/typescript/module/bridge/NativePowerAppsBridge.d.ts +6 -0
  85. package/lib/typescript/module/bridge/setupNativeHost.d.ts +2 -0
  86. package/lib/typescript/module/config/runtimeTenantMode.d.ts +3 -0
  87. package/lib/typescript/module/config/runtimeTenantMode.web.d.ts +3 -0
  88. package/lib/typescript/module/config/tenantMode.d.ts +14 -0
  89. package/lib/typescript/module/connections/PowerPlatformConnectionApi.d.ts +5 -2
  90. package/lib/typescript/module/connections/connectionMetadata.d.ts +1 -1
  91. package/lib/typescript/module/connections/types.d.ts +7 -1
  92. package/lib/typescript/module/connections/useConnectionRefs.d.ts +11 -2
  93. package/lib/typescript/module/index.d.ts +7 -3
  94. package/lib/typescript/module/platform/CanvasAppResolution.d.ts +4 -0
  95. package/lib/typescript/module/platform/CanvasAppResolutionApi.d.ts +6 -0
  96. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +12 -2
  97. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +12 -0
  98. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +9 -1
  99. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +14 -16
  100. package/lib/typescript/module/target/DefaultPowerAppsExperience.d.ts +6 -0
  101. package/lib/typescript/module/target/PowerAppsExperience.d.ts +61 -0
  102. package/lib/typescript/module/target/PowerAppsTargetBootstrap.d.ts +15 -0
  103. package/lib/typescript/module/target/errors.d.ts +13 -0
  104. package/lib/typescript/module/target/types.d.ts +34 -0
  105. package/lib/typescript/module/telemetry/index.d.ts +2 -2
  106. package/package.json +12 -5
  107. package/scripts/build-codegen-package.js +34 -3
  108. package/scripts/dev.js +405 -0
  109. package/scripts/upgrade-authoring.js +85 -28
  110. package/scripts/wrap.js +42 -5
  111. package/src/config/generated-config.d.ts +21 -0
package/README.md CHANGED
@@ -82,6 +82,23 @@ wiring.
82
82
  npm run dev
83
83
  ```
84
84
 
85
+ For a device that cannot reach the workstation over LAN, use a private,
86
+ authenticated Microsoft Dev Tunnel:
87
+
88
+ ```bash
89
+ az login
90
+ npm run dev -- --tunnel
91
+ ```
92
+
93
+ Pass `--tunnel-tenant <tenant-id>` to select an Entra tenant. The command
94
+ creates no anonymous access rule and deletes the tunnel when Metro exits.
95
+ Entra authentication stays on the workstation; the QR code gives the Dev
96
+ Player a tunnel-scoped connect token for Metro bundle and asset requests.
97
+ Enterprise firewalls must allow outbound HTTPS on port 443
98
+ to `login.microsoftonline.com`, `global.rel.tunnels.api.visualstudio.com`,
99
+ `*.rel.tunnels.api.visualstudio.com`, and `*.devtunnels.ms`, with TLS 1.2 or
100
+ newer.
101
+
85
102
  6. Preview the app by scanning the QR code with the Power Apps Developer app.
86
103
 
87
104
  - App Store: https://apps.apple.com/us/app/power-apps-developer/id6753083462
@@ -153,6 +170,48 @@ export default function App() {
153
170
 
154
171
  See `src/index.ts` for the full exported API.
155
172
 
173
+ ### Custom multi-tenant experience
174
+
175
+ Single-tenant apps and multi-tenant apps using the built-in screens do not
176
+ need any root-layout changes. To replace the multi-tenant sign-in, discovery,
177
+ environment selection, loading, and error screens, pass a component through
178
+ `multiTenantExperience`:
179
+
180
+ ```tsx
181
+ import {
182
+ PowerAppsProvider,
183
+ PowerAppsRuntimeGate,
184
+ usePowerAppsExperience,
185
+ } from '@microsoft/power-apps-native-host';
186
+
187
+ function CustomerExperience({ children }: React.PropsWithChildren) {
188
+ const experience = usePowerAppsExperience();
189
+
190
+ if (experience.status === 'signIn') {
191
+ return <LoginScreen error={experience.error} onSignIn={experience.signIn} />;
192
+ }
193
+ if (experience.status === 'selectEnvironment') {
194
+ return <EnvironmentPicker {...experience} />;
195
+ }
196
+ if (experience.status === 'ready') {
197
+ return <PowerAppsRuntimeGate>{children}</PowerAppsRuntimeGate>;
198
+ }
199
+ return <BootstrapStatusScreen experience={experience} />;
200
+ }
201
+
202
+ export default function RootLayout() {
203
+ return (
204
+ <PowerAppsProvider {...config} multiTenantExperience={CustomerExperience}>
205
+ <Slot />
206
+ </PowerAppsProvider>
207
+ );
208
+ }
209
+ ```
210
+
211
+ The experience model exposes presentation-safe state and commands only. Target
212
+ authentication sessions, access tokens, token brokers, and stale-operation
213
+ generation state remain internal to `PowerAppsProvider`.
214
+
156
215
  ## Metro Logger
157
216
 
158
217
  Metro configuration can import the Node-only logger from
@@ -177,6 +236,7 @@ withPowerNativeMetroLogging(middleware, {
177
236
  This package exposes these CLI scripts through the `bin` field:
178
237
 
179
238
  - `generate-connector-schemas` - generates TypeScript schemas from connector definitions.
239
+ - `power-apps-dev` - starts Expo; pass `--tunnel` for a private authenticated Dev Tunnel.
180
240
  - `js-bundle` - packages the JavaScript bundle for embedding.
181
241
  - `build-ios-base` - builds the iOS base framework.
182
242
  - `wrap` - builds a wrapped Android or iOS app.
@@ -13,7 +13,7 @@
13
13
  }
14
14
  },
15
15
  "expoSdk": 55,
16
- "expoVersion": "55.0.26",
16
+ "expoVersion": "55.0.29",
17
17
  "expoDoctorVersion": "1.20.0",
18
18
  "managedDependencies": {
19
19
  "@expo/config-plugins": "55.0.11",