@microsoft/power-apps-native-host 0.2.25 → 0.3.3

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 (154) hide show
  1. package/README.md +21 -10
  2. package/compatibility/current.json +31 -4
  3. package/lib/NOTICE.txt +1325 -24
  4. package/lib/commonjs/auth/AuthContext.js +110 -33
  5. package/lib/commonjs/bridge/NativePowerAppsBridge.js +11 -18
  6. package/lib/commonjs/bridge/PowerPagesBridge.js +27 -8
  7. package/lib/commonjs/bridge/bridgeState.js +40 -0
  8. package/lib/commonjs/config/babelConfig.js +13 -0
  9. package/lib/commonjs/config/expoConfig.js +71 -0
  10. package/lib/commonjs/config/metroConfig.js +70 -0
  11. package/lib/commonjs/config/metroLogger.js +182 -0
  12. package/lib/commonjs/config/tamaguiConfig.js +98 -0
  13. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  14. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  15. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  16. package/lib/commonjs/connections/connectionState.js +96 -0
  17. package/lib/commonjs/connections/disambiguate.js +19 -11
  18. package/lib/commonjs/connections/resolveConnections.js +348 -0
  19. package/lib/commonjs/connections/types.js +106 -0
  20. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +130 -65
  21. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  22. package/lib/commonjs/controls/FilePicker.js +6 -0
  23. package/lib/commonjs/controls/ImagePicker.js +8 -0
  24. package/lib/commonjs/index.js +167 -4
  25. package/lib/commonjs/logger.js +9 -6
  26. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  27. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +48 -0
  28. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  29. package/lib/commonjs/platform/DataverseDataSources.js +18 -0
  30. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +94 -0
  31. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  32. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  33. package/lib/commonjs/provider/PowerAppsHostProvider.js +157 -25
  34. package/lib/commonjs/provider/PowerAppsProvider.js +178 -134
  35. package/lib/commonjs/provider/SessionDetailsGesture.js +208 -0
  36. package/lib/commonjs/telemetry/OfflineSdkTelemetry.js +95 -0
  37. package/lib/commonjs/telemetry/OfflineSdkTelemetry.web.js +9 -0
  38. package/lib/commonjs/telemetry/index.js +22 -3
  39. package/lib/module/auth/AuthContext.js +110 -33
  40. package/lib/module/bridge/NativePowerAppsBridge.js +12 -19
  41. package/lib/module/bridge/PowerPagesBridge.js +27 -8
  42. package/lib/module/bridge/bridgeState.js +34 -0
  43. package/lib/module/config/babelConfig.js +9 -0
  44. package/lib/module/config/expoConfig.js +67 -0
  45. package/lib/module/config/metroConfig.js +65 -0
  46. package/lib/module/config/metroLogger.js +175 -0
  47. package/lib/module/config/tamaguiConfig.js +93 -0
  48. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  49. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  50. package/lib/module/connections/connectionMetadata.js +112 -0
  51. package/lib/module/connections/connectionState.js +82 -0
  52. package/lib/module/connections/disambiguate.js +19 -12
  53. package/lib/module/connections/resolveConnections.js +343 -0
  54. package/lib/module/connections/types.js +91 -0
  55. package/lib/module/{platform → connections}/useConnectionRefs.js +131 -66
  56. package/lib/module/connections/useConnectionSetup.js +113 -54
  57. package/lib/module/controls/FilePicker.js +6 -0
  58. package/lib/module/controls/ImagePicker.js +8 -0
  59. package/lib/module/index.js +14 -4
  60. package/lib/module/logger.js +8 -6
  61. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  62. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +44 -0
  63. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  64. package/lib/module/platform/DataverseDataSources.js +13 -0
  65. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +89 -0
  66. package/lib/module/platform/GlobalDiscovery.js +45 -0
  67. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  68. package/lib/module/provider/PowerAppsHostProvider.js +160 -28
  69. package/lib/module/provider/PowerAppsProvider.js +182 -138
  70. package/lib/module/provider/SessionDetailsGesture.js +203 -0
  71. package/lib/module/telemetry/OfflineSdkTelemetry.js +91 -0
  72. package/lib/module/telemetry/OfflineSdkTelemetry.web.js +5 -0
  73. package/lib/module/telemetry/index.js +15 -4
  74. package/lib/typescript/commonjs/auth/AuthContext.d.ts +3 -1
  75. package/lib/typescript/commonjs/auth/AuthContext.web.d.ts +1 -0
  76. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  77. package/lib/typescript/commonjs/config/babelConfig.d.ts +12 -0
  78. package/lib/typescript/commonjs/config/expoConfig.d.ts +21 -0
  79. package/lib/typescript/commonjs/config/metroConfig.d.ts +6 -0
  80. package/lib/typescript/commonjs/config/metroLogger.d.ts +21 -0
  81. package/lib/typescript/commonjs/config/tamaguiConfig.d.ts +1792 -0
  82. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  83. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  84. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  85. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  86. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  87. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +22 -20
  88. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  89. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +36 -25
  90. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  91. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  92. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  93. package/lib/typescript/commonjs/index.d.ts +18 -10
  94. package/lib/typescript/commonjs/logger.d.ts +4 -4
  95. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  96. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  97. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  98. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +28 -0
  99. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  100. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  101. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  102. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  103. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +54 -9
  104. package/lib/typescript/commonjs/provider/SessionDetailsGesture.d.ts +13 -0
  105. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  106. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  107. package/lib/typescript/commonjs/telemetry/index.d.ts +13 -1
  108. package/lib/typescript/module/auth/AuthContext.d.ts +3 -1
  109. package/lib/typescript/module/auth/AuthContext.web.d.ts +1 -0
  110. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  111. package/lib/typescript/module/config/babelConfig.d.ts +12 -0
  112. package/lib/typescript/module/config/expoConfig.d.ts +21 -0
  113. package/lib/typescript/module/config/metroConfig.d.ts +6 -0
  114. package/lib/typescript/module/config/metroLogger.d.ts +21 -0
  115. package/lib/typescript/module/config/tamaguiConfig.d.ts +1792 -0
  116. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  117. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  118. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  119. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  120. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  121. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +22 -20
  122. package/lib/typescript/module/connections/types.d.ts +129 -1
  123. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +36 -25
  124. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  125. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  126. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  127. package/lib/typescript/module/index.d.ts +18 -10
  128. package/lib/typescript/module/logger.d.ts +4 -4
  129. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  130. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  131. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  132. package/lib/typescript/module/platform/DataverseDataSources.d.ts +28 -0
  133. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  134. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  135. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  136. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  137. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +54 -9
  138. package/lib/typescript/module/provider/SessionDetailsGesture.d.ts +13 -0
  139. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  140. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  141. package/lib/typescript/module/telemetry/index.d.ts +13 -1
  142. package/package.json +52 -13
  143. package/scripts/build-codegen-package.js +283 -0
  144. package/scripts/start-web.mjs +9 -5
  145. package/scripts/upgrade/runtime.js +139 -24
  146. package/scripts/upgrade-authoring.js +274 -180
  147. package/scripts/upgrade.js +10 -16
  148. package/src/config/generated-config.d.ts +4 -0
  149. package/src/config/index.d.ts +3 -0
  150. package/src/config/tsconfig.json +26 -0
  151. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  152. package/lib/commonjs/platform/resolveConnections.js +0 -264
  153. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  154. package/lib/module/platform/resolveConnections.js +0 -259
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.enablePowerNativeMetroLogging = enablePowerNativeMetroLogging;
7
+ exports.redactMetroLog = redactMetroLog;
8
+ exports.withPowerNativeMetroLogging = withPowerNativeMetroLogging;
9
+ var _nodeFs = _interopRequireDefault(require("node:fs"));
10
+ var _nodePath = _interopRequireDefault(require("node:path"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const SENSITIVE_LINE_PATTERN = /\b(?:authorization|bearer|client[_-]?secret|password|token|access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|accountkey|sharedaccesskey)\b|[?&](?:sig|se|sp|sv|token|access_token|code|client_secret)=|\b(?:AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{30,}|sk-[A-Za-z0-9]{20,})\b/i;
13
+ const DEFAULT_MAX_ERROR_BODY_BYTES = 256 * 1024;
14
+ const stateByRoot = new Map();
15
+ function stripAnsi(value) {
16
+ return String(value).replace(/[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*)?\u0007)|(?:(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g, '');
17
+ }
18
+ function redactMetroLog(value) {
19
+ return stripAnsi(value).replace(/[^\r\n]*(?:\r\n|\r|\n)|[^\r\n]+$/g, line => {
20
+ if (!SENSITIVE_LINE_PATTERN.test(line)) return line;
21
+ const ending = line.endsWith('\r\n') ? '\r\n' : line.endsWith('\n') ? '\n' : line.endsWith('\r') ? '\r' : '';
22
+ return `[powernative] [REDACTED_SENSITIVE_LINE]${ending}`;
23
+ });
24
+ }
25
+ function toError(value) {
26
+ return value instanceof Error ? value : new Error(String(value));
27
+ }
28
+ function writeDiagnostic(state, message) {
29
+ try {
30
+ state.diagnosticWrite(message);
31
+ } catch (error) {
32
+ state.diagnosticWriteError = toError(error);
33
+ }
34
+ }
35
+ function reportInstrumentationError(state, error, phase) {
36
+ if (state.instrumentationError) return;
37
+ const normalizedError = toError(error);
38
+ const context = {
39
+ phase,
40
+ logPath: state.logPath
41
+ };
42
+ state.instrumentationError = {
43
+ error: normalizedError,
44
+ context
45
+ };
46
+ if (state.onError) {
47
+ try {
48
+ state.onError(normalizedError, context);
49
+ return;
50
+ } catch (callbackError) {
51
+ state.onErrorFailure = toError(callbackError);
52
+ writeDiagnostic(state, `[powernative] Metro logging instrumentation failed during ${phase}: ${normalizedError.message}; onError callback also failed: ${state.onErrorFailure.message}\n`);
53
+ return;
54
+ }
55
+ }
56
+ writeDiagnostic(state, `[powernative] Metro logging instrumentation failed during ${phase}: ${normalizedError.message}\n`);
57
+ }
58
+ function createMetroLogState(projectRoot, onError) {
59
+ const root = _nodePath.default.resolve(projectRoot || process.cwd());
60
+ const logDir = _nodePath.default.join(root, '.powernative', 'metro-logs');
61
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
62
+ const patchedWrite = process.stderr.write;
63
+ const stderrWrite = patchedWrite.__powerNativeMetroLoggerOriginal || patchedWrite;
64
+ const state = {
65
+ root,
66
+ logDir,
67
+ stamp,
68
+ port: 'unknown',
69
+ logPath: _nodePath.default.join(logDir, `metro-${stamp}-pid-${process.pid}-port-unknown.log`),
70
+ onError: onError || null,
71
+ instrumentationError: null,
72
+ diagnosticWrite: message => Reflect.apply(stderrWrite, process.stderr, [message])
73
+ };
74
+ stateByRoot.set(root, state);
75
+ return state;
76
+ }
77
+ function getMetroLogState(projectRoot, onError) {
78
+ const root = _nodePath.default.resolve(projectRoot || process.cwd());
79
+ const state = stateByRoot.get(root) || createMetroLogState(root, onError);
80
+ if (onError) state.onError = onError;
81
+ return state;
82
+ }
83
+ function appendMetroLog(state, value) {
84
+ try {
85
+ _nodeFs.default.mkdirSync(state.logDir, {
86
+ recursive: true
87
+ });
88
+ _nodeFs.default.appendFileSync(state.logPath, redactMetroLog(value));
89
+ } catch (error) {
90
+ reportInstrumentationError(state, error, 'log persistence');
91
+ }
92
+ }
93
+ function setMetroLogPort(state, port) {
94
+ if (!Number.isInteger(port) || port <= 0 || String(port) === state.port) return;
95
+ const previousPath = state.logPath;
96
+ state.port = String(port);
97
+ state.logPath = _nodePath.default.join(state.logDir, `metro-${state.stamp}-pid-${process.pid}-port-${state.port}.log`);
98
+ try {
99
+ _nodeFs.default.mkdirSync(state.logDir, {
100
+ recursive: true
101
+ });
102
+ if (_nodeFs.default.existsSync(previousPath) && previousPath !== state.logPath) {
103
+ _nodeFs.default.renameSync(previousPath, state.logPath);
104
+ }
105
+ } catch (error) {
106
+ state.logPath = previousPath;
107
+ reportInstrumentationError(state, error, 'port-tagged log rename');
108
+ }
109
+ }
110
+ function extractMetroPort(value) {
111
+ const match = String(value).match(/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\]):(\d{2,5})/);
112
+ const port = match ? Number(match[1]) : null;
113
+ return Number.isInteger(port) && Number(port) > 0 && Number(port) <= 65535 ? port : null;
114
+ }
115
+ function patchStream(stream, key, state) {
116
+ const originalWrite = stream.write;
117
+ if (originalWrite.__powerNativeMetroLoggerPatched) return;
118
+ const patchedWrite = function (chunk, ...args) {
119
+ try {
120
+ const text = Buffer.isBuffer(chunk) ? chunk.toString('utf8') : String(chunk);
121
+ appendMetroLog(state, text);
122
+ const port = extractMetroPort(text);
123
+ if (port) setMetroLogPort(state, port);
124
+ } catch (error) {
125
+ reportInstrumentationError(state, error, `${key} capture`);
126
+ }
127
+ return Reflect.apply(originalWrite, stream, [chunk, ...args]);
128
+ };
129
+ patchedWrite.__powerNativeMetroLoggerPatched = true;
130
+ patchedWrite.__powerNativeMetroLoggerOriginal = originalWrite;
131
+ stream.write = patchedWrite;
132
+ }
133
+ function enablePowerNativeMetroLogging(options = {}) {
134
+ const state = getMetroLogState(options.projectRoot, options.onError);
135
+ try {
136
+ patchStream(process.stdout, 'stdout', state);
137
+ patchStream(process.stderr, 'stderr', state);
138
+ appendMetroLog(state, `[powernative] Metro log started pid=${process.pid}\n`);
139
+ } catch (error) {
140
+ reportInstrumentationError(state, error, 'stream setup');
141
+ }
142
+ return {
143
+ logDir: state.logDir,
144
+ logPath: state.logPath
145
+ };
146
+ }
147
+ function withPowerNativeMetroLogging(middleware, options = {}) {
148
+ const state = getMetroLogState(options.projectRoot, options.onError);
149
+ const maxBodyBytes = Number.isInteger(options.maxBodyBytes) && Number(options.maxBodyBytes) > 0 ? Number(options.maxBodyBytes) : DEFAULT_MAX_ERROR_BODY_BYTES;
150
+ enablePowerNativeMetroLogging(options);
151
+ return (request, response, next) => {
152
+ try {
153
+ setMetroLogPort(state, Number(request.socket.localPort));
154
+ const chunks = [];
155
+ let capturedBytes = 0;
156
+ const write = response.write.bind(response);
157
+ const end = response.end.bind(response);
158
+ function captureChunk(chunk, encoding) {
159
+ if (!chunk || capturedBytes >= maxBodyBytes) return;
160
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), typeof encoding === 'string' ? encoding : undefined);
161
+ const remaining = maxBodyBytes - capturedBytes;
162
+ chunks.push(buffer.length > remaining ? buffer.subarray(0, remaining) : buffer);
163
+ capturedBytes += Math.min(buffer.length, remaining);
164
+ }
165
+ response.write = (chunk, ...args) => {
166
+ captureChunk(chunk, args[0]);
167
+ return Reflect.apply(write, response, [chunk, ...args]);
168
+ };
169
+ response.end = (chunk, ...args) => {
170
+ captureChunk(chunk, args[0]);
171
+ if (response.statusCode >= 400) {
172
+ const body = Buffer.concat(chunks).toString('utf8').slice(0, maxBodyBytes);
173
+ appendMetroLog(state, `\n[powernative] HTTP ${request.method} ${request.url} -> ${response.statusCode}\n${body}\n`);
174
+ }
175
+ return Reflect.apply(end, response, [chunk, ...args]);
176
+ };
177
+ } catch (error) {
178
+ reportInstrumentationError(state, error, 'HTTP middleware setup');
179
+ }
180
+ return middleware(request, response, next);
181
+ };
182
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPowerAppsTamaguiConfig = createPowerAppsTamaguiConfig;
7
+ exports.withPowerAppsSemanticAliases = withPowerAppsSemanticAliases;
8
+ var _core = require("@tamagui/core");
9
+ var _v = require("@tamagui/config/v5");
10
+ var _v5Rn = require("@tamagui/config/v5-rn");
11
+ function parseColorChannels(color) {
12
+ const hexMatch = color.match(/^#([\da-f]{3}|[\da-f]{6})$/i);
13
+ if (hexMatch) {
14
+ const hex = hexMatch[1].length === 3 ? [...hexMatch[1]].map(value => `${value}${value}`).join('') : hexMatch[1];
15
+ return [0, 2, 4].map(offset => Number.parseInt(hex.slice(offset, offset + 2), 16) / 255);
16
+ }
17
+ const rgbMatch = color.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/i);
18
+ if (rgbMatch) {
19
+ const values = rgbMatch.slice(1, 4).map(Number);
20
+ if (values.some(value => !Number.isFinite(value) || value < 0 || value > 255)) return null;
21
+ const alpha = rgbMatch[4] === undefined ? 1 : Number(rgbMatch[4]);
22
+ if (!Number.isFinite(alpha) || alpha !== 1) return null;
23
+ return values.map(value => value / 255);
24
+ }
25
+ const hslMatch = color.match(/^hsla?\(\s*([-\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i);
26
+ if (!hslMatch) return null;
27
+ const hsl = hslMatch.slice(1, 4).map(Number);
28
+ if (hsl.some(value => !Number.isFinite(value))) return null;
29
+ const alpha = hslMatch[4] === undefined ? 1 : Number(hslMatch[4]);
30
+ if (!Number.isFinite(alpha) || alpha !== 1) return null;
31
+ const hue = (hsl[0] % 360 + 360) % 360;
32
+ const saturation = hsl[1] / 100;
33
+ const lightness = hsl[2] / 100;
34
+ if (saturation < 0 || saturation > 1 || lightness < 0 || lightness > 1) return null;
35
+ const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
36
+ const intermediate = chroma * (1 - Math.abs(hue / 60 % 2 - 1));
37
+ const offset = lightness - chroma / 2;
38
+ const segment = Math.floor(hue / 60);
39
+ const rgb = [[chroma, intermediate, 0], [intermediate, chroma, 0], [0, chroma, intermediate], [0, intermediate, chroma], [intermediate, 0, chroma], [chroma, 0, intermediate]][segment];
40
+ return rgb.map(value => value + offset);
41
+ }
42
+ function readableForeground(background, fallback) {
43
+ if (!background) return fallback;
44
+ const channels = parseColorChannels(background);
45
+ if (!channels) return fallback;
46
+ const linearChannels = channels.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4);
47
+ const luminance = 0.2126 * linearChannels[0] + 0.7152 * linearChannels[1] + 0.0722 * linearChannels[2];
48
+ return luminance > 0.179 ? '#000000' : '#ffffff';
49
+ }
50
+ function withPowerAppsSemanticAliases(theme, brand = {}) {
51
+ return {
52
+ ...theme,
53
+ surface0: brand.bg ?? theme.background,
54
+ surface1: brand.surface ?? theme.color3,
55
+ surface2: theme.color4,
56
+ surface3: brand.border ?? theme.color5,
57
+ mediaSurface: theme.color4,
58
+ accentDeep: brand.primary ?? theme.blue11,
59
+ accentBase: brand.primary ?? theme.blue10,
60
+ accentSoft: brand.accent ?? theme.blue3,
61
+ accentOnAccent: brand.onPrimary ?? readableForeground(brand.primary ?? theme.blue10, theme.color1),
62
+ text0: brand.text ?? theme.color12,
63
+ text1: brand.textMuted ?? theme.color11,
64
+ text2: theme.color10,
65
+ text3: theme.color9,
66
+ statusComplete: brand.statusSuccess ?? theme.green11,
67
+ statusCompleteBg: theme.green3,
68
+ statusPending: brand.statusWarning ?? theme.yellow11,
69
+ statusPendingBg: theme.yellow3,
70
+ statusOverdue: brand.statusDanger ?? theme.red11,
71
+ statusOverdueBg: theme.red3,
72
+ statusInProgress: brand.statusInfo ?? theme.blue11,
73
+ statusInProgressBg: theme.blue3,
74
+ statusDraft: theme.color10,
75
+ statusDraftBg: theme.color3,
76
+ statusCancelled: theme.red11,
77
+ statusCancelledBg: theme.red3
78
+ };
79
+ }
80
+ const powerAppsTamaguiDefaults = {
81
+ ..._v.defaultConfig,
82
+ animations: _v5Rn.animations,
83
+ themes: {
84
+ ..._v.defaultConfig.themes,
85
+ light: withPowerAppsSemanticAliases(_v.defaultConfig.themes.light),
86
+ dark: withPowerAppsSemanticAliases(_v.defaultConfig.themes.dark)
87
+ },
88
+ fonts: {
89
+ ..._v.defaultConfig.fonts,
90
+ mono: _v.defaultConfig.fonts.body
91
+ }
92
+ };
93
+ function createPowerAppsTamaguiConfig(overrides = {}) {
94
+ return (0, _core.createTamagui)({
95
+ ...powerAppsTamaguiDefaults,
96
+ ...overrides
97
+ });
98
+ }