bleam 0.0.12 → 0.0.13
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 +5 -4
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +4 -3
- package/dist/app-storage-D8W4n8ey.cjs +39 -0
- package/dist/app-storage-Isi5Bo0R.js +34 -0
- package/dist/cli.cjs +148 -22
- package/dist/cli.d.cts +13 -0
- package/dist/cli.d.ts +14 -1
- package/dist/cli.js +148 -22
- package/dist/config.d.ts +1 -1
- package/dist/elements-CFk0QHw0.d.cts +127 -0
- package/dist/elements-ClGQ41Sc.d.ts +127 -0
- package/dist/{ui.cjs → elements.cjs} +307 -168
- package/dist/elements.d.cts +2 -0
- package/dist/elements.d.ts +2 -0
- package/dist/{ui.js → elements.js} +306 -169
- package/dist/{files-BXVkPrPN.js → files-DErLhzCB.js} +5 -11
- package/dist/{files-DxaQ-Nv0.cjs → files-lMk-CpL_.cjs} +5 -11
- package/dist/files.cjs +1 -1
- package/dist/files.d.ts +1 -1
- package/dist/files.js +1 -1
- package/dist/index.d.ts +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/secrets.cjs +146 -0
- package/dist/secrets.d.cts +14 -0
- package/dist/secrets.d.ts +14 -0
- package/dist/secrets.js +142 -0
- package/dist/{state-LssDgpff.cjs → state-BZYyrE2-.cjs} +4 -41
- package/dist/{state-Dh3HLixb.js → state-DkaRFkZJ.js} +4 -35
- package/dist/state.cjs +3 -2
- package/dist/state.d.cts +1 -1
- package/dist/state.d.ts +1 -1
- package/dist/state.js +3 -2
- package/dist/window.d.cts +1 -1
- package/dist/window.d.ts +3 -3
- package/package.json +11 -6
- package/templates/basic/app/index.tsx +2 -2
- package/templates/foundation-models/app/index.tsx +4 -4
- package/templates/image-generation/app/index.tsx +2 -2
- package/templates/native/modules/bleam-runtime/ios/AIModule.swift +7 -8
- package/templates/state/app/index.tsx +2 -2
- package/templates/text-generation/app/index.tsx +4 -4
- package/templates/updates/README.md +1 -1
- package/dist/ui-1WepaMS4.d.cts +0 -92
- package/dist/ui-D7bRLYee.d.ts +0 -92
- package/dist/ui.d.cts +0 -2
- package/dist/ui.d.ts +0 -2
- /package/dist/{config-Chi-flpJ.d.ts → config-Cms0rvqg.d.ts} +0 -0
- /package/dist/{files-VrkQlKIT.d.ts → files-4ZEoAWiv.d.ts} +0 -0
- /package/dist/{native-sqlite-yQLD5s9i.cjs → native-sqlite-Dw--FI9a.cjs} +0 -0
- /package/dist/{native-sqlite-xcGdamRD.js → native-sqlite-WzRNzCSh.js} +0 -0
- /package/dist/{schema-B5BfdswF.js → schema-B7ELMpuI.js} +0 -0
- /package/dist/{schema-BnVZOXfu.cjs → schema-B7SLUBLN.cjs} +0 -0
- /package/dist/{schema-D5eImHxu.d.cts → schema-BWsDPc6c.d.cts} +0 -0
- /package/dist/{schema-SSjokbtw.d.ts → schema-LxnzAfgw.d.ts} +0 -0
package/dist/secrets.cjs
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const require_native_runtime = require('./native-runtime-CsXnXkQn.cjs');
|
|
2
|
+
const require_app_storage = require('./app-storage-D8W4n8ey.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/native-secrets.ts
|
|
5
|
+
var NativeSecretsError = class extends Error {
|
|
6
|
+
constructor(status, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.name = "NativeSecretsError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
let securityLoaded = false;
|
|
13
|
+
function ensureSecurity() {
|
|
14
|
+
if (securityLoaded) return;
|
|
15
|
+
const nativeScript = require_native_runtime.ensureNativeScript();
|
|
16
|
+
if (!nativeScript.isFrameworkLoaded("Security") && !nativeScript.loadFramework("Security")) throw new NativeSecretsError(void 0, "Keychain is unavailable");
|
|
17
|
+
securityLoaded = true;
|
|
18
|
+
}
|
|
19
|
+
function dictionary(capacity) {
|
|
20
|
+
return NSMutableDictionary.dictionaryWithCapacity(capacity);
|
|
21
|
+
}
|
|
22
|
+
function set(target, key, value) {
|
|
23
|
+
target.setObjectForKey(value, key);
|
|
24
|
+
}
|
|
25
|
+
function serviceName() {
|
|
26
|
+
return NSString.stringWithString(`dev.bleam.apps.${require_app_storage.currentAppStorageKey()}.secrets`);
|
|
27
|
+
}
|
|
28
|
+
function baseQuery(key) {
|
|
29
|
+
ensureSecurity();
|
|
30
|
+
const query = dictionary(4);
|
|
31
|
+
set(query, kSecClass, kSecClassGenericPassword);
|
|
32
|
+
set(query, kSecAttrService, serviceName());
|
|
33
|
+
set(query, kSecAttrAccount, NSString.stringWithString(key));
|
|
34
|
+
set(query, kSecUseDataProtectionKeychain, NSNumber.numberWithBool(true));
|
|
35
|
+
return query;
|
|
36
|
+
}
|
|
37
|
+
function statusMessage(status) {
|
|
38
|
+
const message = SecCopyErrorMessageString(status, null);
|
|
39
|
+
return message ? String(message) : `Keychain operation failed (${status})`;
|
|
40
|
+
}
|
|
41
|
+
function failure(status) {
|
|
42
|
+
return new NativeSecretsError(status, statusMessage(status));
|
|
43
|
+
}
|
|
44
|
+
function nativeSetItem(key, value) {
|
|
45
|
+
const query = baseQuery(key);
|
|
46
|
+
const encoded = NSString.stringWithString(value).dataUsingEncoding(NSUTF8StringEncoding);
|
|
47
|
+
const update = dictionary(1);
|
|
48
|
+
set(update, kSecValueData, encoded);
|
|
49
|
+
const updateStatus = SecItemUpdate(query, update);
|
|
50
|
+
if (updateStatus === errSecSuccess) return;
|
|
51
|
+
if (updateStatus !== errSecItemNotFound) throw failure(updateStatus);
|
|
52
|
+
set(query, kSecValueData, encoded);
|
|
53
|
+
set(query, kSecAttrAccessible, kSecAttrAccessibleWhenUnlockedThisDeviceOnly);
|
|
54
|
+
const addStatus = SecItemAdd(query, null);
|
|
55
|
+
if (addStatus === errSecSuccess) return;
|
|
56
|
+
if (addStatus === errSecDuplicateItem) {
|
|
57
|
+
const retryStatus = SecItemUpdate(baseQuery(key), update);
|
|
58
|
+
if (retryStatus === errSecSuccess) return;
|
|
59
|
+
throw failure(retryStatus);
|
|
60
|
+
}
|
|
61
|
+
throw failure(addStatus);
|
|
62
|
+
}
|
|
63
|
+
function nativeGetItem(key) {
|
|
64
|
+
const query = baseQuery(key);
|
|
65
|
+
set(query, kSecReturnData, NSNumber.numberWithBool(true));
|
|
66
|
+
set(query, kSecMatchLimit, kSecMatchLimitOne);
|
|
67
|
+
const result = new interop.Reference();
|
|
68
|
+
const status = SecItemCopyMatching(query, result);
|
|
69
|
+
if (status === errSecItemNotFound) return void 0;
|
|
70
|
+
if (status !== errSecSuccess) throw failure(status);
|
|
71
|
+
if (!result.value) throw new NativeSecretsError(errSecDecode, "Keychain returned invalid data");
|
|
72
|
+
const decoded = NSString.alloc().initWithDataEncoding(result.value, NSUTF8StringEncoding);
|
|
73
|
+
if (!decoded) throw new NativeSecretsError(errSecDecode, "Keychain returned invalid data");
|
|
74
|
+
return String(decoded);
|
|
75
|
+
}
|
|
76
|
+
function nativeHasItem(key) {
|
|
77
|
+
const status = SecItemCopyMatching(baseQuery(key), null);
|
|
78
|
+
if (status === errSecSuccess) return true;
|
|
79
|
+
if (status === errSecItemNotFound) return false;
|
|
80
|
+
throw failure(status);
|
|
81
|
+
}
|
|
82
|
+
function nativeRemoveItem(key) {
|
|
83
|
+
const status = SecItemDelete(baseQuery(key));
|
|
84
|
+
if (status === errSecSuccess || status === errSecItemNotFound) return;
|
|
85
|
+
throw failure(status);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/secrets.ts
|
|
90
|
+
var SecretsError = class extends Error {
|
|
91
|
+
constructor(code, message, status, cause) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.code = code;
|
|
94
|
+
this.status = status;
|
|
95
|
+
this.cause = cause;
|
|
96
|
+
this.name = "SecretsError";
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function validateKey(key) {
|
|
100
|
+
if (typeof key !== "string" || key.trim().length === 0) throw new SecretsError("invalid_key", "Secret key must not be empty");
|
|
101
|
+
}
|
|
102
|
+
function mapError(error) {
|
|
103
|
+
if (error instanceof SecretsError) return error;
|
|
104
|
+
if (!(error instanceof NativeSecretsError)) return new SecretsError("operation_failed", "Keychain operation failed", void 0, error);
|
|
105
|
+
return new SecretsError(error.status === void 0 || error.status === errSecNotAvailable ? "unavailable" : error.status === errSecInteractionNotAllowed ? "interaction_not_allowed" : error.status === errSecAuthFailed || error.status === errSecUserCanceled ? "authentication_failed" : error.status === errSecMissingEntitlement || error.status === errSecNoAccessForItem ? "permission_denied" : error.status === errSecDecode ? "invalid_data" : "operation_failed", error.message, error.status, error);
|
|
106
|
+
}
|
|
107
|
+
async function setItem(key, value) {
|
|
108
|
+
validateKey(key);
|
|
109
|
+
if (typeof value !== "string") throw new SecretsError("invalid_value", "Secret value must be a string");
|
|
110
|
+
try {
|
|
111
|
+
nativeSetItem(key, value);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
throw mapError(error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function getItem(key) {
|
|
117
|
+
validateKey(key);
|
|
118
|
+
try {
|
|
119
|
+
return nativeGetItem(key);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw mapError(error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function hasItem(key) {
|
|
125
|
+
validateKey(key);
|
|
126
|
+
try {
|
|
127
|
+
return nativeHasItem(key);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw mapError(error);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function removeItem(key) {
|
|
133
|
+
validateKey(key);
|
|
134
|
+
try {
|
|
135
|
+
nativeRemoveItem(key);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
throw mapError(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
exports.SecretsError = SecretsError;
|
|
143
|
+
exports.getItem = getItem;
|
|
144
|
+
exports.hasItem = hasItem;
|
|
145
|
+
exports.removeItem = removeItem;
|
|
146
|
+
exports.setItem = setItem;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/secrets.d.ts
|
|
2
|
+
type SecretsErrorCode = 'invalid_key' | 'invalid_value' | 'unavailable' | 'interaction_not_allowed' | 'authentication_failed' | 'permission_denied' | 'invalid_data' | 'operation_failed';
|
|
3
|
+
declare class SecretsError extends Error {
|
|
4
|
+
readonly code: SecretsErrorCode;
|
|
5
|
+
readonly status?: number | undefined;
|
|
6
|
+
readonly cause?: unknown | undefined;
|
|
7
|
+
constructor(code: SecretsErrorCode, message: string, status?: number | undefined, cause?: unknown | undefined);
|
|
8
|
+
}
|
|
9
|
+
declare function setItem(key: string, value: string): Promise<void>;
|
|
10
|
+
declare function getItem(key: string): Promise<string | undefined>;
|
|
11
|
+
declare function hasItem(key: string): Promise<boolean>;
|
|
12
|
+
declare function removeItem(key: string): Promise<void>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { SecretsError, SecretsErrorCode, getItem, hasItem, removeItem, setItem };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/secrets.d.ts
|
|
2
|
+
type SecretsErrorCode = 'invalid_key' | 'invalid_value' | 'unavailable' | 'interaction_not_allowed' | 'authentication_failed' | 'permission_denied' | 'invalid_data' | 'operation_failed';
|
|
3
|
+
declare class SecretsError extends Error {
|
|
4
|
+
readonly code: SecretsErrorCode;
|
|
5
|
+
readonly status?: number | undefined;
|
|
6
|
+
readonly cause?: unknown | undefined;
|
|
7
|
+
constructor(code: SecretsErrorCode, message: string, status?: number | undefined, cause?: unknown | undefined);
|
|
8
|
+
}
|
|
9
|
+
declare function setItem(key: string, value: string): Promise<void>;
|
|
10
|
+
declare function getItem(key: string): Promise<string | undefined>;
|
|
11
|
+
declare function hasItem(key: string): Promise<boolean>;
|
|
12
|
+
declare function removeItem(key: string): Promise<void>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { SecretsError, SecretsErrorCode, getItem, hasItem, removeItem, setItem };
|
package/dist/secrets.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { t as ensureNativeScript } from "./native-runtime-C85Nuc4F.js";
|
|
2
|
+
import { t as currentAppStorageKey } from "./app-storage-Isi5Bo0R.js";
|
|
3
|
+
|
|
4
|
+
//#region src/native-secrets.ts
|
|
5
|
+
var NativeSecretsError = class extends Error {
|
|
6
|
+
constructor(status, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.name = "NativeSecretsError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
let securityLoaded = false;
|
|
13
|
+
function ensureSecurity() {
|
|
14
|
+
if (securityLoaded) return;
|
|
15
|
+
const nativeScript = ensureNativeScript();
|
|
16
|
+
if (!nativeScript.isFrameworkLoaded("Security") && !nativeScript.loadFramework("Security")) throw new NativeSecretsError(void 0, "Keychain is unavailable");
|
|
17
|
+
securityLoaded = true;
|
|
18
|
+
}
|
|
19
|
+
function dictionary(capacity) {
|
|
20
|
+
return NSMutableDictionary.dictionaryWithCapacity(capacity);
|
|
21
|
+
}
|
|
22
|
+
function set(target, key, value) {
|
|
23
|
+
target.setObjectForKey(value, key);
|
|
24
|
+
}
|
|
25
|
+
function serviceName() {
|
|
26
|
+
return NSString.stringWithString(`dev.bleam.apps.${currentAppStorageKey()}.secrets`);
|
|
27
|
+
}
|
|
28
|
+
function baseQuery(key) {
|
|
29
|
+
ensureSecurity();
|
|
30
|
+
const query = dictionary(4);
|
|
31
|
+
set(query, kSecClass, kSecClassGenericPassword);
|
|
32
|
+
set(query, kSecAttrService, serviceName());
|
|
33
|
+
set(query, kSecAttrAccount, NSString.stringWithString(key));
|
|
34
|
+
set(query, kSecUseDataProtectionKeychain, NSNumber.numberWithBool(true));
|
|
35
|
+
return query;
|
|
36
|
+
}
|
|
37
|
+
function statusMessage(status) {
|
|
38
|
+
const message = SecCopyErrorMessageString(status, null);
|
|
39
|
+
return message ? String(message) : `Keychain operation failed (${status})`;
|
|
40
|
+
}
|
|
41
|
+
function failure(status) {
|
|
42
|
+
return new NativeSecretsError(status, statusMessage(status));
|
|
43
|
+
}
|
|
44
|
+
function nativeSetItem(key, value) {
|
|
45
|
+
const query = baseQuery(key);
|
|
46
|
+
const encoded = NSString.stringWithString(value).dataUsingEncoding(NSUTF8StringEncoding);
|
|
47
|
+
const update = dictionary(1);
|
|
48
|
+
set(update, kSecValueData, encoded);
|
|
49
|
+
const updateStatus = SecItemUpdate(query, update);
|
|
50
|
+
if (updateStatus === errSecSuccess) return;
|
|
51
|
+
if (updateStatus !== errSecItemNotFound) throw failure(updateStatus);
|
|
52
|
+
set(query, kSecValueData, encoded);
|
|
53
|
+
set(query, kSecAttrAccessible, kSecAttrAccessibleWhenUnlockedThisDeviceOnly);
|
|
54
|
+
const addStatus = SecItemAdd(query, null);
|
|
55
|
+
if (addStatus === errSecSuccess) return;
|
|
56
|
+
if (addStatus === errSecDuplicateItem) {
|
|
57
|
+
const retryStatus = SecItemUpdate(baseQuery(key), update);
|
|
58
|
+
if (retryStatus === errSecSuccess) return;
|
|
59
|
+
throw failure(retryStatus);
|
|
60
|
+
}
|
|
61
|
+
throw failure(addStatus);
|
|
62
|
+
}
|
|
63
|
+
function nativeGetItem(key) {
|
|
64
|
+
const query = baseQuery(key);
|
|
65
|
+
set(query, kSecReturnData, NSNumber.numberWithBool(true));
|
|
66
|
+
set(query, kSecMatchLimit, kSecMatchLimitOne);
|
|
67
|
+
const result = new interop.Reference();
|
|
68
|
+
const status = SecItemCopyMatching(query, result);
|
|
69
|
+
if (status === errSecItemNotFound) return void 0;
|
|
70
|
+
if (status !== errSecSuccess) throw failure(status);
|
|
71
|
+
if (!result.value) throw new NativeSecretsError(errSecDecode, "Keychain returned invalid data");
|
|
72
|
+
const decoded = NSString.alloc().initWithDataEncoding(result.value, NSUTF8StringEncoding);
|
|
73
|
+
if (!decoded) throw new NativeSecretsError(errSecDecode, "Keychain returned invalid data");
|
|
74
|
+
return String(decoded);
|
|
75
|
+
}
|
|
76
|
+
function nativeHasItem(key) {
|
|
77
|
+
const status = SecItemCopyMatching(baseQuery(key), null);
|
|
78
|
+
if (status === errSecSuccess) return true;
|
|
79
|
+
if (status === errSecItemNotFound) return false;
|
|
80
|
+
throw failure(status);
|
|
81
|
+
}
|
|
82
|
+
function nativeRemoveItem(key) {
|
|
83
|
+
const status = SecItemDelete(baseQuery(key));
|
|
84
|
+
if (status === errSecSuccess || status === errSecItemNotFound) return;
|
|
85
|
+
throw failure(status);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/secrets.ts
|
|
90
|
+
var SecretsError = class extends Error {
|
|
91
|
+
constructor(code, message, status, cause) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.code = code;
|
|
94
|
+
this.status = status;
|
|
95
|
+
this.cause = cause;
|
|
96
|
+
this.name = "SecretsError";
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function validateKey(key) {
|
|
100
|
+
if (typeof key !== "string" || key.trim().length === 0) throw new SecretsError("invalid_key", "Secret key must not be empty");
|
|
101
|
+
}
|
|
102
|
+
function mapError(error) {
|
|
103
|
+
if (error instanceof SecretsError) return error;
|
|
104
|
+
if (!(error instanceof NativeSecretsError)) return new SecretsError("operation_failed", "Keychain operation failed", void 0, error);
|
|
105
|
+
return new SecretsError(error.status === void 0 || error.status === errSecNotAvailable ? "unavailable" : error.status === errSecInteractionNotAllowed ? "interaction_not_allowed" : error.status === errSecAuthFailed || error.status === errSecUserCanceled ? "authentication_failed" : error.status === errSecMissingEntitlement || error.status === errSecNoAccessForItem ? "permission_denied" : error.status === errSecDecode ? "invalid_data" : "operation_failed", error.message, error.status, error);
|
|
106
|
+
}
|
|
107
|
+
async function setItem(key, value) {
|
|
108
|
+
validateKey(key);
|
|
109
|
+
if (typeof value !== "string") throw new SecretsError("invalid_value", "Secret value must be a string");
|
|
110
|
+
try {
|
|
111
|
+
nativeSetItem(key, value);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
throw mapError(error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function getItem(key) {
|
|
117
|
+
validateKey(key);
|
|
118
|
+
try {
|
|
119
|
+
return nativeGetItem(key);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw mapError(error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function hasItem(key) {
|
|
125
|
+
validateKey(key);
|
|
126
|
+
try {
|
|
127
|
+
return nativeHasItem(key);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw mapError(error);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function removeItem(key) {
|
|
133
|
+
validateKey(key);
|
|
134
|
+
try {
|
|
135
|
+
nativeRemoveItem(key);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
throw mapError(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
export { SecretsError, getItem, hasItem, removeItem, setItem };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_native_runtime = require('./native-runtime-CsXnXkQn.cjs');
|
|
3
2
|
const require_crypto = require('./crypto-CT3VZ7lF.cjs');
|
|
4
|
-
const
|
|
3
|
+
const require_app_storage = require('./app-storage-D8W4n8ey.cjs');
|
|
4
|
+
const require_schema = require('./schema-B7SLUBLN.cjs');
|
|
5
5
|
let jotai_react = require("jotai/react");
|
|
6
6
|
jotai_react = require_chunk.__toESM(jotai_react);
|
|
7
7
|
let jotai_vanilla = require("jotai/vanilla");
|
|
@@ -9,37 +9,6 @@ jotai_vanilla = require_chunk.__toESM(jotai_vanilla);
|
|
|
9
9
|
let jotai_family = require("jotai-family");
|
|
10
10
|
jotai_family = require_chunk.__toESM(jotai_family);
|
|
11
11
|
|
|
12
|
-
//#region src/app-storage.ts
|
|
13
|
-
let cachedStorageKey;
|
|
14
|
-
function launchArgument(name) {
|
|
15
|
-
const argumentsList = NSProcessInfo.processInfo.arguments();
|
|
16
|
-
const count = Number(argumentsList.count ?? 0);
|
|
17
|
-
for (let index = 0; index < count - 1; index += 1) if (String(argumentsList.objectAtIndex(index)) === name) return String(argumentsList.objectAtIndex(index + 1));
|
|
18
|
-
}
|
|
19
|
-
function storageKey$1(name) {
|
|
20
|
-
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "app";
|
|
21
|
-
}
|
|
22
|
-
function currentAppStorageKey() {
|
|
23
|
-
if (cachedStorageKey) return cachedStorageKey;
|
|
24
|
-
require_native_runtime.ensureNativeScript();
|
|
25
|
-
const configPath = launchArgument("--bleam-project-config");
|
|
26
|
-
if (configPath) try {
|
|
27
|
-
const text = String(NSString.stringWithContentsOfFileEncodingError(configPath, NSUTF8StringEncoding, null));
|
|
28
|
-
const config = JSON.parse(text);
|
|
29
|
-
if (typeof config.id === "string" && config.id) {
|
|
30
|
-
cachedStorageKey = config.id;
|
|
31
|
-
return cachedStorageKey;
|
|
32
|
-
}
|
|
33
|
-
if (typeof config.name === "string" && config.name) {
|
|
34
|
-
cachedStorageKey = storageKey$1(config.name);
|
|
35
|
-
return cachedStorageKey;
|
|
36
|
-
}
|
|
37
|
-
} catch {}
|
|
38
|
-
cachedStorageKey = "app";
|
|
39
|
-
return cachedStorageKey;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
12
|
//#region src/state/atom.ts
|
|
44
13
|
const storedAtomsKey = Symbol.for("bleam.state.storedAtoms.v1");
|
|
45
14
|
function storedAtoms() {
|
|
@@ -62,7 +31,7 @@ function asWritableAtom(value) {
|
|
|
62
31
|
function storageKey(key) {
|
|
63
32
|
const trimmed = key.trim();
|
|
64
33
|
if (!trimmed) throw new Error("Atom storage key must not be empty");
|
|
65
|
-
return `bleam.apps.${currentAppStorageKey()}.atoms.${trimmed}`;
|
|
34
|
+
return `bleam.apps.${require_app_storage.currentAppStorageKey()}.atoms.${trimmed}`;
|
|
66
35
|
}
|
|
67
36
|
function assertStoredValue(value, seen = /* @__PURE__ */ new Set()) {
|
|
68
37
|
if (value === null) return;
|
|
@@ -186,7 +155,7 @@ let jsonSqlSupportPromise;
|
|
|
186
155
|
let mutationPipeline = Promise.resolve();
|
|
187
156
|
let transactionCallbackStarting = false;
|
|
188
157
|
function getDatabase() {
|
|
189
|
-
databasePromise ??= Promise.resolve().then(() => require("./native-sqlite-
|
|
158
|
+
databasePromise ??= Promise.resolve().then(() => require("./native-sqlite-Dw--FI9a.cjs")).then((module$1) => module$1.openNativeSQLiteDatabase(`${require_app_storage.currentAppStorageKey()}.sqlite3`));
|
|
190
159
|
return databasePromise;
|
|
191
160
|
}
|
|
192
161
|
async function initializedDatabase() {
|
|
@@ -893,12 +862,6 @@ Object.defineProperty(exports, 'atomCollection', {
|
|
|
893
862
|
return atomCollection;
|
|
894
863
|
}
|
|
895
864
|
});
|
|
896
|
-
Object.defineProperty(exports, 'currentAppStorageKey', {
|
|
897
|
-
enumerable: true,
|
|
898
|
-
get: function () {
|
|
899
|
-
return currentAppStorageKey;
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
865
|
Object.defineProperty(exports, 'internalJotaiAtom', {
|
|
903
866
|
enumerable: true,
|
|
904
867
|
get: function () {
|
|
@@ -1,41 +1,10 @@
|
|
|
1
|
-
import { t as ensureNativeScript } from "./native-runtime-C85Nuc4F.js";
|
|
2
1
|
import { t as crypto } from "./crypto-BB92-Upx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { t as currentAppStorageKey } from "./app-storage-Isi5Bo0R.js";
|
|
3
|
+
import { l as schema } from "./schema-B7ELMpuI.js";
|
|
4
4
|
import { useAtom, useAtomValue, useSetAtom } from "jotai/react";
|
|
5
5
|
import { atom, getDefaultStore } from "jotai/vanilla";
|
|
6
6
|
import { atomFamily } from "jotai-family";
|
|
7
7
|
|
|
8
|
-
//#region src/app-storage.ts
|
|
9
|
-
let cachedStorageKey;
|
|
10
|
-
function launchArgument(name) {
|
|
11
|
-
const argumentsList = NSProcessInfo.processInfo.arguments();
|
|
12
|
-
const count = Number(argumentsList.count ?? 0);
|
|
13
|
-
for (let index = 0; index < count - 1; index += 1) if (String(argumentsList.objectAtIndex(index)) === name) return String(argumentsList.objectAtIndex(index + 1));
|
|
14
|
-
}
|
|
15
|
-
function storageKey$1(name) {
|
|
16
|
-
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "app";
|
|
17
|
-
}
|
|
18
|
-
function currentAppStorageKey() {
|
|
19
|
-
if (cachedStorageKey) return cachedStorageKey;
|
|
20
|
-
ensureNativeScript();
|
|
21
|
-
const configPath = launchArgument("--bleam-project-config");
|
|
22
|
-
if (configPath) try {
|
|
23
|
-
const text = String(NSString.stringWithContentsOfFileEncodingError(configPath, NSUTF8StringEncoding, null));
|
|
24
|
-
const config = JSON.parse(text);
|
|
25
|
-
if (typeof config.id === "string" && config.id) {
|
|
26
|
-
cachedStorageKey = config.id;
|
|
27
|
-
return cachedStorageKey;
|
|
28
|
-
}
|
|
29
|
-
if (typeof config.name === "string" && config.name) {
|
|
30
|
-
cachedStorageKey = storageKey$1(config.name);
|
|
31
|
-
return cachedStorageKey;
|
|
32
|
-
}
|
|
33
|
-
} catch {}
|
|
34
|
-
cachedStorageKey = "app";
|
|
35
|
-
return cachedStorageKey;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
8
|
//#region src/state/atom.ts
|
|
40
9
|
const storedAtomsKey = Symbol.for("bleam.state.storedAtoms.v1");
|
|
41
10
|
function storedAtoms() {
|
|
@@ -182,7 +151,7 @@ let jsonSqlSupportPromise;
|
|
|
182
151
|
let mutationPipeline = Promise.resolve();
|
|
183
152
|
let transactionCallbackStarting = false;
|
|
184
153
|
function getDatabase() {
|
|
185
|
-
databasePromise ??= import("./native-sqlite-
|
|
154
|
+
databasePromise ??= import("./native-sqlite-WzRNzCSh.js").then((module) => module.openNativeSQLiteDatabase(`${currentAppStorageKey()}.sqlite3`));
|
|
186
155
|
return databasePromise;
|
|
187
156
|
}
|
|
188
157
|
async function initializedDatabase() {
|
|
@@ -871,4 +840,4 @@ function useField(collection, id, path) {
|
|
|
871
840
|
}
|
|
872
841
|
|
|
873
842
|
//#endregion
|
|
874
|
-
export { transactionAtom as a, useRow as c, internalJotaiWritableAtom as d, internalStore as f,
|
|
843
|
+
export { transactionAtom as a, useRow as c, internalJotaiWritableAtom as d, internalStore as f, useSetAtom$1 as h, queryAtom as i, atom$1 as l, useAtomValue$1 as m, atomCollection as n, useField as o, useAtom$1 as p, mutateAtom as r, useList as s, CollectionVersionConflictError as t, internalJotaiAtom as u };
|
package/dist/state.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require('./native-runtime-CsXnXkQn.cjs');
|
|
2
2
|
require('./crypto-CT3VZ7lF.cjs');
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
require('./app-storage-D8W4n8ey.cjs');
|
|
4
|
+
const require_schema = require('./schema-B7SLUBLN.cjs');
|
|
5
|
+
const require_state = require('./state-BZYyrE2-.cjs');
|
|
5
6
|
|
|
6
7
|
exports.CollectionVersionConflictError = require_state.CollectionVersionConflictError;
|
|
7
8
|
exports.array = require_schema.array;
|
package/dist/state.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as array, C as SchemaOutput, E as SchemaShape, F as number, I as object, P as literal, R as string, _ as ObjectField, b as SchemaInput, c as FieldPath, j as boolean, k as ValueAtFieldPath, s as FieldOutput, w as SchemaPatch } from "./schema-
|
|
1
|
+
import { A as array, C as SchemaOutput, E as SchemaShape, F as number, I as object, P as literal, R as string, _ as ObjectField, b as SchemaInput, c as FieldPath, j as boolean, k as ValueAtFieldPath, s as FieldOutput, w as SchemaPatch } from "./schema-BWsDPc6c.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/state/atom.d.ts
|
|
4
4
|
declare const atomValue: unique symbol;
|
package/dist/state.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as array, C as SchemaOutput, E as SchemaShape, F as number, I as object, P as literal, R as string, _ as ObjectField, b as SchemaInput, c as FieldPath, j as boolean, k as ValueAtFieldPath, s as FieldOutput, w as SchemaPatch } from "./schema-
|
|
1
|
+
import { A as array, C as SchemaOutput, E as SchemaShape, F as number, I as object, P as literal, R as string, _ as ObjectField, b as SchemaInput, c as FieldPath, j as boolean, k as ValueAtFieldPath, s as FieldOutput, w as SchemaPatch } from "./schema-LxnzAfgw.js";
|
|
2
2
|
import "jotai/vanilla";
|
|
3
3
|
|
|
4
4
|
//#region src/state/atom.d.ts
|
package/dist/state.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./native-runtime-C85Nuc4F.js";
|
|
2
2
|
import "./crypto-BB92-Upx.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import "./app-storage-Isi5Bo0R.js";
|
|
4
|
+
import { c as object, n as array, o as literal, r as boolean, s as number, u as string } from "./schema-B7ELMpuI.js";
|
|
5
|
+
import { a as transactionAtom, c as useRow, h as useSetAtom, i as queryAtom, l as atom, m as useAtomValue, n as atomCollection, o as useField, p as useAtom, r as mutateAtom, s as useList, t as CollectionVersionConflictError } from "./state-DkaRFkZJ.js";
|
|
5
6
|
|
|
6
7
|
export { CollectionVersionConflictError, array, atom, atomCollection, boolean, literal, mutateAtom, number, object, queryAtom, string, transactionAtom, useAtom, useAtomValue, useField, useList, useRow, useSetAtom };
|
package/dist/window.d.cts
CHANGED
package/dist/window.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
1
|
+
import { n as SymbolName } from "./elements-ClGQ41Sc.js";
|
|
2
|
+
import * as react5 from "react";
|
|
3
3
|
import { ComponentType } from "react";
|
|
4
4
|
import { StyleProp, ViewStyle } from "react-native";
|
|
5
5
|
|
|
@@ -55,7 +55,7 @@ type SidebarNavigatorConfig<Routes extends SidebarScreenMap> = {
|
|
|
55
55
|
style?: StyleProp<ViewStyle>;
|
|
56
56
|
};
|
|
57
57
|
declare function createSidebarNavigator<const Routes extends SidebarScreenMap>(config: SidebarNavigatorConfig<Routes>): {
|
|
58
|
-
Navigator: () =>
|
|
58
|
+
Navigator: () => react5.JSX.Element;
|
|
59
59
|
useNavigation: () => SidebarNavigation<Routes>;
|
|
60
60
|
useRoute: () => SidebarRouteState<Routes>;
|
|
61
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bleam",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"packageManager": "yarn@1.22.22",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -97,6 +97,11 @@
|
|
|
97
97
|
"import": "./dist/dev-protocol.js",
|
|
98
98
|
"require": "./dist/dev-protocol.cjs"
|
|
99
99
|
},
|
|
100
|
+
"./elements": {
|
|
101
|
+
"types": "./dist/elements.d.ts",
|
|
102
|
+
"import": "./dist/elements.js",
|
|
103
|
+
"require": "./dist/elements.cjs"
|
|
104
|
+
},
|
|
100
105
|
"./files": {
|
|
101
106
|
"types": "./dist/files.d.ts",
|
|
102
107
|
"import": "./dist/files.js",
|
|
@@ -117,6 +122,11 @@
|
|
|
117
122
|
"import": "./dist/schema.js",
|
|
118
123
|
"require": "./dist/schema.cjs"
|
|
119
124
|
},
|
|
125
|
+
"./secrets": {
|
|
126
|
+
"types": "./dist/secrets.d.ts",
|
|
127
|
+
"import": "./dist/secrets.js",
|
|
128
|
+
"require": "./dist/secrets.cjs"
|
|
129
|
+
},
|
|
120
130
|
"./state": {
|
|
121
131
|
"types": "./dist/state.d.ts",
|
|
122
132
|
"import": "./dist/state.js",
|
|
@@ -127,11 +137,6 @@
|
|
|
127
137
|
"import": "./dist/styles.js",
|
|
128
138
|
"require": "./dist/styles.cjs"
|
|
129
139
|
},
|
|
130
|
-
"./ui": {
|
|
131
|
-
"types": "./dist/ui.d.ts",
|
|
132
|
-
"import": "./dist/ui.js",
|
|
133
|
-
"require": "./dist/ui.cjs"
|
|
134
|
-
},
|
|
135
140
|
"./window": {
|
|
136
141
|
"types": "./dist/window.d.ts",
|
|
137
142
|
"import": "./dist/window.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Button } from 'bleam/elements'
|
|
1
2
|
import { atom, useAtom } from 'bleam/state'
|
|
2
3
|
import { sx } from 'bleam/styles'
|
|
3
|
-
import { Button } from 'bleam/ui'
|
|
4
4
|
import { Toolbar, Window } from 'bleam/window'
|
|
5
5
|
import { Text, View } from 'react-native'
|
|
6
6
|
|
|
@@ -125,7 +125,7 @@ export default function App() {
|
|
|
125
125
|
</View>
|
|
126
126
|
|
|
127
127
|
<Button
|
|
128
|
-
|
|
128
|
+
label={`Count is ${count}`}
|
|
129
129
|
variant="secondary"
|
|
130
130
|
size="regular"
|
|
131
131
|
onPress={() => setCount((value) => value + 1)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { chat, useChat, useChatList } from 'bleam/ai'
|
|
2
|
+
import { Button } from 'bleam/elements'
|
|
2
3
|
import { sx } from 'bleam/styles'
|
|
3
|
-
import { Button } from 'bleam/ui'
|
|
4
4
|
import { Window } from 'bleam/window'
|
|
5
5
|
import { useEffect, useRef, useState } from 'react'
|
|
6
6
|
import { Text, TextInput, View } from 'react-native'
|
|
@@ -64,20 +64,20 @@ function Conversation({ id }: { id: string }) {
|
|
|
64
64
|
/>
|
|
65
65
|
<View style={sx('flex-row', 'gap-3')}>
|
|
66
66
|
<Button
|
|
67
|
-
|
|
67
|
+
label="Send"
|
|
68
68
|
loading={conversation.isGenerating}
|
|
69
69
|
disabled={!conversation.canSend}
|
|
70
70
|
onPress={() => void conversation.send(prompt)}
|
|
71
71
|
/>
|
|
72
72
|
<Button
|
|
73
|
-
|
|
73
|
+
label="Cancel"
|
|
74
74
|
variant="secondary"
|
|
75
75
|
disabled={!conversation.canCancel}
|
|
76
76
|
onPress={() => void conversation.cancel()}
|
|
77
77
|
/>
|
|
78
78
|
{retryable ? (
|
|
79
79
|
<Button
|
|
80
|
-
|
|
80
|
+
label="Retry"
|
|
81
81
|
variant="secondary"
|
|
82
82
|
onPress={() => void conversation.retry(retryable.id)}
|
|
83
83
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bonsai, image } from 'bleam/ai'
|
|
2
|
+
import { Button } from 'bleam/elements'
|
|
2
3
|
import { sx } from 'bleam/styles'
|
|
3
|
-
import { Button } from 'bleam/ui'
|
|
4
4
|
import { Window } from 'bleam/window'
|
|
5
5
|
import { useState } from 'react'
|
|
6
6
|
import { Image, Text, View } from 'react-native'
|
|
@@ -35,7 +35,7 @@ export default function App() {
|
|
|
35
35
|
<Image source={{ uri }} style={sx('w-96', 'h-96', 'rounded-xl')} />
|
|
36
36
|
) : null}
|
|
37
37
|
<Text style={sx('text-secondary-label')}>{status}</Text>
|
|
38
|
-
<Button
|
|
38
|
+
<Button label="Generate image" onPress={create} />
|
|
39
39
|
</View>
|
|
40
40
|
)
|
|
41
41
|
}
|
|
@@ -9,9 +9,6 @@ import FoundationModels
|
|
|
9
9
|
|
|
10
10
|
public final class AIModule: Module {
|
|
11
11
|
@MainActor private let textGeneration = TextGenerationCoordinator()
|
|
12
|
-
private static var appGroupIdentifier: String {
|
|
13
|
-
Bundle.main.object(forInfoDictionaryKey: "AppGroupIdentifier") as? String ?? "group.dev.bleam.app"
|
|
14
|
-
}
|
|
15
12
|
|
|
16
13
|
public func definition() -> ModuleDefinition {
|
|
17
14
|
Name("AI")
|
|
@@ -382,13 +379,15 @@ public final class AIModule: Module {
|
|
|
382
379
|
|
|
383
380
|
private static func workerRequest(from request: FluxImageRequest) throws -> GenerationWorkerRequest {
|
|
384
381
|
let jobID = UUID()
|
|
385
|
-
guard let
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
382
|
+
guard let cacheDirectory = FileManager.default.urls(
|
|
383
|
+
for: .cachesDirectory,
|
|
384
|
+
in: .userDomainMask
|
|
385
|
+
).first else {
|
|
386
|
+
throw ModuleError.imageGeneration("Generation cache is unavailable")
|
|
389
387
|
}
|
|
390
388
|
|
|
391
|
-
let stagingDirectory =
|
|
389
|
+
let stagingDirectory = cacheDirectory
|
|
390
|
+
.appendingPathComponent("Bleam", isDirectory: true)
|
|
392
391
|
.appendingPathComponent("GenerationRuns", isDirectory: true)
|
|
393
392
|
.appendingPathComponent("bleam-generation-jobs", isDirectory: true)
|
|
394
393
|
.appendingPathComponent(jobID.uuidString, isDirectory: true)
|