@microsoft/power-apps-native-host 0.2.22
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/LICENSE +112 -0
- package/README.md +59 -0
- package/app.plugin.js +4 -0
- package/lib/NOTICE.txt +1659 -0
- package/lib/commonjs/ErrorBoundary.js +128 -0
- package/lib/commonjs/auth/AuthContext.js +281 -0
- package/lib/commonjs/bridge/NativePowerAppsBridge.js +279 -0
- package/lib/commonjs/bridge/setupNativeHost.js +65 -0
- package/lib/commonjs/connections/ConnectionSetupScreen.js +531 -0
- package/lib/commonjs/connections/disambiguate.js +88 -0
- package/lib/commonjs/connections/types.js +58 -0
- package/lib/commonjs/connections/useConnectionSetup.js +236 -0
- package/lib/commonjs/controls/FilePicker.js +183 -0
- package/lib/commonjs/controls/ImagePicker.js +236 -0
- package/lib/commonjs/index.js +246 -0
- package/lib/commonjs/logger.js +27 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/platform/PowerPlatformConnectionApi.js +606 -0
- package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +194 -0
- package/lib/commonjs/platform/resolveConnections.js +264 -0
- package/lib/commonjs/platform/useConnectionRefs.js +270 -0
- package/lib/commonjs/provider/PowerAppsHostProvider.js +336 -0
- package/lib/commonjs/provider/PowerAppsProvider.js +351 -0
- package/lib/commonjs/telemetry/index.js +70 -0
- package/lib/commonjs/theme/ThemeProvider.js +80 -0
- package/lib/commonjs/theme/tokens.js +50 -0
- package/lib/commonjs/utils/dataverseUtils.js +98 -0
- package/lib/commonjs/utils/isDevPlayer.js +27 -0
- package/lib/module/ErrorBoundary.js +122 -0
- package/lib/module/auth/AuthContext.js +276 -0
- package/lib/module/bridge/NativePowerAppsBridge.js +273 -0
- package/lib/module/bridge/setupNativeHost.js +62 -0
- package/lib/module/connections/ConnectionSetupScreen.js +526 -0
- package/lib/module/connections/disambiguate.js +83 -0
- package/lib/module/connections/types.js +60 -0
- package/lib/module/connections/useConnectionSetup.js +233 -0
- package/lib/module/controls/FilePicker.js +178 -0
- package/lib/module/controls/ImagePicker.js +231 -0
- package/lib/module/index.js +41 -0
- package/lib/module/logger.js +22 -0
- package/lib/module/package.json +1 -0
- package/lib/module/platform/PowerPlatformConnectionApi.js +595 -0
- package/lib/module/platform/PowerPlatformEnvironmentApi.js +186 -0
- package/lib/module/platform/resolveConnections.js +259 -0
- package/lib/module/platform/useConnectionRefs.js +267 -0
- package/lib/module/provider/PowerAppsHostProvider.js +332 -0
- package/lib/module/provider/PowerAppsProvider.js +345 -0
- package/lib/module/telemetry/index.js +55 -0
- package/lib/module/theme/ThemeProvider.js +63 -0
- package/lib/module/theme/tokens.js +46 -0
- package/lib/module/utils/dataverseUtils.js +90 -0
- package/lib/module/utils/isDevPlayer.js +23 -0
- package/lib/typescript/commonjs/ErrorBoundary.d.ts +30 -0
- package/lib/typescript/commonjs/auth/AuthContext.d.ts +57 -0
- package/lib/typescript/commonjs/bridge/NativePowerAppsBridge.d.ts +112 -0
- package/lib/typescript/commonjs/bridge/setupNativeHost.d.ts +39 -0
- package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +107 -0
- package/lib/typescript/commonjs/connections/disambiguate.d.ts +43 -0
- package/lib/typescript/commonjs/connections/types.d.ts +91 -0
- package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +96 -0
- package/lib/typescript/commonjs/controls/FilePicker.d.ts +65 -0
- package/lib/typescript/commonjs/controls/ImagePicker.d.ts +76 -0
- package/lib/typescript/commonjs/index.d.ts +42 -0
- package/lib/typescript/commonjs/logger.d.ts +11 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/platform/PowerPlatformConnectionApi.d.ts +205 -0
- package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +108 -0
- package/lib/typescript/commonjs/platform/resolveConnections.d.ts +86 -0
- package/lib/typescript/commonjs/platform/useConnectionRefs.d.ts +126 -0
- package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +123 -0
- package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +148 -0
- package/lib/typescript/commonjs/telemetry/index.d.ts +48 -0
- package/lib/typescript/commonjs/theme/ThemeProvider.d.ts +30 -0
- package/lib/typescript/commonjs/theme/tokens.d.ts +27 -0
- package/lib/typescript/commonjs/utils/dataverseUtils.d.ts +39 -0
- package/lib/typescript/commonjs/utils/isDevPlayer.d.ts +19 -0
- package/lib/typescript/module/ErrorBoundary.d.ts +30 -0
- package/lib/typescript/module/auth/AuthContext.d.ts +57 -0
- package/lib/typescript/module/bridge/NativePowerAppsBridge.d.ts +112 -0
- package/lib/typescript/module/bridge/setupNativeHost.d.ts +39 -0
- package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +107 -0
- package/lib/typescript/module/connections/disambiguate.d.ts +43 -0
- package/lib/typescript/module/connections/types.d.ts +91 -0
- package/lib/typescript/module/connections/useConnectionSetup.d.ts +96 -0
- package/lib/typescript/module/controls/FilePicker.d.ts +65 -0
- package/lib/typescript/module/controls/ImagePicker.d.ts +76 -0
- package/lib/typescript/module/index.d.ts +42 -0
- package/lib/typescript/module/logger.d.ts +11 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/platform/PowerPlatformConnectionApi.d.ts +205 -0
- package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +108 -0
- package/lib/typescript/module/platform/resolveConnections.d.ts +86 -0
- package/lib/typescript/module/platform/useConnectionRefs.d.ts +126 -0
- package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +123 -0
- package/lib/typescript/module/provider/PowerAppsProvider.d.ts +148 -0
- package/lib/typescript/module/telemetry/index.d.ts +48 -0
- package/lib/typescript/module/theme/ThemeProvider.d.ts +30 -0
- package/lib/typescript/module/theme/tokens.d.ts +27 -0
- package/lib/typescript/module/utils/dataverseUtils.d.ts +39 -0
- package/lib/typescript/module/utils/isDevPlayer.d.ts +19 -0
- package/package.json +119 -0
- package/scripts/build-ios-base.js +96 -0
- package/scripts/bundle.js +95 -0
- package/scripts/generate-connector-schemas.js +75 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — PowerAppsHostProvider
|
|
3
|
+
*
|
|
4
|
+
* A React component that owns the full pre-launch pipeline:
|
|
5
|
+
*
|
|
6
|
+
* 1. Waits for the user to be signed in.
|
|
7
|
+
* 2. Resolves connection references via useConnectionRefs (with
|
|
8
|
+
* disambiguation support).
|
|
9
|
+
* 3. If any connections are missing, renders ConnectionSetupScreen — which
|
|
10
|
+
* the user MUST complete before the app opens. There is no skip path.
|
|
11
|
+
* 4. Once all connections are resolved, initialises NativePowerAppsBridge
|
|
12
|
+
* and renders children.
|
|
13
|
+
*
|
|
14
|
+
* The consuming app passes raw config (connectionReferences, schemaMap,
|
|
15
|
+
* databaseReferences) and never touches connection resolution logic.
|
|
16
|
+
*
|
|
17
|
+
* <PowerAppsHostProvider
|
|
18
|
+
* acquireToken={acquireToken}
|
|
19
|
+
* isSignedIn={isSignedIn}
|
|
20
|
+
* environmentId="..."
|
|
21
|
+
* region="prod"
|
|
22
|
+
* connectionReferences={powerConfig.connectionReferences}
|
|
23
|
+
* schemaMap={schemaMap}
|
|
24
|
+
* databaseReferences={powerConfig.databaseReferences}
|
|
25
|
+
* >
|
|
26
|
+
* <Slot />
|
|
27
|
+
* </PowerAppsHostProvider>
|
|
28
|
+
*/
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import type { ConnectorSchema } from '../platform/useConnectionRefs';
|
|
31
|
+
import type { DatabaseReference } from '../platform/PowerPlatformEnvironmentApi';
|
|
32
|
+
import type { OnDisambiguationNeeded } from '../connections/types';
|
|
33
|
+
export interface PowerAppsHostProviderProps {
|
|
34
|
+
/**
|
|
35
|
+
* Callback to acquire an access token for the given scopes.
|
|
36
|
+
* Typically provided by your MSAL/auth layer.
|
|
37
|
+
*/
|
|
38
|
+
acquireToken: (scopes: string[]) => Promise<string | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the user is currently signed in.
|
|
41
|
+
* Connection resolution only runs when this is true.
|
|
42
|
+
*/
|
|
43
|
+
isSignedIn: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* PowerApps app GUID (from power.config.json `appId`).
|
|
46
|
+
* When set, connection references are fetched from the PowerApps RP
|
|
47
|
+
* `/apps/{appId}/launch` API at runtime instead of using the static
|
|
48
|
+
* `connectionReferences` prop. Leave undefined during local development
|
|
49
|
+
* to fall back to the static `connectionReferences`.
|
|
50
|
+
*/
|
|
51
|
+
appId?: string;
|
|
52
|
+
/** Power Platform environment GUID (from power.config.json). */
|
|
53
|
+
environmentId: string;
|
|
54
|
+
/**
|
|
55
|
+
* Routing region for the environment.
|
|
56
|
+
* @default 'prod'
|
|
57
|
+
*/
|
|
58
|
+
region?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The connectionReferences map from power.config.json.
|
|
61
|
+
* Shape: { [refId]: { id: string; dataSources: string[] } }
|
|
62
|
+
*
|
|
63
|
+
* NOTE: This prop must be referentially stable across renders (memoize it in
|
|
64
|
+
* the consumer). The bridge re-registration uses its identity as a cache key,
|
|
65
|
+
* so passing a fresh object literal every render forces continuous
|
|
66
|
+
* re-registration.
|
|
67
|
+
*/
|
|
68
|
+
connectionReferences: Record<string, {
|
|
69
|
+
id: string;
|
|
70
|
+
dataSources: string[];
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Connector schema map keyed by data source name.
|
|
74
|
+
* Generated automatically by generate-connector-schemas.
|
|
75
|
+
*/
|
|
76
|
+
schemaMap: Record<string, ConnectorSchema>;
|
|
77
|
+
/**
|
|
78
|
+
* The databaseReferences map from power.config.json.
|
|
79
|
+
* Used to build CDS data sources for the bridge.
|
|
80
|
+
*
|
|
81
|
+
* NOTE: Like `connectionReferences`, pass a referentially stable value; an
|
|
82
|
+
* unstable identity each render triggers redundant bridge re-registration.
|
|
83
|
+
*/
|
|
84
|
+
databaseReferences?: Record<string, DatabaseReference>;
|
|
85
|
+
/**
|
|
86
|
+
* Optional custom renderer for the OAuth consent WebView shown during
|
|
87
|
+
* connection creation. If not provided, the system browser is used via
|
|
88
|
+
* Linking.openURL().
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // Using react-native-webview:
|
|
92
|
+
* renderOAuthWebView={(url, onDone) => (
|
|
93
|
+
* <Modal visible animationType="slide">
|
|
94
|
+
* <WebView source={{ uri: url }} />
|
|
95
|
+
* <Button title="Done" onPress={onDone} />
|
|
96
|
+
* </Modal>
|
|
97
|
+
* )}
|
|
98
|
+
*/
|
|
99
|
+
renderOAuthWebView?: (url: string, onDone: () => void) => React.ReactNode;
|
|
100
|
+
/**
|
|
101
|
+
* The ISV/wrap-app AAD client ID (from auth.config.json `msal.clientId`).
|
|
102
|
+
* When provided, the ISV's service principal is granted CanView access on
|
|
103
|
+
* each newly created connection, allowing APIM to accept tokens with this
|
|
104
|
+
* appid at runtime (prevents 403 "missing connection ACL" for third-party tokens).
|
|
105
|
+
*/
|
|
106
|
+
isvClientId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Called when multiple Connected connections exist for the same connector.
|
|
109
|
+
* Present a native picker UI and return the chosen connectionId, or null to
|
|
110
|
+
* accept the first Connected connection as a fallback.
|
|
111
|
+
*/
|
|
112
|
+
onDisambiguationNeeded?: OnDisambiguationNeeded;
|
|
113
|
+
children: React.ReactNode;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Initialises the NativePowerAppsBridge and manages the full pre-launch
|
|
117
|
+
* pipeline — connection resolution, disambiguation, and creation — before
|
|
118
|
+
* rendering children.
|
|
119
|
+
*
|
|
120
|
+
* Children are never rendered until all required connections are resolved.
|
|
121
|
+
*/
|
|
122
|
+
export declare function PowerAppsHostProvider({ acquireToken, isSignedIn, appId, environmentId, region, connectionReferences, schemaMap, databaseReferences, renderOAuthWebView, isvClientId, onDisambiguationNeeded, children, }: PowerAppsHostProviderProps): React.JSX.Element;
|
|
123
|
+
//# sourceMappingURL=PowerAppsHostProvider.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — PowerAppsProvider
|
|
3
|
+
*
|
|
4
|
+
* A single provider that composes all infrastructure required to run a
|
|
5
|
+
* Power Apps canvas app inside an Expo shell:
|
|
6
|
+
*
|
|
7
|
+
* GestureHandlerRootView
|
|
8
|
+
* └── TamaguiProvider (defaults to @tamagui/config/v3)
|
|
9
|
+
* └── PortalProvider (required by ToastViewport)
|
|
10
|
+
* └── ToastProvider + ToastViewport
|
|
11
|
+
* └── QueryClientProvider (own QueryClient, wired to NetInfo + AppState)
|
|
12
|
+
* └── AuthProvider
|
|
13
|
+
* └── PowerAppsHostProvider (connected via useAuth)
|
|
14
|
+
* └── children
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
*
|
|
18
|
+
* <PowerAppsProvider
|
|
19
|
+
* msalConfig={authConfig.msal}
|
|
20
|
+
* powerConfig={powerConfig}
|
|
21
|
+
* schemaMap={schemaMap}
|
|
22
|
+
* >
|
|
23
|
+
* <StatusBar style="auto" />
|
|
24
|
+
* <Slot />
|
|
25
|
+
* </PowerAppsProvider>
|
|
26
|
+
*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import { createTamagui } from '@tamagui/core';
|
|
29
|
+
import type { AuthProviderProps } from '../auth/AuthContext';
|
|
30
|
+
import type { PowerAppsHostProviderProps } from './PowerAppsHostProvider';
|
|
31
|
+
import type { ConnectorSchema } from '../platform/useConnectionRefs';
|
|
32
|
+
import type { DatabaseReference } from '../platform/PowerPlatformEnvironmentApi';
|
|
33
|
+
import type { OnDisambiguationNeeded } from '../connections/types';
|
|
34
|
+
import type { ThemeTokens } from '../theme/tokens';
|
|
35
|
+
import type { ILogger } from '@microsoft/power-apps-native-common';
|
|
36
|
+
/** Shape of power.config.json consumed by the provider. */
|
|
37
|
+
export interface PowerConfig {
|
|
38
|
+
/**
|
|
39
|
+
* PowerApps app GUID written by `pac wrap` / the publish pipeline.
|
|
40
|
+
* When set, the host fetches connection references from the PowerApps RP
|
|
41
|
+
* `/apps/{appId}/launch` endpoint at runtime instead of reading the static
|
|
42
|
+
* `connectionReferences` object below. Leave `null` (or omit) during local
|
|
43
|
+
* development — the static `connectionReferences` will be used as a fallback.
|
|
44
|
+
*/
|
|
45
|
+
appId?: string | null;
|
|
46
|
+
environmentId?: string;
|
|
47
|
+
region?: string;
|
|
48
|
+
/**
|
|
49
|
+
* BAP environment `location` value (`environment.properties.location` from the
|
|
50
|
+
* Get Environments API). EU locations — `"europe"`, `"unitedkingdom"`,
|
|
51
|
+
* `"france"`, `"germany"`, `"italy"`, `"poland"`, `"norway"`, `"sweden"`,
|
|
52
|
+
* `"switzerland"` — route telemetry to the EU 1DS collector.
|
|
53
|
+
* Omit for the default global collector.
|
|
54
|
+
*/
|
|
55
|
+
geoRegion?: string;
|
|
56
|
+
connectionReferences?: Record<string, {
|
|
57
|
+
id: string;
|
|
58
|
+
dataSources: string[];
|
|
59
|
+
}>;
|
|
60
|
+
databaseReferences?: Record<string, DatabaseReference>;
|
|
61
|
+
/**
|
|
62
|
+
* Allow additional keys — the offline SDK reads arbitrary fields from
|
|
63
|
+
* powerConfig. NOTE: offline activation is configured via the app's
|
|
64
|
+
* `offline-profile.json` (embedded into the Expo manifest as
|
|
65
|
+
* `extra.__offlineProfile`), NOT via a `powerConfig` field.
|
|
66
|
+
*/
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
type TamaguiConfig = ReturnType<typeof createTamagui>;
|
|
70
|
+
export interface PowerAppsProviderProps {
|
|
71
|
+
/** MSAL configuration from auth.config.json (msal section). */
|
|
72
|
+
msalConfig: AuthProviderProps['msalConfig'];
|
|
73
|
+
/** Intune MAM configuration. Defaults to enabled in release builds. */
|
|
74
|
+
intuneConfig?: AuthProviderProps['intuneConfig'];
|
|
75
|
+
/** Contents of power.config.json. */
|
|
76
|
+
powerConfig: PowerConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Connector schema map keyed by data source name.
|
|
79
|
+
* Generated automatically by generate-connector-schemas.
|
|
80
|
+
*/
|
|
81
|
+
schemaMap: Record<string, ConnectorSchema>;
|
|
82
|
+
/**
|
|
83
|
+
* Tamagui design-system config.
|
|
84
|
+
* Defaults to the standard @tamagui/config/v3 preset.
|
|
85
|
+
*/
|
|
86
|
+
tamaguiConfig?: TamaguiConfig;
|
|
87
|
+
/** Tamagui default colour theme. @default 'light' */
|
|
88
|
+
defaultTheme?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Light-mode theme tokens for the built-in ThemeProvider.
|
|
91
|
+
* Defaults to the Power Platform green light palette.
|
|
92
|
+
* Pass a ThemeTokens object built from brand/tokens.ts to apply your brand.
|
|
93
|
+
*/
|
|
94
|
+
theme?: ThemeTokens;
|
|
95
|
+
/**
|
|
96
|
+
* Dark-mode theme tokens for the built-in ThemeProvider.
|
|
97
|
+
* Defaults to the Power Platform green dark palette.
|
|
98
|
+
*/
|
|
99
|
+
darkTheme?: ThemeTokens;
|
|
100
|
+
/**
|
|
101
|
+
* When `true`, the ThemeProvider automatically switches between `theme` and
|
|
102
|
+
* `darkTheme` based on the device colour scheme. @default true
|
|
103
|
+
*/
|
|
104
|
+
followSystemTheme?: boolean;
|
|
105
|
+
/** See PowerAppsHostProviderProps.renderOAuthWebView. */
|
|
106
|
+
renderOAuthWebView?: PowerAppsHostProviderProps['renderOAuthWebView'];
|
|
107
|
+
/** See PowerAppsHostProviderProps.onDisambiguationNeeded. */
|
|
108
|
+
onDisambiguationNeeded?: OnDisambiguationNeeded;
|
|
109
|
+
/**
|
|
110
|
+
* App name used as `clientType` in the auto-wired 1DS telemetry provider.
|
|
111
|
+
* Appears in Kusto as the `clientType` column — use a stable
|
|
112
|
+
* `<Product><Variant>` string (e.g. `'PowerAppsDevPlayer'`).
|
|
113
|
+
* Ignored when `logger` is provided or `null`.
|
|
114
|
+
*/
|
|
115
|
+
appName?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Logger to use for host-package telemetry (auth, HTTP, platform APIs).
|
|
118
|
+
*
|
|
119
|
+
* - Omit (default): a `Logger` wired to `OneDsTelemetryProvider` (1DS JS)
|
|
120
|
+
* is auto-created. `clusterCategory` is derived from `powerConfig.region`
|
|
121
|
+
* (falls back to `'dev'`). This is the recommended path for all apps.
|
|
122
|
+
* - Pass an `ILogger` instance: that logger is used as-is, giving full
|
|
123
|
+
* control over providers and severity.
|
|
124
|
+
* - Pass `null`: telemetry is explicitly disabled (opt-out). The host
|
|
125
|
+
* logger becomes a no-op regardless of build variant.
|
|
126
|
+
*/
|
|
127
|
+
logger?: ILogger | null;
|
|
128
|
+
/**
|
|
129
|
+
* Offline profile JSON — optional override.
|
|
130
|
+
* Primary source: SDK config plugin embeds offline-profile.json into the app
|
|
131
|
+
* manifest at prebuild time (read via expo-constants). This prop is only needed
|
|
132
|
+
* if you want to pass the profile programmatically (e.g., tests).
|
|
133
|
+
*/
|
|
134
|
+
offlineProfile?: Record<string, unknown>;
|
|
135
|
+
children: React.ReactNode;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Top-level provider for Power Apps canvas apps running inside an Expo shell.
|
|
139
|
+
*
|
|
140
|
+
* Composes GestureHandlerRootView, TamaguiProvider, ToastProvider,
|
|
141
|
+
* QueryClientProvider, AuthProvider, and PowerAppsHostProvider into a single
|
|
142
|
+
* component, eliminating all provider boilerplate from the consuming app's
|
|
143
|
+
* root layout.
|
|
144
|
+
*/
|
|
145
|
+
export declare function PowerAppsProvider({ msalConfig, intuneConfig, powerConfig, schemaMap, tamaguiConfig, // override with app's tamagui.config.ts
|
|
146
|
+
defaultTheme, theme, darkTheme, followSystemTheme, renderOAuthWebView, onDisambiguationNeeded, appName, logger: loggerProp, offlineProfile, children, }: PowerAppsProviderProps): React.JSX.Element;
|
|
147
|
+
export {};
|
|
148
|
+
//# sourceMappingURL=PowerAppsProvider.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* power-apps-native-host — package telemetry
|
|
5
|
+
*
|
|
6
|
+
* The shared logger singleton lives in `@microsoft/power-apps-native-common`
|
|
7
|
+
* (`getAppLogger` / `configureAppLogger`). This module re-exports those
|
|
8
|
+
* alongside the canonical host operation-name constants.
|
|
9
|
+
*/
|
|
10
|
+
export { getAppLogger, configureAppLogger } from '@microsoft/power-apps-native-common';
|
|
11
|
+
/**
|
|
12
|
+
* Canonical operation names for host package telemetry.
|
|
13
|
+
* Follow the `PowerAppsHost.<Subsystem>.<Action>` convention so events are
|
|
14
|
+
* filterable in Kusto by prefix.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HostOperationNames: {
|
|
17
|
+
/** MSAL PublicClientApplication.init() + initial account resolution. */
|
|
18
|
+
readonly AuthInit: "PowerAppsHost.Auth.Init";
|
|
19
|
+
/** Interactive sign-in (acquireToken interactive). */
|
|
20
|
+
readonly AuthSignIn: "PowerAppsHost.Auth.SignIn";
|
|
21
|
+
/** Sign-out (token cache clear + broker logout). */
|
|
22
|
+
readonly AuthSignOut: "PowerAppsHost.Auth.SignOut";
|
|
23
|
+
/** Silent token acquisition. Recorded only on failure. */
|
|
24
|
+
readonly AuthAcquireTokenSilentFailed: "PowerAppsHost.Auth.AcquireTokenSilent.Failed";
|
|
25
|
+
/** Intune MAM enrollment after sign-in. */
|
|
26
|
+
readonly AuthIntuneEnroll: "PowerAppsHost.Auth.Intune.Enroll";
|
|
27
|
+
/** Intune MAM unenrollment during sign-out. */
|
|
28
|
+
readonly AuthIntuneUnenroll: "PowerAppsHost.Auth.Intune.Unenroll";
|
|
29
|
+
/** SDK-originated HTTP request relayed through NativePowerAppsBridge. */
|
|
30
|
+
readonly BridgeHttpRequest: "PowerAppsHost.Bridge.HttpRequest";
|
|
31
|
+
/** Plugin call forwarded through NativePowerAppsBridge (verbose; also used for unhandled). */
|
|
32
|
+
readonly BridgeUnhandledPlugin: "PowerAppsHost.Bridge.PluginCall";
|
|
33
|
+
/** Connector/Dataverse token acquisition for the bridge. Recorded only on failure. */
|
|
34
|
+
readonly BridgeTokenAcquireFailed: "PowerAppsHost.Bridge.TokenAcquire.Failed";
|
|
35
|
+
/** Top-level React error boundary caught an unhandled JS error. */
|
|
36
|
+
readonly RuntimeUnhandledJsError: "PowerAppsHost.Runtime.UnhandledJsError";
|
|
37
|
+
/** Resolve Dataverse instanceUrl from Power Platform environment API. */
|
|
38
|
+
readonly PlatformFetchInstanceUrl: "PowerAppsHost.Platform.FetchInstanceUrl";
|
|
39
|
+
/** useConnectionRefs failed to resolve connections (recoverable). Recorded only on failure. */
|
|
40
|
+
readonly PlatformLoadConnectionsFailed: "PowerAppsHost.Platform.LoadConnections.Failed";
|
|
41
|
+
/** Create a new Power Platform connection. */
|
|
42
|
+
readonly PlatformCreateConnection: "PowerAppsHost.Platform.CreateConnection";
|
|
43
|
+
/** Resolve app connection references for the current launch. */
|
|
44
|
+
readonly PlatformResolveConnectionRefs: "PowerAppsHost.Platform.ResolveConnectionRefs";
|
|
45
|
+
/** Grant this app access to a Power Platform connection ACL. */
|
|
46
|
+
readonly PlatformConnectionAclGrant: "PowerAppsHost.Platform.ConnectionAclGrant";
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemeProvider — distributes {@link ThemeTokens} through the component tree.
|
|
3
|
+
*
|
|
4
|
+
* `PowerAppsProvider` mounts this automatically. Use directly only when
|
|
5
|
+
* composing providers manually.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { type ThemeTokens } from './tokens';
|
|
9
|
+
export interface ThemeControl {
|
|
10
|
+
setTheme: (tokens: ThemeTokens) => void;
|
|
11
|
+
resetTheme: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface ThemeProviderProps {
|
|
14
|
+
theme?: ThemeTokens;
|
|
15
|
+
darkTheme?: ThemeTokens;
|
|
16
|
+
/** @default true */
|
|
17
|
+
followSystem?: boolean;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export declare function ThemeProvider({ theme, darkTheme, followSystem, children, }: ThemeProviderProps): React.JSX.Element;
|
|
21
|
+
/** Returns current {@link ThemeTokens} from the nearest ThemeProvider. */
|
|
22
|
+
export declare function useThemeTokens(): ThemeTokens;
|
|
23
|
+
/**
|
|
24
|
+
* Returns `{ setTheme, resetTheme }` for imperative theme overrides.
|
|
25
|
+
* Stable reference — does not re-render consumers on theme change.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useThemeControl(): ThemeControl;
|
|
28
|
+
export type { ThemeTokens } from './tokens';
|
|
29
|
+
export { lightTheme, darkTheme } from './tokens';
|
|
30
|
+
//# sourceMappingURL=ThemeProvider.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme token schema and built-in palettes for power-apps-native-host.
|
|
3
|
+
*
|
|
4
|
+
* Pass a custom {@link ThemeTokens} object to `PowerAppsProvider` to override
|
|
5
|
+
* the default Microsoft blue palette.
|
|
6
|
+
*/
|
|
7
|
+
export interface ThemeTokens {
|
|
8
|
+
surface0: string;
|
|
9
|
+
surface1: string;
|
|
10
|
+
surface2: string;
|
|
11
|
+
surface3: string;
|
|
12
|
+
surface4: string;
|
|
13
|
+
text0: string;
|
|
14
|
+
text1: string;
|
|
15
|
+
text2: string;
|
|
16
|
+
text3: string;
|
|
17
|
+
accentDeep: string;
|
|
18
|
+
accentBase: string;
|
|
19
|
+
accentSoft: string;
|
|
20
|
+
accentOnAccent: string;
|
|
21
|
+
isDark: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Microsoft blue light palette (default). */
|
|
24
|
+
export declare const lightTheme: ThemeTokens;
|
|
25
|
+
/** Microsoft blue dark palette (default). */
|
|
26
|
+
export declare const darkTheme: ThemeTokens;
|
|
27
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for reading local file:// URIs and converting them into the binary
|
|
3
|
+
* format expected by the Dataverse upload endpoint via NativePowerAppsBridge.
|
|
4
|
+
*
|
|
5
|
+
* Background:
|
|
6
|
+
* - `fetch('file://')` fails silently on Android.
|
|
7
|
+
* - `fetch('data:...')` throws "Network request failed" on Android.
|
|
8
|
+
* - `new Blob([Uint8Array])` crashes Hermes ("ArrayBufferView not supported").
|
|
9
|
+
* - NativePowerAppsBridge accepts `Uint8Array` and extracts `.buffer` as the
|
|
10
|
+
* fetch body, which React Native sends as raw bytes correctly.
|
|
11
|
+
*
|
|
12
|
+
* Solution: read via `readAsStringAsync` (base64) → `atob` → `Uint8Array`.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Read a local `file://` URI and return its contents as a `Uint8Array`.
|
|
16
|
+
* Safe on both Android and iOS.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readFileAsUint8Array(uri: string): Promise<Uint8Array>;
|
|
19
|
+
/**
|
|
20
|
+
* Detect the image MIME type from the first bytes of a base64-encoded string.
|
|
21
|
+
* Returns 'image/jpeg' as a safe default.
|
|
22
|
+
*/
|
|
23
|
+
export declare function detectImageMime(base64: string): string;
|
|
24
|
+
/** Convert a base64 string into bytes suitable for Dataverse binary upload APIs. */
|
|
25
|
+
export declare function base64ToUint8Array(base64: string): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* Create a lightweight File-compatible object for generated Dataverse upload methods.
|
|
28
|
+
* React Native does not consistently provide a browser File implementation, but the
|
|
29
|
+
* generated services only require `name` and `arrayBuffer()`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createDataverseUploadFile(name: string, mimeType: string, bytes: Uint8Array): File;
|
|
32
|
+
/** Create a File-compatible image object from Dataverse-style base64 image content. */
|
|
33
|
+
export declare function base64ToDataverseUploadFile(base64: string, name?: string): File;
|
|
34
|
+
/**
|
|
35
|
+
* Build a `data:<mime>;base64,<data>` URI from a raw base64 string returned
|
|
36
|
+
* by Dataverse for an image column.
|
|
37
|
+
*/
|
|
38
|
+
export declare function base64ToDataUri(base64: string): string;
|
|
39
|
+
//# sourceMappingURL=dataverseUtils.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when the JS bundle is running inside the Power Apps Dev Player shell.
|
|
3
|
+
*
|
|
4
|
+
* Two signals are combined to cover both execution paths:
|
|
5
|
+
*
|
|
6
|
+
* 1. `Constants.expoConfig.extra.isDevPlayer` — set in apps/dev-player/app.config.js.
|
|
7
|
+
* Fires when the dev-player's **own** JS bundle is active (e.g. the launcher screen).
|
|
8
|
+
*
|
|
9
|
+
* 2. `NativeModules.PowerAppsDevLauncher` — the dev-player's Expo native module,
|
|
10
|
+
* registered in the dev-player APK/IPA regardless of which JS bundle is loaded.
|
|
11
|
+
* Fires when a template bundle is loaded via QR-code/URL into the dev-player shell,
|
|
12
|
+
* because expo-constants then reflects the template's manifest (no isDevPlayer flag)
|
|
13
|
+
* but the native module is still present in the host binary.
|
|
14
|
+
*
|
|
15
|
+
* Neither signal fires in a standalone release APK generated from the template, so
|
|
16
|
+
* `isDevPlayer` is false there and all debug logging is silenced.
|
|
17
|
+
*/
|
|
18
|
+
export declare const isDevPlayer: boolean;
|
|
19
|
+
//# sourceMappingURL=isDevPlayer.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
interface State {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
componentStack: string | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Top-level React error boundary.
|
|
12
|
+
*
|
|
13
|
+
* Catches any unhandled JS exception thrown during rendering / lifecycle and
|
|
14
|
+
* displays a diagnostic screen. All error details are written to the native
|
|
15
|
+
* log via debugLog so diagnostics stay consistent with the host package logger.
|
|
16
|
+
*
|
|
17
|
+
* Place this component at the very root of the component tree so it captures
|
|
18
|
+
* failures in any screen.
|
|
19
|
+
*
|
|
20
|
+
* Exported from power-apps-native-host so it can be used in the template and
|
|
21
|
+
* in any custom app without duplicating the implementation.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ErrorBoundary extends React.Component<Props, State> {
|
|
24
|
+
state: State;
|
|
25
|
+
static getDerivedStateFromError(error: Error): Partial<State>;
|
|
26
|
+
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
27
|
+
render(): React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=ErrorBoundary.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — AuthContext
|
|
3
|
+
*
|
|
4
|
+
* A generic MSAL auth provider built on power-apps-native-auth's
|
|
5
|
+
* PublicClientApplication. Provides AuthProvider, useAuth, and the
|
|
6
|
+
* AuthState / AuthProviderProps types.
|
|
7
|
+
*
|
|
8
|
+
* Usage in the consuming Expo app:
|
|
9
|
+
*
|
|
10
|
+
* <AuthProvider msalConfig={authConfig.msal}>
|
|
11
|
+
* <PowerAppsHostProvider acquireToken={acquireToken} ...>
|
|
12
|
+
* {children}
|
|
13
|
+
* </PowerAppsHostProvider>
|
|
14
|
+
* </AuthProvider>
|
|
15
|
+
*/
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import type { MsalAuthConfig, IntuneConfig } from '@microsoft/power-apps-native-auth';
|
|
18
|
+
export interface AuthState {
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
isAuthReady: boolean;
|
|
21
|
+
isSignedIn: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* True only when a real MSAL account is present (a usable token can be
|
|
24
|
+
* acquired). Unlike `isSignedIn`, this is NOT inflated by `noAuthMode`
|
|
25
|
+
* (login-bypassed / demo sessions report `isSignedIn: true` but have no
|
|
26
|
+
* account and `acquireToken` always returns null). Offline engagement must
|
|
27
|
+
* gate on this — engaging offline without a token spins the SDK orchestrator
|
|
28
|
+
* in a perpetual "waiting-for-auth" retry loop.
|
|
29
|
+
*/
|
|
30
|
+
hasRealAccount: boolean;
|
|
31
|
+
error: Error | null;
|
|
32
|
+
acquireToken: (scopes: string[]) => Promise<string | null>;
|
|
33
|
+
signIn: () => Promise<void>;
|
|
34
|
+
signOut: () => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface AuthProviderProps {
|
|
37
|
+
/**
|
|
38
|
+
* MSAL configuration from the consuming app's auth.config.json (msal section).
|
|
39
|
+
* `useBroker` defaults to `!__DEV__` when omitted — broker is enabled
|
|
40
|
+
* automatically in release builds and disabled in the dev client.
|
|
41
|
+
*/
|
|
42
|
+
msalConfig: MsalAuthConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Intune MAM configuration. `enabled` defaults to `!__DEV__` when omitted,
|
|
45
|
+
* so MAM enrollment is active in release builds and skipped in the dev client.
|
|
46
|
+
* Pass explicitly only to override the default (e.g. in tests).
|
|
47
|
+
*/
|
|
48
|
+
intuneConfig?: IntuneConfig;
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
export declare function AuthProvider({ msalConfig, intuneConfig, children }: AuthProviderProps): React.JSX.Element;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the current auth state from the nearest <AuthProvider>.
|
|
54
|
+
* Must be called within the AuthProvider tree.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useAuth(): AuthState;
|
|
57
|
+
//# sourceMappingURL=AuthContext.d.ts.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — NativePowerAppsBridge
|
|
3
|
+
*
|
|
4
|
+
* A PowerAppsBridge implementation for React Native that handles all plugin
|
|
5
|
+
* calls in-process: auth tokens are supplied by the host app via callbacks,
|
|
6
|
+
* and HTTP is performed with the global `fetch` (built into RN 0.60+).
|
|
7
|
+
*
|
|
8
|
+
* This file mirrors the bridge in the SDK but lives here so the package can
|
|
9
|
+
* be used without patching the published @microsoft/power-apps tarball.
|
|
10
|
+
*/
|
|
11
|
+
import type { NativeConnectionInstance } from '../connections/types.js';
|
|
12
|
+
export type CdsDataSourceConfig = Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Per-connection-reference data keyed by data source name
|
|
15
|
+
* (e.g. "commondataserviceforapps", "office365users").
|
|
16
|
+
* Returned to the SDK for AppPowerAppsClientPlugin.loadAppConnectionsAsync_v2
|
|
17
|
+
* and AppPowerAppsClientPlugin.loadNonCompositeConnectionsAsync.
|
|
18
|
+
*/
|
|
19
|
+
export interface AppConnectionReference {
|
|
20
|
+
/** Connector API ID, e.g. "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps" */
|
|
21
|
+
apiId: string;
|
|
22
|
+
/** Connector runtime base URL (environment-specific). */
|
|
23
|
+
runtimeUrl: string;
|
|
24
|
+
/** Per-user connection identifier assigned by Power Platform. */
|
|
25
|
+
connectionName: string;
|
|
26
|
+
/** Dataset name (e.g. Dataverse org URL for CDS). */
|
|
27
|
+
datasetName?: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
instances?: NativeConnectionInstance[];
|
|
30
|
+
}
|
|
31
|
+
/** @deprecated Use AppConnectionReference */
|
|
32
|
+
export type AppConnection = AppConnectionReference;
|
|
33
|
+
/**
|
|
34
|
+
* Build a connection-references map (keyed by data source name) from the
|
|
35
|
+
* `connectionReferences` section of power.config.json.
|
|
36
|
+
*
|
|
37
|
+
* Each entry from power.config.json looks like:
|
|
38
|
+
* { id: "/providers/Microsoft.PowerApps/apis/shared_XXX", dataSources: ["XXX"], ... }
|
|
39
|
+
*
|
|
40
|
+
* The resulting map shape is what the SDK expects for loadAppConnectionsAsync_v2:
|
|
41
|
+
* { XXX: { apiId, runtimeUrl, connectionName, datasetName } }
|
|
42
|
+
*
|
|
43
|
+
* `runtimeUrl` and `connectionName` default to empty strings — they must be
|
|
44
|
+
* populated at runtime from the Power Platform connections API for the SDK to
|
|
45
|
+
* make actual connector API calls.
|
|
46
|
+
*
|
|
47
|
+
* @param powerConfigConnectionReferences - The `connectionReferences` object
|
|
48
|
+
* from power.config.json.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildConnectionReferences(powerConfigConnectionReferences: Record<string, {
|
|
51
|
+
id: string;
|
|
52
|
+
dataSources: string[];
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}>): Record<string, AppConnectionReference>;
|
|
55
|
+
export type NativeBridgeOptions = {
|
|
56
|
+
/**
|
|
57
|
+
* Return an auth token scoped to a connector API endpoint.
|
|
58
|
+
* @param apiId - Connection API identifier (e.g. "shared_sharepointonline").
|
|
59
|
+
*/
|
|
60
|
+
getConnectorToken(apiId: string): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Return an auth token for a Dataverse org URL.
|
|
63
|
+
* @param datasetName - The Dataverse org URL used as the OAuth resource.
|
|
64
|
+
*/
|
|
65
|
+
getDataverseToken(datasetName: string): Promise<string>;
|
|
66
|
+
/** Data-source configs from the app manifest / Power Apps server response. */
|
|
67
|
+
dataSources: CdsDataSourceConfig[];
|
|
68
|
+
/**
|
|
69
|
+
* Connection references keyed by data source name
|
|
70
|
+
* (e.g. { commondataserviceforapps: { apiId, runtimeUrl, connectionName } }).
|
|
71
|
+
* Returned to the SDK for loadAppConnectionsAsync_v2 and
|
|
72
|
+
* loadNonCompositeConnectionsAsync. Build from power.config.json's
|
|
73
|
+
* connectionReferences using buildConnectionReferences().
|
|
74
|
+
*/
|
|
75
|
+
connections: Record<string, AppConnectionReference>;
|
|
76
|
+
};
|
|
77
|
+
export declare class NativePowerAppsBridge {
|
|
78
|
+
private _options;
|
|
79
|
+
constructor(_options: NativeBridgeOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Updates the bridge's options in-place.
|
|
82
|
+
*
|
|
83
|
+
* Call this when connection references or data sources change (e.g. after
|
|
84
|
+
* a new connection is created) without recreating the bridge. The SDK caches
|
|
85
|
+
* the bridge instance after the first data operation, so replacing the bridge
|
|
86
|
+
* via globalThis would have no effect — mutating options is the correct path.
|
|
87
|
+
*/
|
|
88
|
+
updateOptions(options: NativeBridgeOptions): void;
|
|
89
|
+
initialize(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Hermes-safe body construction. Returns the raw body value so that
|
|
92
|
+
* _sendHttpAsync can pass it directly to fetch without any Blob wrapping.
|
|
93
|
+
*
|
|
94
|
+
* The web-player's RuntimeDataClient wraps all bodies in `new Blob([...])`,
|
|
95
|
+
* which Hermes does not support for ArrayBuffer / TypedArray inputs.
|
|
96
|
+
* Implementing this hook on the bridge bypasses that wrapping entirely.
|
|
97
|
+
*/
|
|
98
|
+
createRequestBody(config: {
|
|
99
|
+
body?: string | Uint8Array | ArrayBuffer | Blob;
|
|
100
|
+
headers?: {
|
|
101
|
+
[key: string]: string;
|
|
102
|
+
};
|
|
103
|
+
}): Blob | string | Uint8Array | ArrayBuffer;
|
|
104
|
+
executePluginAsync<T = unknown>(pluginName: string, pluginAction: string, params: unknown[]): Promise<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Calls fetch and returns the result in the exact shape expected by
|
|
107
|
+
* RuntimeDataClient._executeRequest:
|
|
108
|
+
* [{ status: number; headers: Record<string, string> }, ArrayBuffer]
|
|
109
|
+
*/
|
|
110
|
+
private _sendHttpAsync;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=NativePowerAppsBridge.d.ts.map
|