bleam 0.0.11 → 0.0.12

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 (51) hide show
  1. package/dist/ai.cjs +2314 -2173
  2. package/dist/ai.d.cts +227 -322
  3. package/dist/ai.d.ts +227 -322
  4. package/dist/ai.js +2309 -2159
  5. package/dist/cli.d.cts +1 -1
  6. package/dist/cli.d.ts +1 -1
  7. package/dist/config.d.cts +1 -1
  8. package/dist/config.d.ts +1 -1
  9. package/dist/{files-Ds1wT8C2.js → files-BXVkPrPN.js} +6 -1
  10. package/dist/{files-Bo7h9fik.cjs → files-DxaQ-Nv0.cjs} +11 -0
  11. package/dist/files.cjs +1 -1
  12. package/dist/files.d.cts +1 -1
  13. package/dist/files.d.ts +1 -1
  14. package/dist/files.js +1 -1
  15. package/dist/index.d.cts +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/schema-B5BfdswF.js +226 -0
  18. package/dist/schema-BnVZOXfu.cjs +286 -0
  19. package/dist/schema-D5eImHxu.d.cts +125 -0
  20. package/dist/schema-SSjokbtw.d.ts +125 -0
  21. package/dist/schema.cjs +10 -2
  22. package/dist/schema.d.cts +2 -2
  23. package/dist/schema.d.ts +2 -2
  24. package/dist/schema.js +2 -2
  25. package/dist/state-Dh3HLixb.js +874 -0
  26. package/dist/state-LssDgpff.cjs +973 -0
  27. package/dist/state.cjs +16 -12
  28. package/dist/state.d.cts +144 -140
  29. package/dist/state.d.ts +145 -140
  30. package/dist/state.js +3 -3
  31. package/dist/{ui-CHc4xEs_.d.ts → ui-D7bRLYee.d.ts} +7 -7
  32. package/dist/ui.d.ts +1 -1
  33. package/dist/window.d.ts +1 -1
  34. package/package.json +3 -1
  35. package/templates/foundation-models/app/index.tsx +77 -15
  36. package/templates/image-generation/app/index.tsx +2 -2
  37. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +46 -46
  38. package/templates/native/ios/Podfile.lock +173 -173
  39. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +35 -357
  40. package/templates/text-generation/app/index.tsx +81 -50
  41. package/templates/updates/README.md +1 -1
  42. package/dist/schema-Bo5Jvqus.js +0 -90
  43. package/dist/schema-CYh6n8GS.d.ts +0 -58
  44. package/dist/schema-oeOrd3i1.d.cts +0 -58
  45. package/dist/schema-rQ13mrpD.cjs +0 -102
  46. package/dist/state-Bx0VlTlO.cjs +0 -852
  47. package/dist/state-CAwe-Vw1.js +0 -767
  48. /package/dist/{config-Cms0rvqg.d.ts → config-COcRnn5a.d.cts} +0 -0
  49. /package/dist/{config-CufOVJV3.d.cts → config-Chi-flpJ.d.ts} +0 -0
  50. /package/dist/{files-4ZEoAWiv.d.ts → files-DwA7pzr3.d.cts} +0 -0
  51. /package/dist/{files-Dt5mbzLq.d.cts → files-VrkQlKIT.d.ts} +0 -0
package/dist/state.d.ts CHANGED
@@ -1,159 +1,164 @@
1
- import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-CYh6n8GS.js";
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-SSjokbtw.js";
2
+ import "jotai/vanilla";
2
3
 
3
4
  //#region src/state/atom.d.ts
4
- type Listener = () => void;
5
- interface Store<Value> {
6
- get(): Value;
7
- subscribe(listener: Listener): () => void;
5
+ declare const atomValue: unique symbol;
6
+ declare const atomWrite: unique symbol;
7
+ interface Atom<Value> {
8
+ readonly [atomValue]: Value;
8
9
  }
9
- interface WritableStore<Value> extends Store<Value> {
10
- set(value: Value): void;
11
- update(updater: (value: Value) => Value): void;
12
- }
13
- declare class LiveStore<Value> implements WritableStore<Value> {
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 Atom<Value> = WritableStore<Value>;
23
- type SetStoreValue<Value> = (value: Value | ((current: Value) => Value)) => void;
24
- declare function atom<Value>(initialValue: Value): Atom<Value>;
25
- declare function useStore<Value>(store: Store<Value>): Value;
26
- declare function useAtom<Value>(value: Atom<Value>): readonly [Value, SetStoreValue<Value>];
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
- type FieldRecord = Record<string, FieldValue | undefined>;
30
- type CollectionFields<Shape extends SchemaShape> = SchemaOutput<Shape>;
31
- type CollectionInput<Shape extends SchemaShape> = SchemaInput<Shape>;
32
- type CollectionData<Shape extends SchemaShape> = CollectionFields<Shape>;
33
- type CollectionFieldKey<Shape extends SchemaShape> = Extract<keyof Shape, string>;
34
- type CollectionFieldValue<Shape extends SchemaShape, Key extends CollectionFieldKey<Shape>> = Key extends keyof CollectionData<Shape> ? CollectionData<Shape>[Key] : undefined;
35
- type Entry<Value> = {
36
- value: Value | undefined;
37
- error: unknown;
38
- promise: Promise<unknown> | null;
39
- version: number;
40
- listeners: Set<Listener>;
41
- };
42
- type RawCollectionView = {
43
- id: string;
44
- collection: string;
45
- createdAt: string;
46
- updatedAt: string;
47
- data: FieldRecord;
48
- links: Record<string, string[]>;
49
- };
50
- type RecordEntry = Entry<RawCollectionView | null>;
51
- type ListEntry = Entry<string[]> & {
52
- dependencies: ListDependencies;
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
- type ViewOptions = {
59
- links?: CollectionReference[];
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 ListWhereValue = FieldValue | ['equals' | 'greater-than' | 'less-than' | 'contains', FieldValue] | Array<['equals' | 'greater-than' | 'less-than' | 'contains', FieldValue]>;
62
- type ListOptions<Shape extends SchemaShape> = {
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 NormalizedListOptions = {
69
- where?: Record<string, Array<[string, FieldValue]>>;
70
- sortBy?: string;
71
- order?: 'asc' | 'desc';
72
- take?: number;
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 RecordChange = {
75
- collection: string;
76
- id: string;
77
- previous: RawCollectionView | null;
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
- right: {
88
- collection: string;
89
- id: string;
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 ListDependencies = {
93
- collection: string;
94
- paths: Set<string>;
95
- options: NormalizedListOptions;
95
+ type QueryTerminal<Shape extends SchemaShape, Result$1> = {
96
+ readonly plan: QueryPlan;
97
+ readonly result?: Result$1;
98
+ readonly shape?: Shape;
96
99
  };
97
- type CollectionView<Shape extends SchemaShape> = {
98
- readonly id: string;
99
- readonly collection: string;
100
- readonly createdAt: string;
101
- readonly updatedAt: string;
102
- readonly data: CollectionData<Shape>;
103
- readonly links: Record<string, string[]>;
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
- declare class Collection<Shape extends SchemaShape> {
106
- readonly name: string;
107
- readonly shape: Shape;
108
- readonly validator: BleamSchema<SchemaInput<Shape>, SchemaOutput<Shape>>;
109
- private records;
110
- private lists;
111
- private fields;
112
- constructor(name: string, shape: Shape);
113
- validateListOptions(options?: ListOptions<Shape>): void;
114
- getRecordEntry(id: string): RecordEntry;
115
- getListEntry(options?: ListOptions<Shape>): ListEntry;
116
- private getFieldEntry;
117
- private notifyFields;
118
- private setRecordValue;
119
- private rawRecord;
120
- private loadRecord;
121
- private loadListRows;
122
- private selectListRows;
123
- private applyListOptions;
124
- private refreshListEntry;
125
- invalidateChanges(recordChanges: RecordChange[], edgeChanges?: EdgeChange[]): Promise<void>;
126
- private refreshLoadedLinks;
127
- private peekRecord;
128
- insert(value: CollectionInput<Shape>): Promise<string>;
129
- update(id: string, value: Partial<CollectionInput<Shape>>): Promise<void>;
130
- delete(id: string): Promise<void>;
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
- declare function collection<Shape extends SchemaShape>(name: string, shape: Shape): Collection<Shape>;
146
- declare function link<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
147
- declare function unlink<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<void>;
148
- declare function isLinked<FirstShape extends SchemaShape, SecondShape extends SchemaShape>(firstCollection: Collection<FirstShape>, firstId: string, secondCollection: Collection<SecondShape>, secondId: string): Promise<boolean>;
149
- declare function useList<Shape extends SchemaShape>(collection: Collection<Shape>, options?: ListOptions<Shape>): string[];
150
- declare function useView<Shape extends SchemaShape>(collection: Collection<Shape>, id: string, options?: ViewOptions): CollectionView<Shape> | null | undefined;
151
- declare function useField<Shape extends SchemaShape, Key extends CollectionFieldKey<Shape>>(collection: Collection<Shape>, id: string, key: Key): CollectionFieldValue<Shape, Key> | undefined;
152
- //#endregion
153
- //#region src/state/setting.d.ts
154
- type Setting<Value> = WritableStore<Value>;
155
- type SetSettingValue<Value> = SetStoreValue<Value>;
156
- declare function setting<Value extends string | number | boolean>(key: string, initialValue: Value): Setting<Value>;
157
- declare function useSetting<Value>(value: Setting<Value>): readonly [Value, SetStoreValue<Value>];
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, Collection, CollectionView, ListOptions, Listener, LiveStore, SetSettingValue, SetStoreValue, Setting, Store, WritableStore, atom, collection, isLinked, link, setting, unlink, useAtom, useField, useList, useSetting, useStore, useView };
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,6 @@
1
1
  import "./native-runtime-C85Nuc4F.js";
2
2
  import "./crypto-BB92-Upx.js";
3
- import { a as isLinked, c as useField, d as LiveStore, f as atom, i as collection, l as useList, m as useStore, n as useSetting, o as link, p as useAtom, r as Collection, s as unlink, t as setting, u as useView } from "./state-CAwe-Vw1.js";
4
- import "./schema-Bo5Jvqus.js";
3
+ import { c as object, n as array, o as literal, r as boolean, s as number, u as string } from "./schema-B5BfdswF.js";
4
+ 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-Dh3HLixb.js";
5
5
 
6
- export { Collection, LiveStore, atom, collection, isLinked, link, setting, unlink, useAtom, useField, useList, useSetting, useStore, useView };
6
+ export { CollectionVersionConflictError, array, atom, atomCollection, boolean, literal, mutateAtom, number, object, queryAtom, string, transactionAtom, useAtom, useAtomValue, useField, useList, useRow, useSetAtom };
@@ -1,4 +1,4 @@
1
- import * as _nativescript_react_native25 from "@nativescript/react-native";
1
+ import * as _nativescript_react_native30 from "@nativescript/react-native";
2
2
  import { ReactNode } from "react";
3
3
  import { ColorValue, StyleProp, TextStyle, ViewStyle } from "react-native";
4
4
 
@@ -18,7 +18,7 @@ type ButtonProps = {
18
18
  onPress?: () => void;
19
19
  style?: StyleProp<NativeStyle>;
20
20
  };
21
- declare const Button: _nativescript_react_native25.UIKitViewComponent<ButtonProps, UIButton>;
21
+ declare const Button: _nativescript_react_native30.UIKitViewComponent<ButtonProps, UIButton>;
22
22
  //#endregion
23
23
  //#region src/ui/label.d.ts
24
24
  type LabelTone = 'primary' | 'secondary' | 'tertiary';
@@ -29,7 +29,7 @@ type LabelProps = {
29
29
  numberOfLines?: number;
30
30
  style?: StyleProp<NativeStyle>;
31
31
  };
32
- declare const Label: _nativescript_react_native25.UIKitViewComponent<LabelProps, UILabel>;
32
+ declare const Label: _nativescript_react_native30.UIKitViewComponent<LabelProps, UILabel>;
33
33
  //#endregion
34
34
  //#region src/ui/symbol.d.ts
35
35
  type SymbolName = string;
@@ -43,7 +43,7 @@ type SymbolProps = {
43
43
  color?: ColorValue;
44
44
  style?: StyleProp<NativeStyle>;
45
45
  };
46
- declare const Symbol: _nativescript_react_native25.UIKitViewComponent<SymbolProps, UIImageView>;
46
+ declare const Symbol: _nativescript_react_native30.UIKitViewComponent<SymbolProps, UIImageView>;
47
47
  //#endregion
48
48
  //#region src/ui/glass-shared.d.ts
49
49
  type GlassStyle = 'regular' | 'clear' | 'none';
@@ -73,10 +73,10 @@ type GlassContainerProps = {
73
73
  };
74
74
  //#endregion
75
75
  //#region src/ui/glass-view.d.ts
76
- declare const GlassView: _nativescript_react_native25.UIKitViewComponent<GlassViewProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
76
+ declare const GlassView: _nativescript_react_native30.UIKitViewComponent<GlassViewProps, _nativescript_react_native30.UIKitContainerResult<UIVisualEffectView, UIView>>;
77
77
  //#endregion
78
78
  //#region src/ui/glass-container.d.ts
79
- declare const GlassContainer: _nativescript_react_native25.UIKitViewComponent<GlassContainerProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
79
+ declare const GlassContainer: _nativescript_react_native30.UIKitViewComponent<GlassContainerProps, _nativescript_react_native30.UIKitContainerResult<UIVisualEffectView, UIView>>;
80
80
  //#endregion
81
81
  //#region src/ui/blur-view.d.ts
82
82
  type BlurIntensity = 'ultraThin' | 'thin' | 'regular' | 'thick' | 'chrome';
@@ -87,6 +87,6 @@ type BlurViewProps = {
87
87
  intensity?: BlurIntensity;
88
88
  colorScheme?: BlurColorScheme;
89
89
  };
90
- declare const BlurView: _nativescript_react_native25.UIKitViewComponent<BlurViewProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
90
+ declare const BlurView: _nativescript_react_native30.UIKitViewComponent<BlurViewProps, _nativescript_react_native30.UIKitContainerResult<UIVisualEffectView, UIView>>;
91
91
  //#endregion
92
92
  export { ButtonVariant as C, ButtonSize as S, Label as _, GlassContainer as a, Button as b, GlassEffectStyleConfig as c, GlassVisualStyle as d, Symbol as f, SymbolWeight as g, SymbolScale as h, BlurViewProps as i, GlassStyle as l, SymbolProps as m, BlurIntensity as n, GlassView as o, SymbolName as p, BlurView as r, GlassContainerProps as s, BlurColorScheme as t, GlassViewProps as u, LabelProps as v, ButtonProps as x, LabelTone as y };
package/dist/ui.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-CHc4xEs_.js";
1
+ import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-D7bRLYee.js";
2
2
  export { BlurColorScheme, BlurIntensity, BlurView, BlurViewProps, Button, ButtonProps, ButtonSize, ButtonVariant, GlassContainer, GlassContainerProps, GlassEffectStyleConfig, GlassStyle, GlassView, GlassViewProps, GlassVisualStyle, Label, LabelProps, LabelTone, Symbol, SymbolName, SymbolProps, SymbolScale, SymbolWeight };
package/dist/window.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { p as SymbolName } from "./ui-CHc4xEs_.js";
1
+ import { p as SymbolName } from "./ui-D7bRLYee.js";
2
2
  import * as react3 from "react";
3
3
  import { ComponentType } from "react";
4
4
  import { StyleProp, ViewStyle } from "react-native";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bleam",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
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",
@@ -1,32 +1,94 @@
1
- import { generate } from 'bleam/ai'
1
+ import { chat, useChat, useChatList } from 'bleam/ai'
2
2
  import { sx } from 'bleam/styles'
3
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 [answer, setAnswer] = useState('Ask the on-device model for an idea.')
11
+ const chats = useChatList()
12
+ const creating = useRef(false)
13
+ const [error, setError] = useState('')
12
14
 
13
- async function ask() {
14
- setAnswer('Thinking...')
15
- try {
16
- setAnswer(
17
- await generate({ prompt: 'Suggest one useful native Mac app.' }),
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
- } catch (error) {
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-lg', 'text-secondary-label')}>{answer}</Text>
29
- <Button title="Generate an idea" onPress={ask} />
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
+ title="Send"
68
+ loading={conversation.isGenerating}
69
+ disabled={!conversation.canSend}
70
+ onPress={() => void conversation.send(prompt)}
71
+ />
72
+ <Button
73
+ title="Cancel"
74
+ variant="secondary"
75
+ disabled={!conversation.canCancel}
76
+ onPress={() => void conversation.cancel()}
77
+ />
78
+ {retryable ? (
79
+ <Button
80
+ title="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,4 +1,4 @@
1
- import { bonsai, generateImage } from 'bleam/ai'
1
+ import { bonsai, image } from 'bleam/ai'
2
2
  import { sx } from 'bleam/styles'
3
3
  import { Button } from 'bleam/ui'
4
4
  import { Window } from 'bleam/window'
@@ -15,7 +15,7 @@ export default function App() {
15
15
  async function create() {
16
16
  setStatus('Generating...')
17
17
  try {
18
- const result = await generateImage({
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',