bleam 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.cjs +3984 -25
- package/dist/ai.d.cts +503 -20
- package/dist/ai.d.ts +503 -20
- package/dist/ai.js +3946 -26
- package/dist/animated.cjs +1 -1
- package/dist/animated.js +1 -1
- package/dist/app.cjs +92 -0
- package/dist/app.js +92 -0
- package/dist/cli.cjs +653 -86
- package/dist/cli.d.cts +89 -1
- package/dist/cli.d.ts +89 -1
- package/dist/cli.js +654 -88
- package/dist/{config-ClDGHNb3.d.ts → config-Cms0rvqg.d.ts} +1 -0
- package/dist/{config-D3gPaVMb.d.cts → config-CufOVJV3.d.cts} +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/crypto.d.cts +0 -2
- package/dist/crypto.d.ts +1 -1
- package/dist/dev-protocol.d.cts +14 -1
- package/dist/dev-protocol.d.ts +14 -1
- package/dist/files-Bo7h9fik.cjs +468 -0
- package/dist/files-Ds1wT8C2.js +445 -0
- package/dist/files-DwA7pzr3.d.cts +99 -0
- package/dist/files-VrkQlKIT.d.ts +99 -0
- package/dist/files.cjs +7 -0
- package/dist/files.d.cts +2 -0
- package/dist/files.d.ts +2 -0
- package/dist/files.js +4 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/native-sqlite-xcGdamRD.js +64 -0
- package/dist/native-sqlite-yQLD5s9i.cjs +66 -0
- package/dist/platform.cjs +27 -0
- package/dist/platform.d.cts +39 -0
- package/dist/platform.d.ts +39 -0
- package/dist/platform.js +21 -0
- package/dist/runtime.d.cts +1 -6
- package/dist/runtime.d.ts +1 -6
- package/dist/{schema-ipsECAso.d.ts → schema-DOOjfXvs.d.ts} +1 -1
- package/dist/{schema-BOuUHcqo.d.cts → schema-ENSMX_1t.d.cts} +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.d.cts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/state-Bx0VlTlO.cjs +852 -0
- package/dist/state-CAwe-Vw1.js +767 -0
- package/dist/state.cjs +17 -763
- package/dist/state.d.cts +107 -77
- package/dist/state.d.ts +107 -77
- package/dist/state.js +4 -745
- package/dist/ui-1WepaMS4.d.cts +92 -0
- package/dist/ui-Ce-pnUUA.d.ts +92 -0
- package/dist/ui.cjs +286 -35
- package/dist/ui.d.cts +2 -30
- package/dist/ui.d.ts +2 -30
- package/dist/ui.js +283 -36
- package/dist/window.cjs +596 -0
- package/dist/window.d.cts +63 -0
- package/dist/window.d.ts +63 -0
- package/dist/window.js +589 -0
- package/package.json +16 -14
- package/templates/basic/app/index.tsx +8 -5
- package/templates/foundation-models/app/index.tsx +32 -0
- package/templates/foundation-models/app.config.ts +5 -0
- package/templates/image-generation/app/index.tsx +39 -0
- package/templates/image-generation/app.config.ts +5 -0
- package/templates/state/app/index.tsx +30 -0
- package/templates/state/app.config.ts +5 -0
- package/dist/chrome.cjs +0 -265
- package/dist/chrome.d.cts +0 -19
- package/dist/chrome.d.ts +0 -19
- package/dist/chrome.js +0 -262
- package/dist/fs.cjs +0 -13
- package/dist/fs.d.cts +0 -8
- package/dist/fs.d.ts +0 -8
- package/dist/fs.js +0 -12
- package/dist/native-macos-D6p2SmUj.js +0 -20
- package/dist/native-macos-DLwo_ii9.cjs +0 -31
- package/dist/native-runtime-CbPzrs8j.d.cts +0 -33
- package/dist/native-runtime-DxHSrsTX.d.ts +0 -33
- package/dist/native.cjs +0 -135
- package/dist/native.d.cts +0 -34
- package/dist/native.d.ts +0 -34
- package/dist/native.js +0 -135
- /package/dist/{schema-DVmoD9JL.js → schema-Bo5Jvqus.js} +0 -0
- /package/dist/{schema-bxeeCyLn.cjs → schema-rQ13mrpD.cjs} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bleam",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"packageManager": "yarn@1.22.22",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsdown",
|
|
18
|
+
"test": "vitest run",
|
|
18
19
|
"typecheck": "tsc --noEmit -p tsconfig.build.json"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"@nativescript/react-native": "9.0.0-preview.4",
|
|
31
32
|
"@types/react": "~19.2.17",
|
|
32
33
|
"expo": "57",
|
|
34
|
+
"expo-splash-screen": "57.0.2",
|
|
33
35
|
"react": "19.2.3",
|
|
34
36
|
"react-native": "0.86.0",
|
|
35
37
|
"tsx": "^4.21.0",
|
|
@@ -74,11 +76,6 @@
|
|
|
74
76
|
"import": "./dist/bundler.js",
|
|
75
77
|
"require": "./dist/bundler.cjs"
|
|
76
78
|
},
|
|
77
|
-
"./chrome": {
|
|
78
|
-
"types": "./dist/chrome.d.ts",
|
|
79
|
-
"import": "./dist/chrome.js",
|
|
80
|
-
"require": "./dist/chrome.cjs"
|
|
81
|
-
},
|
|
82
79
|
"./config": {
|
|
83
80
|
"types": "./dist/config.d.ts",
|
|
84
81
|
"import": "./dist/config.js",
|
|
@@ -94,15 +91,15 @@
|
|
|
94
91
|
"import": "./dist/dev-protocol.js",
|
|
95
92
|
"require": "./dist/dev-protocol.cjs"
|
|
96
93
|
},
|
|
97
|
-
"./
|
|
98
|
-
"types": "./dist/
|
|
99
|
-
"import": "./dist/
|
|
100
|
-
"require": "./dist/
|
|
94
|
+
"./files": {
|
|
95
|
+
"types": "./dist/files.d.ts",
|
|
96
|
+
"import": "./dist/files.js",
|
|
97
|
+
"require": "./dist/files.cjs"
|
|
101
98
|
},
|
|
102
|
-
"./
|
|
103
|
-
"types": "./dist/
|
|
104
|
-
"import": "./dist/
|
|
105
|
-
"require": "./dist/
|
|
99
|
+
"./platform": {
|
|
100
|
+
"types": "./dist/platform.d.ts",
|
|
101
|
+
"import": "./dist/platform.js",
|
|
102
|
+
"require": "./dist/platform.cjs"
|
|
106
103
|
},
|
|
107
104
|
"./runtime": {
|
|
108
105
|
"types": "./dist/runtime.d.ts",
|
|
@@ -129,6 +126,11 @@
|
|
|
129
126
|
"import": "./dist/ui.js",
|
|
130
127
|
"require": "./dist/ui.cjs"
|
|
131
128
|
},
|
|
129
|
+
"./window": {
|
|
130
|
+
"types": "./dist/window.d.ts",
|
|
131
|
+
"import": "./dist/window.js",
|
|
132
|
+
"require": "./dist/window.cjs"
|
|
133
|
+
},
|
|
132
134
|
"./package.json": "./package.json",
|
|
133
135
|
"./metro-config": {
|
|
134
136
|
"require": "./metro-config.cjs"
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { atom, useAtom } from 'bleam/state'
|
|
2
2
|
import { sx } from 'bleam/styles'
|
|
3
3
|
import { Button } from 'bleam/ui'
|
|
4
|
-
import {
|
|
4
|
+
import { Toolbar, Window } from 'bleam/window'
|
|
5
5
|
import { Text, View } from 'react-native'
|
|
6
6
|
|
|
7
|
+
const appName = 'Bleam Basic'
|
|
8
|
+
const counter = atom(0)
|
|
9
|
+
|
|
7
10
|
export default function App() {
|
|
8
|
-
const [count, setCount] =
|
|
11
|
+
const [count, setCount] = useAtom(counter)
|
|
9
12
|
|
|
10
13
|
return (
|
|
11
|
-
<View style={sx('flex-1'
|
|
12
|
-
<Window title=
|
|
14
|
+
<View style={sx('flex-1')}>
|
|
15
|
+
<Window title={appName} titleVisibility="visible" />
|
|
13
16
|
<Toolbar toolbarStyle="unified" />
|
|
14
17
|
|
|
15
18
|
<View style={sx('flex-1', 'items-center', 'justify-center', 'p-6')}>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { generate } from 'bleam/ai'
|
|
2
|
+
import { sx } from 'bleam/styles'
|
|
3
|
+
import { Button } from 'bleam/ui'
|
|
4
|
+
import { Window } from 'bleam/window'
|
|
5
|
+
import { useState } from 'react'
|
|
6
|
+
import { Text, View } from 'react-native'
|
|
7
|
+
|
|
8
|
+
const appName = 'Bleam Basic'
|
|
9
|
+
|
|
10
|
+
export default function App() {
|
|
11
|
+
const [answer, setAnswer] = useState('Ask the on-device model for an idea.')
|
|
12
|
+
|
|
13
|
+
async function ask() {
|
|
14
|
+
setAnswer('Thinking...')
|
|
15
|
+
try {
|
|
16
|
+
setAnswer(
|
|
17
|
+
await generate({ prompt: 'Suggest one useful native Mac app.' }),
|
|
18
|
+
)
|
|
19
|
+
} catch (error) {
|
|
20
|
+
setAnswer(error instanceof Error ? error.message : String(error))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<View style={sx('flex-1', 'p-8', 'gap-6')}>
|
|
26
|
+
<Window title={appName} />
|
|
27
|
+
<Text style={sx('text-3xl', 'font-semibold')}>Foundation Models</Text>
|
|
28
|
+
<Text style={sx('text-lg', 'text-secondary-label')}>{answer}</Text>
|
|
29
|
+
<Button title="Generate an idea" onPress={ask} />
|
|
30
|
+
</View>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { generateImage } from 'bleam/ai'
|
|
2
|
+
import { sx } from 'bleam/styles'
|
|
3
|
+
import { Button } from 'bleam/ui'
|
|
4
|
+
import { Window } from 'bleam/window'
|
|
5
|
+
import { useState } from 'react'
|
|
6
|
+
import { Image, Text, View } from 'react-native'
|
|
7
|
+
|
|
8
|
+
const appName = 'Bleam Basic'
|
|
9
|
+
|
|
10
|
+
export default function App() {
|
|
11
|
+
const [uri, setUri] = useState<string>()
|
|
12
|
+
const [status, setStatus] = useState('Generate an image on this Mac.')
|
|
13
|
+
|
|
14
|
+
async function create() {
|
|
15
|
+
setStatus('Generating...')
|
|
16
|
+
try {
|
|
17
|
+
const result = await generateImage({
|
|
18
|
+
prompt: 'A precise editorial illustration of a small native Mac app',
|
|
19
|
+
aspectRatio: 'square',
|
|
20
|
+
})
|
|
21
|
+
setUri(result.uri)
|
|
22
|
+
setStatus(`Completed with seed ${result.metadata.seed}`)
|
|
23
|
+
} catch (error) {
|
|
24
|
+
setStatus(error instanceof Error ? error.message : String(error))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<View style={sx('flex-1', 'p-8', 'gap-6')}>
|
|
30
|
+
<Window title={appName} />
|
|
31
|
+
<Text style={sx('text-3xl', 'font-semibold')}>Image Generation</Text>
|
|
32
|
+
{uri ? (
|
|
33
|
+
<Image source={{ uri }} style={sx('w-96', 'h-96', 'rounded-xl')} />
|
|
34
|
+
) : null}
|
|
35
|
+
<Text style={sx('text-secondary-label')}>{status}</Text>
|
|
36
|
+
<Button title="Generate image" onPress={create} />
|
|
37
|
+
</View>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { atom, useAtom } from 'bleam/state'
|
|
2
|
+
import { sx } from 'bleam/styles'
|
|
3
|
+
import { Button } from 'bleam/ui'
|
|
4
|
+
import { Window } from 'bleam/window'
|
|
5
|
+
import { Text, View } from 'react-native'
|
|
6
|
+
|
|
7
|
+
const appName = 'Bleam Basic'
|
|
8
|
+
const tasks = atom<string[]>(['Create a native Mac app'])
|
|
9
|
+
|
|
10
|
+
export default function App() {
|
|
11
|
+
const [items, setItems] = useAtom(tasks)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<View style={sx('flex-1', 'p-8', 'gap-4')}>
|
|
15
|
+
<Window title={appName} />
|
|
16
|
+
<Text style={sx('text-3xl', 'font-semibold')}>Tasks</Text>
|
|
17
|
+
{items.map((item) => (
|
|
18
|
+
<Text key={item} style={sx('text-lg')}>
|
|
19
|
+
{item}
|
|
20
|
+
</Text>
|
|
21
|
+
))}
|
|
22
|
+
<Button
|
|
23
|
+
title="Add task"
|
|
24
|
+
onPress={() =>
|
|
25
|
+
setItems((current) => [...current, `Task ${current.length + 1}`])
|
|
26
|
+
}
|
|
27
|
+
/>
|
|
28
|
+
</View>
|
|
29
|
+
)
|
|
30
|
+
}
|
package/dist/chrome.cjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
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;
|
package/dist/chrome.d.cts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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 };
|