bleam 0.0.5 → 0.0.6

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 (113) hide show
  1. package/dist/ai.cjs +187 -0
  2. package/dist/ai.d.cts +52 -0
  3. package/dist/ai.d.ts +52 -0
  4. package/dist/ai.js +182 -0
  5. package/dist/animated.cjs +286 -0
  6. package/dist/animated.d.cts +47 -0
  7. package/dist/animated.d.ts +47 -0
  8. package/dist/animated.js +281 -0
  9. package/dist/app.d.cts +1 -2
  10. package/dist/app.d.ts +1 -2
  11. package/dist/app.js +1 -2
  12. package/dist/bundler.d.cts +1 -2
  13. package/dist/bundler.d.ts +1 -2
  14. package/dist/chrome.cjs +265 -0
  15. package/dist/chrome.d.cts +19 -0
  16. package/dist/chrome.d.ts +19 -0
  17. package/dist/chrome.js +262 -0
  18. package/dist/cli.cjs +768 -31
  19. package/dist/cli.js +767 -34
  20. package/dist/config-Bb6SULnR.cjs +46 -0
  21. package/dist/config-CfWa3q-k.js +28 -0
  22. package/dist/config-ClDGHNb3.d.ts +39 -0
  23. package/dist/config-D3gPaVMb.d.cts +39 -0
  24. package/dist/config.cjs +4 -25
  25. package/dist/config.d.cts +2 -28
  26. package/dist/config.d.ts +2 -28
  27. package/dist/config.js +2 -24
  28. package/dist/crypto-BB92-Upx.js +7 -0
  29. package/dist/crypto-CT3VZ7lF.cjs +13 -0
  30. package/dist/crypto.cjs +2 -2
  31. package/dist/crypto.d.cts +8 -1
  32. package/dist/crypto.d.ts +8 -1
  33. package/dist/crypto.js +2 -2
  34. package/dist/dev-protocol.d.cts +3 -3
  35. package/dist/dev-protocol.d.ts +3 -3
  36. package/dist/dev-protocol.js +1 -2
  37. package/dist/fs.cjs +12 -2
  38. package/dist/fs.d.cts +7 -1
  39. package/dist/fs.d.ts +7 -1
  40. package/dist/fs.js +10 -1
  41. package/dist/index.cjs +4 -5
  42. package/dist/index.d.cts +2 -3
  43. package/dist/index.d.ts +2 -3
  44. package/dist/index.js +2 -4
  45. package/dist/native-macos-D6p2SmUj.js +20 -0
  46. package/dist/native-macos-DLwo_ii9.cjs +31 -0
  47. package/dist/native-runtime-C85Nuc4F.js +10 -0
  48. package/dist/native-runtime-CbPzrs8j.d.cts +33 -0
  49. package/dist/{native-runtime-CdeT0JyQ.cjs → native-runtime-CsXnXkQn.cjs} +1 -14
  50. package/dist/native-runtime-DxHSrsTX.d.ts +33 -0
  51. package/dist/native.cjs +35 -32
  52. package/dist/native.d.cts +4 -34
  53. package/dist/native.d.ts +3 -33
  54. package/dist/native.js +36 -34
  55. package/dist/runtime.d.cts +1 -2
  56. package/dist/runtime.d.ts +1 -2
  57. package/dist/schema-BOuUHcqo.d.cts +58 -0
  58. package/dist/schema-DVmoD9JL.js +90 -0
  59. package/dist/schema-bxeeCyLn.cjs +102 -0
  60. package/dist/schema-ipsECAso.d.ts +58 -0
  61. package/dist/schema.cjs +4 -0
  62. package/dist/schema.d.cts +2 -0
  63. package/dist/schema.d.ts +2 -0
  64. package/dist/schema.js +3 -0
  65. package/dist/state.cjs +765 -0
  66. package/dist/state.d.cts +129 -0
  67. package/dist/state.d.ts +129 -0
  68. package/dist/state.js +747 -0
  69. package/dist/styles.cjs +742 -0
  70. package/dist/styles.d.cts +701 -0
  71. package/dist/styles.d.ts +701 -0
  72. package/dist/styles.js +739 -0
  73. package/dist/ui.cjs +113 -0
  74. package/dist/ui.d.cts +30 -0
  75. package/dist/ui.d.ts +30 -0
  76. package/dist/ui.js +110 -0
  77. package/metro-config.cjs +18 -13
  78. package/package.json +47 -13
  79. package/templates/basic/app/index.tsx +130 -12
  80. package/templates/basic/app.config.ts +4 -2
  81. package/dist/app.d.cts.map +0 -1
  82. package/dist/app.d.ts.map +0 -1
  83. package/dist/app.js.map +0 -1
  84. package/dist/bundler.d.cts.map +0 -1
  85. package/dist/bundler.d.ts.map +0 -1
  86. package/dist/cli.js.map +0 -1
  87. package/dist/config.d.cts.map +0 -1
  88. package/dist/config.d.ts.map +0 -1
  89. package/dist/config.js.map +0 -1
  90. package/dist/crypto-BNhWeXMj.cjs +0 -15
  91. package/dist/crypto-Bg8cD8wX.d.cts +0 -8
  92. package/dist/crypto-Bg8cD8wX.d.cts.map +0 -1
  93. package/dist/crypto-CCA_hvao.js +0 -11
  94. package/dist/crypto-CCA_hvao.js.map +0 -1
  95. package/dist/crypto-IOzbNoJD.d.ts +0 -8
  96. package/dist/crypto-IOzbNoJD.d.ts.map +0 -1
  97. package/dist/dev-protocol.d.cts.map +0 -1
  98. package/dist/dev-protocol.d.ts.map +0 -1
  99. package/dist/dev-protocol.js.map +0 -1
  100. package/dist/fs-BK7joD1g.js +0 -13
  101. package/dist/fs-BK7joD1g.js.map +0 -1
  102. package/dist/fs-CEhcjuN6.d.ts +0 -9
  103. package/dist/fs-CEhcjuN6.d.ts.map +0 -1
  104. package/dist/fs-CfE8CHf_.d.cts +0 -9
  105. package/dist/fs-CfE8CHf_.d.cts.map +0 -1
  106. package/dist/fs-DKHYTPua.cjs +0 -18
  107. package/dist/native-runtime-BoqybBBf.js +0 -18
  108. package/dist/native-runtime-BoqybBBf.js.map +0 -1
  109. package/dist/native.d.cts.map +0 -1
  110. package/dist/native.d.ts.map +0 -1
  111. package/dist/native.js.map +0 -1
  112. package/dist/runtime.d.cts.map +0 -1
  113. package/dist/runtime.d.ts.map +0 -1
@@ -0,0 +1,265 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_native_runtime = require('./native-runtime-CsXnXkQn.cjs');
3
+ const require_native_macos = require('./native-macos-DLwo_ii9.cjs');
4
+ let react = require("react");
5
+ react = require_chunk.__toESM(react);
6
+
7
+ //#region src/chrome.tsx
8
+ const toolbarStyleValues = {
9
+ automatic: 0,
10
+ expanded: 1,
11
+ preference: 2,
12
+ unified: 3,
13
+ unifiedCompact: 4
14
+ };
15
+ const titleVisibilityValues = {
16
+ visible: 0,
17
+ hidden: 1
18
+ };
19
+ const userInterfaceStyleValues = {
20
+ automatic: 0,
21
+ light: 1,
22
+ dark: 2
23
+ };
24
+ function nativeRecord(value) {
25
+ if (!value || typeof value !== "object") return;
26
+ return value;
27
+ }
28
+ function macOSScene(value) {
29
+ return nativeRecord(value);
30
+ }
31
+ function macOSWindow(value) {
32
+ return nativeRecord(value);
33
+ }
34
+ function selectorTarget(value) {
35
+ return nativeRecord(value);
36
+ }
37
+ function setNativeValue(value, key, nextValue) {
38
+ const record = nativeRecord(value);
39
+ if (!record) return false;
40
+ record[key] = nextValue;
41
+ return true;
42
+ }
43
+ function colorFromHex(hex) {
44
+ const value = hex.trim().replace(/^#/, "");
45
+ const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
46
+ if (!/^[\da-f]{6}$/i.test(normalized)) throw new Error(`Invalid color: ${hex}`);
47
+ const number = Number.parseInt(normalized, 16);
48
+ const red = (number >> 16 & 255) / 255;
49
+ const green = (number >> 8 & 255) / 255;
50
+ const blue = (number & 255) / 255;
51
+ return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, 1);
52
+ }
53
+ function forEachNativeObject(collection, callback) {
54
+ const values = collection?.allObjects ?? collection;
55
+ if (Array.isArray(values)) {
56
+ values.forEach(callback);
57
+ return;
58
+ }
59
+ const iterableValues = values;
60
+ const count = Number(iterableValues?.count ?? 0);
61
+ for (let index = 0; index < count; index += 1) callback(iterableValues?.objectAtIndex?.(index));
62
+ }
63
+ function runOnUIWithRetry(apply) {
64
+ const run = () => require_native_runtime.ensureNativeScript().runOnUI(apply).catch(() => {});
65
+ run();
66
+ const timeout = setTimeout(() => {
67
+ run();
68
+ }, 250);
69
+ return () => {
70
+ clearTimeout(timeout);
71
+ };
72
+ }
73
+ function applyWindowTitle(title) {
74
+ const application = UIApplication.sharedApplication;
75
+ forEachNativeObject(application?.connectedScenes, (scene) => {
76
+ setNativeValue(scene, "title", title);
77
+ });
78
+ const appKitApplication = require_native_macos.macOSApplication();
79
+ const appKitWindow = appKitApplication?.keyWindow ?? appKitApplication?.mainWindow;
80
+ if (appKitWindow) setNativeValue(appKitWindow, "title", title);
81
+ }
82
+ function clearRootView(window) {
83
+ const rootView = (macOSWindow(window)?.rootViewController)?.view;
84
+ if (!rootView) return;
85
+ setNativeValue(rootView, "backgroundColor", UIColor.clearColor);
86
+ setNativeValue(rootView, "opaque", false);
87
+ }
88
+ function forEachApplicationWindow(callback) {
89
+ const application = UIApplication.sharedApplication;
90
+ callback(application.keyWindow);
91
+ forEachNativeObject(application?.windows, callback);
92
+ forEachNativeObject(application?.connectedScenes, (scene) => {
93
+ callback(macOSScene(scene)?.keyWindow);
94
+ forEachNativeObject(macOSScene(scene)?.windows, callback);
95
+ });
96
+ }
97
+ function applyWindowTint(tint) {
98
+ const tintColor = colorFromHex(tint);
99
+ function applyTint(window) {
100
+ if (!window) return;
101
+ setNativeValue(window, "tintColor", tintColor);
102
+ clearRootView(window);
103
+ const rootView = (macOSWindow(window)?.rootViewController)?.view;
104
+ if (rootView) setNativeValue(rootView, "tintColor", tintColor);
105
+ }
106
+ forEachApplicationWindow(applyTint);
107
+ }
108
+ function applyWindowBackgroundColor(backgroundColor) {
109
+ const color = colorFromHex(backgroundColor);
110
+ forEachApplicationWindow((window) => {
111
+ if (!window) return;
112
+ setNativeValue(window, "backgroundColor", color);
113
+ clearRootView(window);
114
+ });
115
+ }
116
+ function applyWindowUserInterfaceStyle(userInterfaceStyle) {
117
+ const value = userInterfaceStyleValues[userInterfaceStyle];
118
+ forEachApplicationWindow((window) => {
119
+ if (!window) return;
120
+ setNativeValue(window, "overrideUserInterfaceStyle", value);
121
+ const rootViewController = macOSWindow(window)?.rootViewController;
122
+ if (rootViewController) setNativeValue(rootViewController, "overrideUserInterfaceStyle", value);
123
+ });
124
+ }
125
+ function applyWindowRootTransparency() {
126
+ forEachApplicationWindow((window) => {
127
+ if (window) clearRootView(window);
128
+ });
129
+ }
130
+ function invokeNativeValue(target, selector, ...values) {
131
+ const invoke = selectorTarget(target)?.invoke;
132
+ if (typeof invoke !== "function") return;
133
+ return invoke.call(target, selector, ...values);
134
+ }
135
+ function titlebarForScene(scene) {
136
+ try {
137
+ const titlebar = invokeNativeValue(scene, "titlebar");
138
+ if (titlebar) return titlebar;
139
+ } catch {}
140
+ try {
141
+ const target = selectorTarget(scene);
142
+ if (target?.valueForKey) {
143
+ const titlebar = target.valueForKey("titlebar");
144
+ if (titlebar) return titlebar;
145
+ }
146
+ } catch {}
147
+ return macOSScene(scene)?.titlebar;
148
+ }
149
+ function setNativeNumber(target, key, value) {
150
+ const selector = `set${key[0]?.toUpperCase()}${key.slice(1)}:`;
151
+ try {
152
+ if (invokeNativeValue(target, selector, value) !== void 0) return;
153
+ } catch {}
154
+ try {
155
+ if (setNativeValue(target, key, value)) return;
156
+ } catch {}
157
+ try {
158
+ const selector$1 = selectorTarget(target);
159
+ if (selector$1?.setValueForKey) {
160
+ selector$1.setValueForKey(NSNumber.numberWithInteger(value), key);
161
+ return;
162
+ }
163
+ } catch {}
164
+ }
165
+ function applyTitleVisibility(titleVisibility) {
166
+ if (!require_native_macos.macOSApplication()) return;
167
+ const value = titleVisibilityValues[titleVisibility];
168
+ const application = UIApplication.sharedApplication;
169
+ forEachNativeObject(application?.connectedScenes, (scene) => {
170
+ const titlebar = titlebarForScene(scene);
171
+ if (!titlebar) return;
172
+ setNativeNumber(titlebar, "titleVisibility", value);
173
+ });
174
+ }
175
+ function toolbarForTitlebar(titlebar) {
176
+ let toolbar;
177
+ try {
178
+ toolbar = invokeNativeValue(titlebar, "toolbar");
179
+ } catch {}
180
+ try {
181
+ toolbar ??= titlebar.toolbar;
182
+ } catch {}
183
+ try {
184
+ if (!toolbar && titlebar.valueForKey) toolbar = titlebar.valueForKey("toolbar");
185
+ } catch {}
186
+ if (toolbar) return toolbar;
187
+ toolbar = require_native_macos.createMacOSToolbar("BleamToolbar");
188
+ if (!toolbar) return;
189
+ try {
190
+ if (invokeNativeValue(titlebar, "setToolbar:", toolbar) !== void 0) return toolbar;
191
+ } catch {}
192
+ try {
193
+ if (setNativeValue(titlebar, "toolbar", toolbar)) return toolbar;
194
+ } catch {}
195
+ try {
196
+ if (titlebar.setValueForKey) {
197
+ titlebar.setValueForKey(toolbar, "toolbar");
198
+ return toolbar;
199
+ }
200
+ } catch {}
201
+ }
202
+ function applyToolbarStyle(toolbarStyle) {
203
+ if (!require_native_macos.macOSApplication()) return;
204
+ const value = toolbarStyleValues[toolbarStyle];
205
+ const application = UIApplication.sharedApplication;
206
+ forEachNativeObject(application?.connectedScenes, (scene) => {
207
+ const titlebar = titlebarForScene(scene);
208
+ if (!titlebar) return;
209
+ toolbarForTitlebar(titlebar);
210
+ setNativeNumber(titlebar, "toolbarStyle", value);
211
+ });
212
+ }
213
+ function Window(props) {
214
+ const { title, tint, backgroundColor, userInterfaceStyle, titleVisibility } = props;
215
+ (0, react.useLayoutEffect)(() => {
216
+ return runOnUIWithRetry(() => {
217
+ applyWindowRootTransparency();
218
+ });
219
+ }, []);
220
+ (0, react.useEffect)(() => {
221
+ if (title === void 0) return;
222
+ require_native_runtime.ensureNativeScript().runOnUI(() => {
223
+ applyWindowTitle(title);
224
+ }).catch(() => {});
225
+ }, [title]);
226
+ (0, react.useLayoutEffect)(() => {
227
+ if (tint === void 0) return;
228
+ return runOnUIWithRetry(() => {
229
+ applyWindowTint(tint);
230
+ });
231
+ }, [tint]);
232
+ (0, react.useLayoutEffect)(() => {
233
+ if (backgroundColor === void 0) return;
234
+ return runOnUIWithRetry(() => {
235
+ applyWindowBackgroundColor(backgroundColor);
236
+ });
237
+ }, [backgroundColor]);
238
+ (0, react.useLayoutEffect)(() => {
239
+ if (userInterfaceStyle === void 0) return;
240
+ return runOnUIWithRetry(() => {
241
+ applyWindowUserInterfaceStyle(userInterfaceStyle);
242
+ });
243
+ }, [userInterfaceStyle]);
244
+ (0, react.useEffect)(() => {
245
+ if (titleVisibility === void 0) return;
246
+ require_native_runtime.ensureNativeScript().runOnUI(() => {
247
+ applyTitleVisibility(titleVisibility);
248
+ }).catch(() => {});
249
+ }, [titleVisibility]);
250
+ return null;
251
+ }
252
+ function Toolbar(props) {
253
+ const { toolbarStyle } = props;
254
+ (0, react.useEffect)(() => {
255
+ if (toolbarStyle === void 0) return;
256
+ require_native_runtime.ensureNativeScript().runOnUI(() => {
257
+ applyToolbarStyle(toolbarStyle);
258
+ }).catch(() => {});
259
+ }, [toolbarStyle]);
260
+ return null;
261
+ }
262
+
263
+ //#endregion
264
+ exports.Toolbar = Toolbar;
265
+ exports.Window = Window;
@@ -0,0 +1,19 @@
1
+ //#region src/chrome.d.ts
2
+ type HexColor = `#${string}`;
3
+ type WindowToolbarStyle = 'automatic' | 'unified' | 'unifiedCompact' | 'preference' | 'expanded';
4
+ type WindowTitleVisibility = 'visible' | 'hidden';
5
+ type WindowUserInterfaceStyle = 'automatic' | 'light' | 'dark';
6
+ type WindowProps = {
7
+ title?: string;
8
+ tint?: HexColor;
9
+ backgroundColor?: HexColor;
10
+ userInterfaceStyle?: WindowUserInterfaceStyle;
11
+ titleVisibility?: WindowTitleVisibility;
12
+ };
13
+ type ToolbarProps = {
14
+ toolbarStyle?: WindowToolbarStyle;
15
+ };
16
+ declare function Window(props: WindowProps): null;
17
+ declare function Toolbar(props: ToolbarProps): null;
18
+ //#endregion
19
+ export { HexColor, Toolbar, ToolbarProps, Window, WindowProps, WindowTitleVisibility, WindowToolbarStyle, WindowUserInterfaceStyle };
@@ -0,0 +1,19 @@
1
+ //#region src/chrome.d.ts
2
+ type HexColor = `#${string}`;
3
+ type WindowToolbarStyle = 'automatic' | 'unified' | 'unifiedCompact' | 'preference' | 'expanded';
4
+ type WindowTitleVisibility = 'visible' | 'hidden';
5
+ type WindowUserInterfaceStyle = 'automatic' | 'light' | 'dark';
6
+ type WindowProps = {
7
+ title?: string;
8
+ tint?: HexColor;
9
+ backgroundColor?: HexColor;
10
+ userInterfaceStyle?: WindowUserInterfaceStyle;
11
+ titleVisibility?: WindowTitleVisibility;
12
+ };
13
+ type ToolbarProps = {
14
+ toolbarStyle?: WindowToolbarStyle;
15
+ };
16
+ declare function Window(props: WindowProps): null;
17
+ declare function Toolbar(props: ToolbarProps): null;
18
+ //#endregion
19
+ export { HexColor, Toolbar, ToolbarProps, Window, WindowProps, WindowTitleVisibility, WindowToolbarStyle, WindowUserInterfaceStyle };
package/dist/chrome.js ADDED
@@ -0,0 +1,262 @@
1
+ import { t as ensureNativeScript } from "./native-runtime-C85Nuc4F.js";
2
+ import { n as macOSApplication, t as createMacOSToolbar } from "./native-macos-D6p2SmUj.js";
3
+ import { useEffect, useLayoutEffect } from "react";
4
+
5
+ //#region src/chrome.tsx
6
+ const toolbarStyleValues = {
7
+ automatic: 0,
8
+ expanded: 1,
9
+ preference: 2,
10
+ unified: 3,
11
+ unifiedCompact: 4
12
+ };
13
+ const titleVisibilityValues = {
14
+ visible: 0,
15
+ hidden: 1
16
+ };
17
+ const userInterfaceStyleValues = {
18
+ automatic: 0,
19
+ light: 1,
20
+ dark: 2
21
+ };
22
+ function nativeRecord(value) {
23
+ if (!value || typeof value !== "object") return;
24
+ return value;
25
+ }
26
+ function macOSScene(value) {
27
+ return nativeRecord(value);
28
+ }
29
+ function macOSWindow(value) {
30
+ return nativeRecord(value);
31
+ }
32
+ function selectorTarget(value) {
33
+ return nativeRecord(value);
34
+ }
35
+ function setNativeValue(value, key, nextValue) {
36
+ const record = nativeRecord(value);
37
+ if (!record) return false;
38
+ record[key] = nextValue;
39
+ return true;
40
+ }
41
+ function colorFromHex(hex) {
42
+ const value = hex.trim().replace(/^#/, "");
43
+ const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
44
+ if (!/^[\da-f]{6}$/i.test(normalized)) throw new Error(`Invalid color: ${hex}`);
45
+ const number = Number.parseInt(normalized, 16);
46
+ const red = (number >> 16 & 255) / 255;
47
+ const green = (number >> 8 & 255) / 255;
48
+ const blue = (number & 255) / 255;
49
+ return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, 1);
50
+ }
51
+ function forEachNativeObject(collection, callback) {
52
+ const values = collection?.allObjects ?? collection;
53
+ if (Array.isArray(values)) {
54
+ values.forEach(callback);
55
+ return;
56
+ }
57
+ const iterableValues = values;
58
+ const count = Number(iterableValues?.count ?? 0);
59
+ for (let index = 0; index < count; index += 1) callback(iterableValues?.objectAtIndex?.(index));
60
+ }
61
+ function runOnUIWithRetry(apply) {
62
+ const run = () => ensureNativeScript().runOnUI(apply).catch(() => {});
63
+ run();
64
+ const timeout = setTimeout(() => {
65
+ run();
66
+ }, 250);
67
+ return () => {
68
+ clearTimeout(timeout);
69
+ };
70
+ }
71
+ function applyWindowTitle(title) {
72
+ const application = UIApplication.sharedApplication;
73
+ forEachNativeObject(application?.connectedScenes, (scene) => {
74
+ setNativeValue(scene, "title", title);
75
+ });
76
+ const appKitApplication = macOSApplication();
77
+ const appKitWindow = appKitApplication?.keyWindow ?? appKitApplication?.mainWindow;
78
+ if (appKitWindow) setNativeValue(appKitWindow, "title", title);
79
+ }
80
+ function clearRootView(window) {
81
+ const rootView = (macOSWindow(window)?.rootViewController)?.view;
82
+ if (!rootView) return;
83
+ setNativeValue(rootView, "backgroundColor", UIColor.clearColor);
84
+ setNativeValue(rootView, "opaque", false);
85
+ }
86
+ function forEachApplicationWindow(callback) {
87
+ const application = UIApplication.sharedApplication;
88
+ callback(application.keyWindow);
89
+ forEachNativeObject(application?.windows, callback);
90
+ forEachNativeObject(application?.connectedScenes, (scene) => {
91
+ callback(macOSScene(scene)?.keyWindow);
92
+ forEachNativeObject(macOSScene(scene)?.windows, callback);
93
+ });
94
+ }
95
+ function applyWindowTint(tint) {
96
+ const tintColor = colorFromHex(tint);
97
+ function applyTint(window) {
98
+ if (!window) return;
99
+ setNativeValue(window, "tintColor", tintColor);
100
+ clearRootView(window);
101
+ const rootView = (macOSWindow(window)?.rootViewController)?.view;
102
+ if (rootView) setNativeValue(rootView, "tintColor", tintColor);
103
+ }
104
+ forEachApplicationWindow(applyTint);
105
+ }
106
+ function applyWindowBackgroundColor(backgroundColor) {
107
+ const color = colorFromHex(backgroundColor);
108
+ forEachApplicationWindow((window) => {
109
+ if (!window) return;
110
+ setNativeValue(window, "backgroundColor", color);
111
+ clearRootView(window);
112
+ });
113
+ }
114
+ function applyWindowUserInterfaceStyle(userInterfaceStyle) {
115
+ const value = userInterfaceStyleValues[userInterfaceStyle];
116
+ forEachApplicationWindow((window) => {
117
+ if (!window) return;
118
+ setNativeValue(window, "overrideUserInterfaceStyle", value);
119
+ const rootViewController = macOSWindow(window)?.rootViewController;
120
+ if (rootViewController) setNativeValue(rootViewController, "overrideUserInterfaceStyle", value);
121
+ });
122
+ }
123
+ function applyWindowRootTransparency() {
124
+ forEachApplicationWindow((window) => {
125
+ if (window) clearRootView(window);
126
+ });
127
+ }
128
+ function invokeNativeValue(target, selector, ...values) {
129
+ const invoke = selectorTarget(target)?.invoke;
130
+ if (typeof invoke !== "function") return;
131
+ return invoke.call(target, selector, ...values);
132
+ }
133
+ function titlebarForScene(scene) {
134
+ try {
135
+ const titlebar = invokeNativeValue(scene, "titlebar");
136
+ if (titlebar) return titlebar;
137
+ } catch {}
138
+ try {
139
+ const target = selectorTarget(scene);
140
+ if (target?.valueForKey) {
141
+ const titlebar = target.valueForKey("titlebar");
142
+ if (titlebar) return titlebar;
143
+ }
144
+ } catch {}
145
+ return macOSScene(scene)?.titlebar;
146
+ }
147
+ function setNativeNumber(target, key, value) {
148
+ const selector = `set${key[0]?.toUpperCase()}${key.slice(1)}:`;
149
+ try {
150
+ if (invokeNativeValue(target, selector, value) !== void 0) return;
151
+ } catch {}
152
+ try {
153
+ if (setNativeValue(target, key, value)) return;
154
+ } catch {}
155
+ try {
156
+ const selector$1 = selectorTarget(target);
157
+ if (selector$1?.setValueForKey) {
158
+ selector$1.setValueForKey(NSNumber.numberWithInteger(value), key);
159
+ return;
160
+ }
161
+ } catch {}
162
+ }
163
+ function applyTitleVisibility(titleVisibility) {
164
+ if (!macOSApplication()) return;
165
+ const value = titleVisibilityValues[titleVisibility];
166
+ const application = UIApplication.sharedApplication;
167
+ forEachNativeObject(application?.connectedScenes, (scene) => {
168
+ const titlebar = titlebarForScene(scene);
169
+ if (!titlebar) return;
170
+ setNativeNumber(titlebar, "titleVisibility", value);
171
+ });
172
+ }
173
+ function toolbarForTitlebar(titlebar) {
174
+ let toolbar;
175
+ try {
176
+ toolbar = invokeNativeValue(titlebar, "toolbar");
177
+ } catch {}
178
+ try {
179
+ toolbar ??= titlebar.toolbar;
180
+ } catch {}
181
+ try {
182
+ if (!toolbar && titlebar.valueForKey) toolbar = titlebar.valueForKey("toolbar");
183
+ } catch {}
184
+ if (toolbar) return toolbar;
185
+ toolbar = createMacOSToolbar("BleamToolbar");
186
+ if (!toolbar) return;
187
+ try {
188
+ if (invokeNativeValue(titlebar, "setToolbar:", toolbar) !== void 0) return toolbar;
189
+ } catch {}
190
+ try {
191
+ if (setNativeValue(titlebar, "toolbar", toolbar)) return toolbar;
192
+ } catch {}
193
+ try {
194
+ if (titlebar.setValueForKey) {
195
+ titlebar.setValueForKey(toolbar, "toolbar");
196
+ return toolbar;
197
+ }
198
+ } catch {}
199
+ }
200
+ function applyToolbarStyle(toolbarStyle) {
201
+ if (!macOSApplication()) return;
202
+ const value = toolbarStyleValues[toolbarStyle];
203
+ const application = UIApplication.sharedApplication;
204
+ forEachNativeObject(application?.connectedScenes, (scene) => {
205
+ const titlebar = titlebarForScene(scene);
206
+ if (!titlebar) return;
207
+ toolbarForTitlebar(titlebar);
208
+ setNativeNumber(titlebar, "toolbarStyle", value);
209
+ });
210
+ }
211
+ function Window(props) {
212
+ const { title, tint, backgroundColor, userInterfaceStyle, titleVisibility } = props;
213
+ useLayoutEffect(() => {
214
+ return runOnUIWithRetry(() => {
215
+ applyWindowRootTransparency();
216
+ });
217
+ }, []);
218
+ useEffect(() => {
219
+ if (title === void 0) return;
220
+ ensureNativeScript().runOnUI(() => {
221
+ applyWindowTitle(title);
222
+ }).catch(() => {});
223
+ }, [title]);
224
+ useLayoutEffect(() => {
225
+ if (tint === void 0) return;
226
+ return runOnUIWithRetry(() => {
227
+ applyWindowTint(tint);
228
+ });
229
+ }, [tint]);
230
+ useLayoutEffect(() => {
231
+ if (backgroundColor === void 0) return;
232
+ return runOnUIWithRetry(() => {
233
+ applyWindowBackgroundColor(backgroundColor);
234
+ });
235
+ }, [backgroundColor]);
236
+ useLayoutEffect(() => {
237
+ if (userInterfaceStyle === void 0) return;
238
+ return runOnUIWithRetry(() => {
239
+ applyWindowUserInterfaceStyle(userInterfaceStyle);
240
+ });
241
+ }, [userInterfaceStyle]);
242
+ useEffect(() => {
243
+ if (titleVisibility === void 0) return;
244
+ ensureNativeScript().runOnUI(() => {
245
+ applyTitleVisibility(titleVisibility);
246
+ }).catch(() => {});
247
+ }, [titleVisibility]);
248
+ return null;
249
+ }
250
+ function Toolbar(props) {
251
+ const { toolbarStyle } = props;
252
+ useEffect(() => {
253
+ if (toolbarStyle === void 0) return;
254
+ ensureNativeScript().runOnUI(() => {
255
+ applyToolbarStyle(toolbarStyle);
256
+ }).catch(() => {});
257
+ }, [toolbarStyle]);
258
+ return null;
259
+ }
260
+
261
+ //#endregion
262
+ export { Toolbar, Window };