bleam 0.0.12 → 0.0.14

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 (57) hide show
  1. package/dist/ai.cjs +5 -4
  2. package/dist/ai.js +4 -3
  3. package/dist/app-storage-D8W4n8ey.cjs +39 -0
  4. package/dist/app-storage-Isi5Bo0R.js +34 -0
  5. package/dist/cli.cjs +149 -23
  6. package/dist/cli.d.cts +13 -0
  7. package/dist/cli.d.ts +13 -0
  8. package/dist/cli.js +149 -23
  9. package/dist/elements-DX_YUveu.d.ts +341 -0
  10. package/dist/elements-gEI8YGl1.d.cts +341 -0
  11. package/dist/elements.cjs +1031 -0
  12. package/dist/elements.d.cts +2 -0
  13. package/dist/elements.d.ts +2 -0
  14. package/dist/elements.js +999 -0
  15. package/dist/{files-BXVkPrPN.js → files-DErLhzCB.js} +5 -11
  16. package/dist/{files-DxaQ-Nv0.cjs → files-lMk-CpL_.cjs} +5 -11
  17. package/dist/files.cjs +1 -1
  18. package/dist/files.js +1 -1
  19. package/dist/schema.cjs +1 -1
  20. package/dist/schema.d.cts +1 -1
  21. package/dist/schema.d.ts +1 -1
  22. package/dist/schema.js +1 -1
  23. package/dist/secrets.cjs +146 -0
  24. package/dist/secrets.d.cts +14 -0
  25. package/dist/secrets.d.ts +14 -0
  26. package/dist/secrets.js +142 -0
  27. package/dist/{state-LssDgpff.cjs → state-Bm9GiRnU.cjs} +61 -47
  28. package/dist/{state-Dh3HLixb.js → state-D8Firo9w.js} +60 -41
  29. package/dist/state.cjs +3 -2
  30. package/dist/state.d.cts +1 -1
  31. package/dist/state.d.ts +1 -1
  32. package/dist/state.js +3 -2
  33. package/dist/window.d.cts +1 -1
  34. package/dist/window.d.ts +1 -1
  35. package/package.json +14 -11
  36. package/templates/basic/app/index.tsx +7 -129
  37. package/templates/foundation-models/app/index.tsx +100 -41
  38. package/templates/image-generation/app/index.tsx +2 -2
  39. package/templates/native/ios/Podfile.lock +6 -0
  40. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +7 -8
  41. package/templates/native/package.json +6 -1
  42. package/templates/native/yarn.lock +5392 -3749
  43. package/templates/state/app/index.tsx +2 -2
  44. package/templates/text-generation/app/index.tsx +4 -4
  45. package/templates/updates/README.md +1 -1
  46. package/dist/native-sqlite-xcGdamRD.js +0 -64
  47. package/dist/native-sqlite-yQLD5s9i.cjs +0 -66
  48. package/dist/ui-1WepaMS4.d.cts +0 -92
  49. package/dist/ui-D7bRLYee.d.ts +0 -92
  50. package/dist/ui.cjs +0 -364
  51. package/dist/ui.d.cts +0 -2
  52. package/dist/ui.d.ts +0 -2
  53. package/dist/ui.js +0 -357
  54. /package/dist/{schema-B5BfdswF.js → schema-B7ELMpuI.js} +0 -0
  55. /package/dist/{schema-BnVZOXfu.cjs → schema-B7SLUBLN.cjs} +0 -0
  56. /package/dist/{schema-D5eImHxu.d.cts → schema-BWsDPc6c.d.cts} +0 -0
  57. /package/dist/{schema-SSjokbtw.d.ts → schema-DsXZBnvc.d.ts} +0 -0
package/dist/ui.js DELETED
@@ -1,357 +0,0 @@
1
- import { t as ensureNativeScript } from "./native-runtime-C85Nuc4F.js";
2
- import { StyleSheet, processColor } from "react-native";
3
-
4
- //#region src/ui/shared.ts
5
- function textFromChildren(children) {
6
- if (typeof children === "string" || typeof children === "number") return String(children);
7
- if (Array.isArray(children)) return children.filter((child) => typeof child === "string" || typeof child === "number").join("");
8
- }
9
- function styleFromProps(style) {
10
- return StyleSheet.flatten(style);
11
- }
12
- function colorFromHex(hex) {
13
- const value = hex.trim().replace(/^#/, "");
14
- const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
15
- if (!/^[\da-f]{6}$/i.test(normalized)) return;
16
- const number = Number.parseInt(normalized, 16);
17
- const red = (number >> 16 & 255) / 255;
18
- const green = (number >> 8 & 255) / 255;
19
- const blue = (number & 255) / 255;
20
- return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, 1);
21
- }
22
- function colorFromStyle(value) {
23
- if (value == null) return;
24
- if (typeof value === "string") {
25
- const hexColor = colorFromHex(value);
26
- if (hexColor) return hexColor;
27
- }
28
- const color = processColor(value);
29
- if (typeof color !== "number") return;
30
- const alpha = (color >>> 24 & 255) / 255;
31
- const red = (color >>> 16 & 255) / 255;
32
- const green = (color >>> 8 & 255) / 255;
33
- const blue = (color & 255) / 255;
34
- return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, alpha);
35
- }
36
- function fontFromStyle(style) {
37
- if (typeof style?.fontSize !== "number") return;
38
- if (style.fontWeight === "700" || style.fontWeight === "bold") return UIFont.boldSystemFontOfSize(style.fontSize);
39
- return UIFont.systemFontOfSize(style.fontSize);
40
- }
41
-
42
- //#endregion
43
- //#region src/ui/button.tsx
44
- function buttonTitle(props) {
45
- return props.title ?? textFromChildren(props.children) ?? "";
46
- }
47
- function buttonConfiguration(variant) {
48
- if (variant === "secondary") return UIButtonConfiguration.borderedButtonConfiguration();
49
- if (variant === "plain") return UIButtonConfiguration.plainButtonConfiguration();
50
- return UIButtonConfiguration.borderedProminentButtonConfiguration();
51
- }
52
- function buttonSize(size) {
53
- if (size === "small") return UIButtonConfigurationSize.Small;
54
- if (size === "large") return UIButtonConfigurationSize.Large;
55
- return UIButtonConfigurationSize.Medium;
56
- }
57
- const Button = ensureNativeScript().defineUIKitView({
58
- name: "Button",
59
- layout: {
60
- sizing: "intrinsic",
61
- defaultSize: {
62
- width: 1,
63
- height: 34
64
- }
65
- },
66
- create(ctx) {
67
- const button = UIButton.buttonWithType(UIButtonType.System);
68
- ctx.targetAction(button, UIControlEvents.TouchUpInside, () => {
69
- ctx.emit("onPress");
70
- });
71
- return button;
72
- },
73
- update(button, props, _previousProps, ctx) {
74
- const style = styleFromProps(props.style);
75
- const configuration = buttonConfiguration(props.variant);
76
- configuration.title = buttonTitle(props);
77
- configuration.buttonSize = buttonSize(props.size);
78
- configuration.showsActivityIndicator = props.loading ?? false;
79
- const foregroundColor = colorFromStyle(style?.color);
80
- if (foregroundColor) configuration.baseForegroundColor = foregroundColor;
81
- const backgroundColor = colorFromStyle(style?.backgroundColor);
82
- if (backgroundColor) configuration.baseBackgroundColor = backgroundColor;
83
- button.configuration = configuration;
84
- button.enabled = !(props.disabled || props.loading);
85
- ctx?.invalidateLayout();
86
- }
87
- });
88
-
89
- //#endregion
90
- //#region src/ui/label.tsx
91
- function labelText(props) {
92
- return props.text ?? textFromChildren(props.children) ?? "";
93
- }
94
- function defaultLabelColor(tone) {
95
- if (tone === "secondary") return UIColor.secondaryLabelColor;
96
- if (tone === "tertiary") return UIColor.tertiaryLabelColor;
97
- return UIColor.labelColor;
98
- }
99
- const Label = ensureNativeScript().defineUIKitView({
100
- name: "Label",
101
- layout: {
102
- sizing: "intrinsic",
103
- defaultSize: {
104
- width: 1,
105
- height: 24
106
- }
107
- },
108
- create() {
109
- const label = UILabel.new();
110
- label.adjustsFontForContentSizeCategory = true;
111
- return label;
112
- },
113
- update(label, props, _previousProps, ctx) {
114
- const style = styleFromProps(props.style);
115
- label.text = labelText(props);
116
- label.textColor = colorFromStyle(style?.color) ?? defaultLabelColor(props.tone);
117
- label.font = fontFromStyle(style) ?? UIFont.preferredFontForTextStyle(UIFontTextStyleBody);
118
- label.numberOfLines = props.numberOfLines ?? 0;
119
- if (style?.textAlign === "center") label.textAlignment = NSTextAlignment.Center;
120
- else if (style?.textAlign === "right") label.textAlignment = NSTextAlignment.Right;
121
- else label.textAlignment = NSTextAlignment.Left;
122
- ctx?.invalidateLayout();
123
- }
124
- });
125
-
126
- //#endregion
127
- //#region src/ui/symbol.tsx
128
- function symbolWeight(weight) {
129
- switch (weight) {
130
- case "ultraLight": return UIImageSymbolWeight.UltraLight;
131
- case "thin": return UIImageSymbolWeight.Thin;
132
- case "light": return UIImageSymbolWeight.Light;
133
- case "medium": return UIImageSymbolWeight.Medium;
134
- case "semibold": return UIImageSymbolWeight.Semibold;
135
- case "bold": return UIImageSymbolWeight.Bold;
136
- case "heavy": return UIImageSymbolWeight.Heavy;
137
- case "black": return UIImageSymbolWeight.Black;
138
- default: return UIImageSymbolWeight.Regular;
139
- }
140
- }
141
- function symbolScale(scale) {
142
- if (scale === "small") return UIImageSymbolScale.Small;
143
- if (scale === "large") return UIImageSymbolScale.Large;
144
- return UIImageSymbolScale.Medium;
145
- }
146
- function symbolConfiguration(props, style) {
147
- const size = props.size ?? style?.fontSize ?? 17;
148
- return UIImageSymbolConfiguration.configurationWithPointSizeWeightScale(size, symbolWeight(props.weight), symbolScale(props.scale));
149
- }
150
- function symbolImage(name, configuration) {
151
- if (configuration) return UIImage.systemImageNamedWithConfiguration(name, configuration);
152
- return UIImage.systemImageNamed(name);
153
- }
154
- const Symbol = ensureNativeScript().defineUIKitView({
155
- name: "Symbol",
156
- layout: {
157
- sizing: "intrinsic",
158
- defaultSize: {
159
- width: 17,
160
- height: 17
161
- }
162
- },
163
- create() {
164
- const imageView = UIImageView.new();
165
- imageView.contentMode = UIViewContentMode.ScaleAspectFit;
166
- return imageView;
167
- },
168
- update(imageView, props, _previousProps, ctx) {
169
- const style = styleFromProps(props.style);
170
- const configuration = symbolConfiguration(props, style);
171
- imageView.image = symbolImage(props.symbol, configuration);
172
- imageView.tintColor = colorFromStyle(props.color) ?? colorFromStyle(style?.tintColor) ?? colorFromStyle(style?.color) ?? UIColor.labelColor;
173
- ctx?.invalidateLayout();
174
- }
175
- });
176
-
177
- //#endregion
178
- //#region src/ui/glass-shared.ts
179
- function glassStyleValue(style) {
180
- return typeof style === "object" ? style.style : style ?? "regular";
181
- }
182
- function glassEffect(style) {
183
- if (style === "none") return null;
184
- return UIGlassEffect.effectWithStyle(style === "clear" ? UIGlassEffectStyle.Clear : UIGlassEffectStyle.Regular);
185
- }
186
- function createGlassHost(effect) {
187
- const rootView = UIVisualEffectView.alloc().initWithEffect(effect);
188
- const childrenView = UIView.new();
189
- rootView.backgroundColor = UIColor.clearColor;
190
- rootView.contentView.backgroundColor = UIColor.clearColor;
191
- childrenView.backgroundColor = UIColor.clearColor;
192
- rootView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
193
- rootView.contentView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
194
- childrenView.translatesAutoresizingMaskIntoConstraints = false;
195
- rootView.contentView.addSubview(childrenView);
196
- const constraints = {
197
- top: childrenView.topAnchor.constraintEqualToAnchorConstant(rootView.contentView.topAnchor, 0),
198
- right: rootView.contentView.rightAnchor.constraintEqualToAnchorConstant(childrenView.rightAnchor, 0),
199
- bottom: rootView.contentView.bottomAnchor.constraintEqualToAnchorConstant(childrenView.bottomAnchor, 0),
200
- left: childrenView.leftAnchor.constraintEqualToAnchorConstant(rootView.contentView.leftAnchor, 0)
201
- };
202
- NSLayoutConstraint.activateConstraints([
203
- constraints.top,
204
- constraints.right,
205
- constraints.bottom,
206
- constraints.left
207
- ]);
208
- return {
209
- rootView,
210
- childrenView
211
- };
212
- }
213
- function applyGlassShape(view, style) {
214
- const radius = typeof style?.cornerRadius === "number" ? style.cornerRadius : 0;
215
- view.layer.cornerRadius = radius;
216
- view.contentView.layer.cornerRadius = radius;
217
- view.layer.cornerCurve = kCACornerCurveContinuous;
218
- view.contentView.layer.cornerCurve = kCACornerCurveContinuous;
219
- view.clipsToBounds = radius > 0;
220
- view.contentView.clipsToBounds = radius > 0;
221
- view.layer.masksToBounds = radius > 0;
222
- view.contentView.layer.masksToBounds = radius > 0;
223
- view.layer.borderWidth = typeof style?.borderWidth === "number" ? style.borderWidth : 0;
224
- const borderColor = colorFromStyle(style?.borderColor);
225
- view.layer.borderColor = borderColor?.CGColor ?? null;
226
- }
227
- function updateGlassEffect(view, props) {
228
- const style = glassStyleValue(props.glassEffectStyle);
229
- const effect = glassEffect(style);
230
- if (style !== "none") {
231
- const tintColor = props.tintColor ? colorFromHex(props.tintColor) : void 0;
232
- const glass = effect;
233
- glass.interactive = props.isInteractive ?? false;
234
- if (tintColor) glass.tintColor = tintColor;
235
- }
236
- if (typeof props.glassEffectStyle === "object" && props.glassEffectStyle.animate) UIView.animateWithDurationAnimations(props.glassEffectStyle.animationDuration ?? .35, () => {
237
- view.effect = effect;
238
- });
239
- else view.effect = effect;
240
- }
241
- function updateGlassContainerEffect(view, spacing) {
242
- const effect = UIGlassContainerEffect.new();
243
- effect.spacing = spacing ?? 0;
244
- view.effect = effect;
245
- }
246
-
247
- //#endregion
248
- //#region src/ui/glass-view.tsx
249
- const GlassView = ensureNativeScript().defineUIKitContainer({
250
- name: "GlassView",
251
- layout: {
252
- sizing: "fill",
253
- defaultSize: {
254
- width: 0,
255
- height: 0
256
- }
257
- },
258
- create() {
259
- return createGlassHost(glassEffect("regular"));
260
- },
261
- update(view, props, _previousProps, ctx) {
262
- updateGlassEffect(view.rootView, props);
263
- applyGlassShape(view.rootView, props.glassStyle);
264
- ctx?.invalidateLayout();
265
- }
266
- });
267
-
268
- //#endregion
269
- //#region src/ui/glass-container.tsx
270
- const GlassContainer = ensureNativeScript().defineUIKitContainer({
271
- name: "GlassContainer",
272
- layout: {
273
- sizing: "fill",
274
- defaultSize: {
275
- width: 0,
276
- height: 0
277
- }
278
- },
279
- create() {
280
- const host = createGlassHost(UIGlassContainerEffect.new());
281
- updateGlassContainerEffect(host.rootView, void 0);
282
- return host;
283
- },
284
- update(view, props, _previousProps, ctx) {
285
- updateGlassContainerEffect(view.rootView, props.spacing);
286
- applyGlassShape(view.rootView, props.glassStyle);
287
- ctx?.invalidateLayout();
288
- }
289
- });
290
-
291
- //#endregion
292
- //#region src/ui/blur-view.tsx
293
- function blurStyle(intensity, colorScheme) {
294
- const scheme = colorScheme ?? "auto";
295
- const level = intensity ?? "regular";
296
- if (scheme === "light") switch (level) {
297
- case "ultraThin": return UIBlurEffectStyle.SystemUltraThinMaterialLight;
298
- case "thin": return UIBlurEffectStyle.SystemThinMaterialLight;
299
- case "thick": return UIBlurEffectStyle.SystemThickMaterialLight;
300
- case "chrome": return UIBlurEffectStyle.SystemChromeMaterialLight;
301
- default: return UIBlurEffectStyle.SystemMaterialLight;
302
- }
303
- if (scheme === "dark") switch (level) {
304
- case "ultraThin": return UIBlurEffectStyle.SystemUltraThinMaterialDark;
305
- case "thin": return UIBlurEffectStyle.SystemThinMaterialDark;
306
- case "thick": return UIBlurEffectStyle.SystemThickMaterialDark;
307
- case "chrome": return UIBlurEffectStyle.SystemChromeMaterialDark;
308
- default: return UIBlurEffectStyle.SystemMaterialDark;
309
- }
310
- switch (level) {
311
- case "ultraThin": return UIBlurEffectStyle.SystemUltraThinMaterial;
312
- case "thin": return UIBlurEffectStyle.SystemThinMaterial;
313
- case "thick": return UIBlurEffectStyle.SystemThickMaterial;
314
- case "chrome": return UIBlurEffectStyle.SystemChromeMaterial;
315
- default: return UIBlurEffectStyle.SystemMaterial;
316
- }
317
- }
318
- function createEffectHost(effect) {
319
- const rootView = UIVisualEffectView.alloc().initWithEffect(effect);
320
- rootView.backgroundColor = UIColor.clearColor;
321
- rootView.contentView.backgroundColor = UIColor.clearColor;
322
- rootView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
323
- rootView.contentView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
324
- return {
325
- rootView,
326
- childrenView: rootView.contentView
327
- };
328
- }
329
- function applyContainerStyle(view, style) {
330
- const borderRadius = style?.borderRadius;
331
- if (typeof borderRadius === "number") view.layer.cornerRadius = borderRadius;
332
- view.clipsToBounds = style?.overflow === "hidden" || typeof borderRadius === "number";
333
- }
334
- function updateBlurEffect(view, props) {
335
- view.effect = UIBlurEffect.effectWithStyle(blurStyle(props.intensity, props.colorScheme));
336
- }
337
- const BlurView = ensureNativeScript().defineUIKitContainer({
338
- name: "BlurView",
339
- layout: {
340
- sizing: "fill",
341
- defaultSize: {
342
- width: 0,
343
- height: 0
344
- }
345
- },
346
- create() {
347
- return createEffectHost(UIBlurEffect.effectWithStyle(UIBlurEffectStyle.SystemMaterial));
348
- },
349
- update(view, props, _previousProps, ctx) {
350
- updateBlurEffect(view.rootView, props);
351
- applyContainerStyle(view.rootView, styleFromProps(props.style));
352
- ctx?.invalidateLayout();
353
- }
354
- });
355
-
356
- //#endregion
357
- export { BlurView, Button, GlassContainer, GlassView, Label, Symbol };
File without changes