bleam 0.0.11 → 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 +2315 -2173
- package/dist/ai.d.cts +227 -322
- package/dist/ai.d.ts +227 -322
- package/dist/ai.js +2310 -2159
- 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 +14 -1
- package/dist/cli.d.ts +13 -0
- package/dist/cli.js +148 -22
- package/dist/config.d.cts +1 -1
- package/dist/elements-CFk0QHw0.d.cts +127 -0
- package/dist/{ui-CHc4xEs_.d.ts → elements-ClGQ41Sc.d.ts} +84 -49
- 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-Ds1wT8C2.js → files-DErLhzCB.js} +11 -12
- package/dist/{files-Bo7h9fik.cjs → files-lMk-CpL_.cjs} +16 -11
- package/dist/files.cjs +1 -1
- package/dist/files.d.cts +1 -1
- package/dist/files.js +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/schema-B7ELMpuI.js +226 -0
- package/dist/schema-B7SLUBLN.cjs +286 -0
- package/dist/schema-BWsDPc6c.d.cts +125 -0
- package/dist/schema-LxnzAfgw.d.ts +125 -0
- package/dist/schema.cjs +10 -2
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +2 -2
- 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-BZYyrE2-.cjs +936 -0
- package/dist/state-DkaRFkZJ.js +843 -0
- package/dist/state.cjs +17 -12
- package/dist/state.d.cts +144 -140
- package/dist/state.d.ts +145 -140
- package/dist/state.js +4 -3
- package/dist/window.d.cts +1 -1
- package/dist/window.d.ts +3 -3
- package/package.json +13 -6
- package/templates/basic/app/index.tsx +2 -2
- package/templates/foundation-models/app/index.tsx +78 -16
- package/templates/image-generation/app/index.tsx +4 -4
- package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +46 -46
- package/templates/native/ios/Podfile.lock +173 -173
- package/templates/native/modules/bleam-runtime/ios/AIModule.swift +42 -365
- package/templates/state/app/index.tsx +2 -2
- package/templates/text-generation/app/index.tsx +83 -52
- package/templates/updates/README.md +1 -1
- package/dist/schema-Bo5Jvqus.js +0 -90
- package/dist/schema-CYh6n8GS.d.ts +0 -58
- package/dist/schema-oeOrd3i1.d.cts +0 -58
- package/dist/schema-rQ13mrpD.cjs +0 -102
- package/dist/state-Bx0VlTlO.cjs +0 -852
- package/dist/state-CAwe-Vw1.js +0 -767
- package/dist/ui-1WepaMS4.d.cts +0 -92
- package/dist/ui.d.cts +0 -2
- package/dist/ui.d.ts +0 -2
- /package/dist/{config-CufOVJV3.d.cts → config-COcRnn5a.d.cts} +0 -0
- /package/dist/{files-Dt5mbzLq.d.cts → files-DwA7pzr3.d.cts} +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/state.d.ts
CHANGED
|
@@ -1,159 +1,164 @@
|
|
|
1
|
-
import {
|
|
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
|
+
import "jotai/vanilla";
|
|
2
3
|
|
|
3
4
|
//#region src/state/atom.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
declare const atomValue: unique symbol;
|
|
6
|
+
declare const atomWrite: unique symbol;
|
|
7
|
+
interface Atom<Value> {
|
|
8
|
+
readonly [atomValue]: Value;
|
|
8
9
|
}
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private value;
|
|
15
|
-
private listeners;
|
|
16
|
-
constructor(value: Value);
|
|
17
|
-
get(): Value;
|
|
18
|
-
set(value: Value): void;
|
|
19
|
-
update(updater: (value: Value) => Value): void;
|
|
20
|
-
subscribe(listener: Listener): () => void;
|
|
10
|
+
interface WritableAtom<Value, Args$1 extends unknown[], Result$1> extends Atom<Value> {
|
|
11
|
+
readonly [atomWrite]: {
|
|
12
|
+
args: Args$1;
|
|
13
|
+
result: Result$1;
|
|
14
|
+
};
|
|
21
15
|
}
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
type SetStateAction<Value> = Value | ((current: Value) => Value);
|
|
17
|
+
type PrimitiveAtom<Value> = WritableAtom<Value, [SetStateAction<Value>], void>;
|
|
18
|
+
type Getter = <Value>(value: Atom<Value>) => Value;
|
|
19
|
+
type Setter = <Value, Args$1 extends unknown[], Result$1>(value: WritableAtom<Value, Args$1, Result$1>, ...args: Args$1) => Result$1;
|
|
20
|
+
type AtomOptions = {
|
|
21
|
+
storage?: string;
|
|
22
|
+
};
|
|
23
|
+
declare function atom<Value, Args$1 extends unknown[], Result$1>(read: (get: Getter) => Value, write: (get: Getter, set: Setter, ...args: Args$1) => Result$1): WritableAtom<Value, Args$1, Result$1>;
|
|
24
|
+
declare function atom<Value>(read: (get: Getter) => Value): Atom<Value>;
|
|
25
|
+
declare function atom<Value>(initialValue: Value, options?: AtomOptions): PrimitiveAtom<Value>;
|
|
26
|
+
declare function useAtomValue<Value>(value: Atom<Value>): Awaited<Value>;
|
|
27
|
+
declare function useSetAtom<Value, Args$1 extends unknown[], Result$1>(value: WritableAtom<Value, Args$1, Result$1>): (...args: Args$1) => Result$1;
|
|
28
|
+
declare function useAtom<Value, Args$1 extends unknown[], Result$1>(value: WritableAtom<Value, Args$1, Result$1>): [Awaited<Value>, (...args: Args$1) => Result$1];
|
|
27
29
|
//#endregion
|
|
28
30
|
//#region src/state/collection.d.ts
|
|
29
|
-
|
|
30
|
-
type
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
type CollectionReference = {
|
|
55
|
-
readonly name: string;
|
|
56
|
-
get(id: string): Promise<unknown>;
|
|
31
|
+
declare const collectionBrand: unique symbol;
|
|
32
|
+
type AnyShape = SchemaShape;
|
|
33
|
+
type AnyCollection = CollectionAtom<AnyShape>;
|
|
34
|
+
type Scalar = string | number | boolean;
|
|
35
|
+
type MaybePromise<Value> = Value | Promise<Value>;
|
|
36
|
+
type Order = 'asc' | 'desc';
|
|
37
|
+
type Comparison = 'equals' | 'greater-than' | 'less-than' | 'contains';
|
|
38
|
+
type ComparisonFor<Value> = Value extends number ? Exclude<Comparison, 'contains'> : Value extends string ? 'equals' | 'contains' : 'equals';
|
|
39
|
+
type WhereClauseValue<Value> = Value | readonly [ComparisonFor<Value>, Value] | ReadonlyArray<readonly [ComparisonFor<Value>, Value]>;
|
|
40
|
+
type ScalarFieldPath<Shape extends SchemaShape> = { [Key in Extract<keyof Shape, string>]: Shape[Key] extends {
|
|
41
|
+
kind: 'object';
|
|
42
|
+
shape: infer Nested extends SchemaShape;
|
|
43
|
+
} ? `${Key}.${ScalarFieldPath<Nested>}` : Shape[Key] extends {
|
|
44
|
+
kind: 'array';
|
|
45
|
+
} ? never : Key }[Extract<keyof Shape, string>];
|
|
46
|
+
type ScalarAtPath<Shape extends SchemaShape, Path$1 extends ScalarFieldPath<Shape>> = Path$1 extends `${infer Key}.${infer Rest}` ? Key extends keyof Shape ? Shape[Key] extends ObjectField<infer Nested> ? Rest extends ScalarFieldPath<Nested> ? ScalarAtPath<Nested, Rest> : never : never : never : Path$1 extends keyof Shape ? Extract<FieldOutput<Shape[Path$1]>, Scalar> : never;
|
|
47
|
+
type CollectionRow<Shape extends SchemaShape> = {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly collection: string;
|
|
50
|
+
readonly version: number;
|
|
51
|
+
readonly createdAt: string;
|
|
52
|
+
readonly updatedAt: string;
|
|
53
|
+
readonly data: SchemaOutput<Shape>;
|
|
54
|
+
readonly links: Readonly<Record<string, readonly string[]>>;
|
|
57
55
|
};
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
interface CollectionAtom<Shape extends SchemaShape> extends Atom<Promise<readonly string[]>> {
|
|
57
|
+
readonly [collectionBrand]: Shape;
|
|
58
|
+
}
|
|
59
|
+
declare class CollectionVersionConflictError extends Error {
|
|
60
|
+
readonly collection: string;
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly expectedVersion: number;
|
|
63
|
+
readonly actualVersion: number;
|
|
64
|
+
readonly name = "CollectionVersionConflictError";
|
|
65
|
+
constructor(collection: string, id: string, expectedVersion: number, actualVersion: number);
|
|
66
|
+
}
|
|
67
|
+
type UpdateOptions = {
|
|
68
|
+
ifVersion?: number;
|
|
60
69
|
};
|
|
61
|
-
type
|
|
62
|
-
|
|
63
|
-
where?: Partial<Record<CollectionFieldKey<Shape>, ListWhereValue>>;
|
|
64
|
-
sortBy?: CollectionFieldKey<Shape> | 'createdAt' | 'updatedAt';
|
|
65
|
-
order?: 'asc' | 'desc';
|
|
66
|
-
take?: number;
|
|
70
|
+
type RowOptions = {
|
|
71
|
+
links?: readonly AnyCollection[];
|
|
67
72
|
};
|
|
68
|
-
type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
type CollectionWhere<Shape extends SchemaShape> = Partial<{ [Path in ScalarFieldPath<Shape>]: WhereClauseValue<ScalarAtPath<Shape, Path>> }>;
|
|
74
|
+
type WhereClause = {
|
|
75
|
+
path: string;
|
|
76
|
+
comparison: Comparison;
|
|
77
|
+
operand: Scalar;
|
|
73
78
|
};
|
|
74
|
-
type
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
next: RawCollectionView | null;
|
|
79
|
-
changedPaths: Set<string>;
|
|
80
|
-
};
|
|
81
|
-
type EdgeChange = {
|
|
82
|
-
type: 'link' | 'unlink';
|
|
83
|
-
left: {
|
|
79
|
+
type QueryPlan = {
|
|
80
|
+
terminal: 'ids' | 'row' | 'field';
|
|
81
|
+
where: WhereClause[];
|
|
82
|
+
from?: {
|
|
84
83
|
collection: string;
|
|
85
84
|
id: string;
|
|
86
85
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
sort?: {
|
|
87
|
+
path: string;
|
|
88
|
+
order: Order;
|
|
90
89
|
};
|
|
90
|
+
take?: number;
|
|
91
|
+
id?: string;
|
|
92
|
+
path?: string;
|
|
93
|
+
links?: string[];
|
|
91
94
|
};
|
|
92
|
-
type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
type QueryTerminal<Shape extends SchemaShape, Result$1> = {
|
|
96
|
+
readonly plan: QueryPlan;
|
|
97
|
+
readonly result?: Result$1;
|
|
98
|
+
readonly shape?: Shape;
|
|
96
99
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
interface QueryBuilder<Shape extends SchemaShape> {
|
|
101
|
+
where(filters: CollectionWhere<Shape>): QueryBuilder<Shape>;
|
|
102
|
+
from<OtherShape extends SchemaShape>(other: CollectionAtom<OtherShape>, id: string): QueryBuilder<Shape>;
|
|
103
|
+
sortBy(path: ScalarFieldPath<Shape> | 'createdAt' | 'updatedAt', order?: Order): QueryBuilder<Shape>;
|
|
104
|
+
take(count: number): QueryBuilder<Shape>;
|
|
105
|
+
ids(): QueryTerminal<Shape, readonly string[]>;
|
|
106
|
+
row(id: string, options?: RowOptions): QueryTerminal<Shape, CollectionRow<Shape> | null>;
|
|
107
|
+
field<Path$1 extends FieldPath<Shape>>(id: string, path: Path$1): QueryTerminal<Shape, ValueAtFieldPath<Shape, Path$1> | undefined>;
|
|
108
|
+
}
|
|
109
|
+
type InsertTerminal<Shape extends SchemaShape> = {
|
|
110
|
+
kind: 'insert';
|
|
111
|
+
args: [SchemaInput<Shape>];
|
|
112
|
+
result: string;
|
|
104
113
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
all(): Promise<CollectionView<Shape>[]>;
|
|
132
|
-
get(id: string): Promise<CollectionView<Shape> | null>;
|
|
133
|
-
subscribeRecord(id: string, listener: Listener): () => void;
|
|
134
|
-
subscribeList(options: ListOptions<Shape> | undefined, listener: Listener): () => void;
|
|
135
|
-
subscribeField(id: string, path: string, listener: Listener): () => void;
|
|
136
|
-
getRecordVersion(id: string): number;
|
|
137
|
-
getListVersion(options?: ListOptions<Shape>): number;
|
|
138
|
-
getFieldVersion(id: string, path: string): number;
|
|
139
|
-
getRecordSnapshot(id: string, options?: ViewOptions): CollectionView<Shape> | null | undefined;
|
|
140
|
-
getListSnapshot(options?: ListOptions<Shape>): string[] | undefined;
|
|
141
|
-
ensureRecord(id: string, options?: ViewOptions): Promise<RawCollectionView | null>;
|
|
142
|
-
ensureList(options?: ListOptions<Shape>): Promise<string[]>;
|
|
143
|
-
private deleteLinksForRecord;
|
|
114
|
+
type UpdateTerminal<Shape extends SchemaShape> = {
|
|
115
|
+
kind: 'update';
|
|
116
|
+
id: string;
|
|
117
|
+
args: [SchemaPatch<Shape>, UpdateOptions?];
|
|
118
|
+
result: CollectionRow<Shape>;
|
|
119
|
+
};
|
|
120
|
+
type RemoveTerminal = {
|
|
121
|
+
kind: 'remove';
|
|
122
|
+
id: string;
|
|
123
|
+
args: [];
|
|
124
|
+
result: boolean;
|
|
125
|
+
};
|
|
126
|
+
type LinkTerminal = {
|
|
127
|
+
kind: 'link' | 'unlink';
|
|
128
|
+
id: string;
|
|
129
|
+
other: AnyCollection;
|
|
130
|
+
args: [string];
|
|
131
|
+
result: boolean;
|
|
132
|
+
};
|
|
133
|
+
type MutationTerminal<Shape extends SchemaShape> = InsertTerminal<Shape> | UpdateTerminal<Shape> | RemoveTerminal | LinkTerminal;
|
|
134
|
+
interface MutationBuilder<Shape extends SchemaShape> {
|
|
135
|
+
insert(): InsertTerminal<Shape>;
|
|
136
|
+
update(id: string): UpdateTerminal<Shape>;
|
|
137
|
+
remove(id: string): RemoveTerminal;
|
|
138
|
+
link<OtherShape extends SchemaShape>(id: string, other: CollectionAtom<OtherShape>): LinkTerminal;
|
|
139
|
+
unlink<OtherShape extends SchemaShape>(id: string, other: CollectionAtom<OtherShape>): LinkTerminal;
|
|
144
140
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
declare function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
type TerminalArgs<Terminal> = Terminal extends {
|
|
142
|
+
args: infer Args extends unknown[];
|
|
143
|
+
} ? Args : never;
|
|
144
|
+
type TerminalResult<Terminal> = Terminal extends {
|
|
145
|
+
result: infer Result;
|
|
146
|
+
} ? Result : never;
|
|
147
|
+
declare function atomCollection<const Shape extends SchemaShape>(name: string, shape: Shape): CollectionAtom<Shape>;
|
|
148
|
+
declare function queryAtom<Shape extends SchemaShape, Result$1>(collection: CollectionAtom<Shape>, build: (builder: QueryBuilder<Shape>) => QueryTerminal<Shape, Result$1>): Atom<Promise<Result$1>>;
|
|
149
|
+
declare function mutateAtom<Shape extends SchemaShape, Terminal extends MutationTerminal<Shape>>(collection: CollectionAtom<Shape>, build: (builder: MutationBuilder<Shape>) => Terminal): WritableAtom<null, TerminalArgs<Terminal>, Promise<TerminalResult<Terminal>>>;
|
|
150
|
+
interface TransactionContext {
|
|
151
|
+
get<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string, options?: RowOptions): Promise<CollectionRow<Shape> | null>;
|
|
152
|
+
query<Shape extends SchemaShape, Result$1>(collection: CollectionAtom<Shape>, build: (builder: QueryBuilder<Shape>) => QueryTerminal<Shape, Result$1>): Promise<Result$1>;
|
|
153
|
+
insert<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, value: SchemaInput<Shape>): Promise<string>;
|
|
154
|
+
update<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string, patch: SchemaPatch<Shape>, options?: UpdateOptions): Promise<CollectionRow<Shape>>;
|
|
155
|
+
remove<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string): Promise<boolean>;
|
|
156
|
+
link<LeftShape extends SchemaShape, RightShape extends SchemaShape>(collection: CollectionAtom<LeftShape>, id: string, other: CollectionAtom<RightShape>, otherId: string): Promise<boolean>;
|
|
157
|
+
unlink<LeftShape extends SchemaShape, RightShape extends SchemaShape>(collection: CollectionAtom<LeftShape>, id: string, other: CollectionAtom<RightShape>, otherId: string): Promise<boolean>;
|
|
158
|
+
}
|
|
159
|
+
declare function transactionAtom<Args$1 extends unknown[], Result$1>(action: (context: TransactionContext, ...args: Args$1) => MaybePromise<Result$1>): WritableAtom<null, Args$1, Promise<Result$1>>;
|
|
160
|
+
declare function useList<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, build?: (builder: QueryBuilder<Shape>) => QueryTerminal<Shape, readonly string[]>): readonly string[];
|
|
161
|
+
declare function useRow<Shape extends SchemaShape>(collection: CollectionAtom<Shape>, id: string, options?: RowOptions): CollectionRow<Shape> | null;
|
|
162
|
+
declare function useField<Shape extends SchemaShape, Path$1 extends FieldPath<Shape>>(collection: CollectionAtom<Shape>, id: string, path: Path$1): ValueAtFieldPath<Shape, Path$1> | undefined;
|
|
158
163
|
//#endregion
|
|
159
|
-
export { Atom,
|
|
164
|
+
export { type Atom, type AtomOptions, CollectionAtom, CollectionRow, CollectionVersionConflictError, CollectionWhere, type Getter, MutationBuilder, type PrimitiveAtom, QueryBuilder, RowOptions, type SetStateAction, type Setter, TransactionContext, UpdateOptions, type WritableAtom, array, atom, atomCollection, boolean, literal, mutateAtom, number, object, queryAtom, string, transactionAtom, useAtom, useAtomValue, useField, useList, useRow, useSetAtom };
|
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 "./schema-
|
|
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
|
-
export {
|
|
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": [
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"@types/react": "~19.2.17",
|
|
36
36
|
"expo": "57",
|
|
37
37
|
"expo-splash-screen": "57.0.2",
|
|
38
|
+
"jotai": "2.20.2",
|
|
39
|
+
"jotai-family": "1.0.2",
|
|
38
40
|
"react": "19.2.3",
|
|
39
41
|
"react-native": "0.86.0",
|
|
40
42
|
"tsx": "^4.21.0",
|
|
@@ -95,6 +97,11 @@
|
|
|
95
97
|
"import": "./dist/dev-protocol.js",
|
|
96
98
|
"require": "./dist/dev-protocol.cjs"
|
|
97
99
|
},
|
|
100
|
+
"./elements": {
|
|
101
|
+
"types": "./dist/elements.d.ts",
|
|
102
|
+
"import": "./dist/elements.js",
|
|
103
|
+
"require": "./dist/elements.cjs"
|
|
104
|
+
},
|
|
98
105
|
"./files": {
|
|
99
106
|
"types": "./dist/files.d.ts",
|
|
100
107
|
"import": "./dist/files.js",
|
|
@@ -115,6 +122,11 @@
|
|
|
115
122
|
"import": "./dist/schema.js",
|
|
116
123
|
"require": "./dist/schema.cjs"
|
|
117
124
|
},
|
|
125
|
+
"./secrets": {
|
|
126
|
+
"types": "./dist/secrets.d.ts",
|
|
127
|
+
"import": "./dist/secrets.js",
|
|
128
|
+
"require": "./dist/secrets.cjs"
|
|
129
|
+
},
|
|
118
130
|
"./state": {
|
|
119
131
|
"types": "./dist/state.d.ts",
|
|
120
132
|
"import": "./dist/state.js",
|
|
@@ -125,11 +137,6 @@
|
|
|
125
137
|
"import": "./dist/styles.js",
|
|
126
138
|
"require": "./dist/styles.cjs"
|
|
127
139
|
},
|
|
128
|
-
"./ui": {
|
|
129
|
-
"types": "./dist/ui.d.ts",
|
|
130
|
-
"import": "./dist/ui.js",
|
|
131
|
-
"require": "./dist/ui.cjs"
|
|
132
|
-
},
|
|
133
140
|
"./window": {
|
|
134
141
|
"types": "./dist/window.d.ts",
|
|
135
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,32 +1,94 @@
|
|
|
1
|
-
import {
|
|
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
|
-
import { useState } from 'react'
|
|
6
|
-
import { Text, View } from 'react-native'
|
|
5
|
+
import { useEffect, useRef, useState } from 'react'
|
|
6
|
+
import { Text, TextInput, View } from 'react-native'
|
|
7
7
|
|
|
8
8
|
const appName = 'Bleam Basic'
|
|
9
9
|
|
|
10
10
|
export default function App() {
|
|
11
|
-
const
|
|
11
|
+
const chats = useChatList()
|
|
12
|
+
const creating = useRef(false)
|
|
13
|
+
const [error, setError] = useState('')
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (chats.length > 0 || creating.current) return
|
|
17
|
+
creating.current = true
|
|
18
|
+
void chat
|
|
19
|
+
.create({ title: 'App ideas' })
|
|
20
|
+
.catch((nextError) =>
|
|
21
|
+
setError(
|
|
22
|
+
nextError instanceof Error ? nextError.message : String(nextError),
|
|
23
|
+
),
|
|
18
24
|
)
|
|
19
|
-
|
|
20
|
-
setAnswer(error instanceof Error ? error.message : String(error))
|
|
21
|
-
}
|
|
22
|
-
}
|
|
25
|
+
}, [chats.length])
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<View style={sx('flex-1', 'p-8', 'gap-6')}>
|
|
26
29
|
<Window title={appName} />
|
|
27
30
|
<Text style={sx('text-3xl', 'font-semibold')}>Foundation Models</Text>
|
|
28
|
-
<Text style={sx('text-
|
|
29
|
-
|
|
31
|
+
<Text style={sx('text-secondary-label')}>
|
|
32
|
+
Chats persist on this Mac and use Apple Foundation Models by default.
|
|
33
|
+
</Text>
|
|
34
|
+
{error ? <Text style={sx('text-system-red')}>{error}</Text> : null}
|
|
35
|
+
{chats[0] ? (
|
|
36
|
+
<Conversation id={chats[0].id} />
|
|
37
|
+
) : (
|
|
38
|
+
<Text>Creating chat...</Text>
|
|
39
|
+
)}
|
|
40
|
+
</View>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function Conversation({ id }: { id: string }) {
|
|
45
|
+
const conversation = useChat(id, {
|
|
46
|
+
system: 'You suggest practical, concise native Mac app ideas.',
|
|
47
|
+
})
|
|
48
|
+
const [prompt, setPrompt] = useState('Suggest one useful native Mac app.')
|
|
49
|
+
const latestAssistant = conversation.messages.findLast(
|
|
50
|
+
(message) => message.role === 'assistant',
|
|
51
|
+
)
|
|
52
|
+
const retryable =
|
|
53
|
+
latestAssistant?.status === 'failed' ||
|
|
54
|
+
latestAssistant?.status === 'canceled'
|
|
55
|
+
? latestAssistant
|
|
56
|
+
: null
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View style={sx('gap-4')}>
|
|
60
|
+
<TextInput
|
|
61
|
+
value={prompt}
|
|
62
|
+
onChangeText={setPrompt}
|
|
63
|
+
style={sx('rounded-xl', 'border', 'border-separator', 'p-4')}
|
|
64
|
+
/>
|
|
65
|
+
<View style={sx('flex-row', 'gap-3')}>
|
|
66
|
+
<Button
|
|
67
|
+
label="Send"
|
|
68
|
+
loading={conversation.isGenerating}
|
|
69
|
+
disabled={!conversation.canSend}
|
|
70
|
+
onPress={() => void conversation.send(prompt)}
|
|
71
|
+
/>
|
|
72
|
+
<Button
|
|
73
|
+
label="Cancel"
|
|
74
|
+
variant="secondary"
|
|
75
|
+
disabled={!conversation.canCancel}
|
|
76
|
+
onPress={() => void conversation.cancel()}
|
|
77
|
+
/>
|
|
78
|
+
{retryable ? (
|
|
79
|
+
<Button
|
|
80
|
+
label="Retry"
|
|
81
|
+
variant="secondary"
|
|
82
|
+
onPress={() => void conversation.retry(retryable.id)}
|
|
83
|
+
/>
|
|
84
|
+
) : null}
|
|
85
|
+
</View>
|
|
86
|
+
{conversation.messages.map((message) => (
|
|
87
|
+
<Text key={message.id} style={sx('text-lg', 'text-label')}>
|
|
88
|
+
{message.role === 'user' ? 'You: ' : 'Assistant: '}
|
|
89
|
+
{message.content || message.status}
|
|
90
|
+
</Text>
|
|
91
|
+
))}
|
|
30
92
|
</View>
|
|
31
93
|
)
|
|
32
94
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { bonsai,
|
|
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'
|
|
@@ -15,7 +15,7 @@ export default function App() {
|
|
|
15
15
|
async function create() {
|
|
16
16
|
setStatus('Generating...')
|
|
17
17
|
try {
|
|
18
|
-
const result = await
|
|
18
|
+
const result = await image.generate({
|
|
19
19
|
model,
|
|
20
20
|
prompt: 'A precise editorial illustration of a small native Mac app',
|
|
21
21
|
aspectRatio: '1:1',
|
|
@@ -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
|
}
|