bleam 0.0.5 → 0.0.6

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 (113) hide show
  1. package/dist/ai.cjs +187 -0
  2. package/dist/ai.d.cts +52 -0
  3. package/dist/ai.d.ts +52 -0
  4. package/dist/ai.js +182 -0
  5. package/dist/animated.cjs +286 -0
  6. package/dist/animated.d.cts +47 -0
  7. package/dist/animated.d.ts +47 -0
  8. package/dist/animated.js +281 -0
  9. package/dist/app.d.cts +1 -2
  10. package/dist/app.d.ts +1 -2
  11. package/dist/app.js +1 -2
  12. package/dist/bundler.d.cts +1 -2
  13. package/dist/bundler.d.ts +1 -2
  14. package/dist/chrome.cjs +265 -0
  15. package/dist/chrome.d.cts +19 -0
  16. package/dist/chrome.d.ts +19 -0
  17. package/dist/chrome.js +262 -0
  18. package/dist/cli.cjs +768 -31
  19. package/dist/cli.js +767 -34
  20. package/dist/config-Bb6SULnR.cjs +46 -0
  21. package/dist/config-CfWa3q-k.js +28 -0
  22. package/dist/config-ClDGHNb3.d.ts +39 -0
  23. package/dist/config-D3gPaVMb.d.cts +39 -0
  24. package/dist/config.cjs +4 -25
  25. package/dist/config.d.cts +2 -28
  26. package/dist/config.d.ts +2 -28
  27. package/dist/config.js +2 -24
  28. package/dist/crypto-BB92-Upx.js +7 -0
  29. package/dist/crypto-CT3VZ7lF.cjs +13 -0
  30. package/dist/crypto.cjs +2 -2
  31. package/dist/crypto.d.cts +8 -1
  32. package/dist/crypto.d.ts +8 -1
  33. package/dist/crypto.js +2 -2
  34. package/dist/dev-protocol.d.cts +3 -3
  35. package/dist/dev-protocol.d.ts +3 -3
  36. package/dist/dev-protocol.js +1 -2
  37. package/dist/fs.cjs +12 -2
  38. package/dist/fs.d.cts +7 -1
  39. package/dist/fs.d.ts +7 -1
  40. package/dist/fs.js +10 -1
  41. package/dist/index.cjs +4 -5
  42. package/dist/index.d.cts +2 -3
  43. package/dist/index.d.ts +2 -3
  44. package/dist/index.js +2 -4
  45. package/dist/native-macos-D6p2SmUj.js +20 -0
  46. package/dist/native-macos-DLwo_ii9.cjs +31 -0
  47. package/dist/native-runtime-C85Nuc4F.js +10 -0
  48. package/dist/native-runtime-CbPzrs8j.d.cts +33 -0
  49. package/dist/{native-runtime-CdeT0JyQ.cjs → native-runtime-CsXnXkQn.cjs} +1 -14
  50. package/dist/native-runtime-DxHSrsTX.d.ts +33 -0
  51. package/dist/native.cjs +35 -32
  52. package/dist/native.d.cts +4 -34
  53. package/dist/native.d.ts +3 -33
  54. package/dist/native.js +36 -34
  55. package/dist/runtime.d.cts +1 -2
  56. package/dist/runtime.d.ts +1 -2
  57. package/dist/schema-BOuUHcqo.d.cts +58 -0
  58. package/dist/schema-DVmoD9JL.js +90 -0
  59. package/dist/schema-bxeeCyLn.cjs +102 -0
  60. package/dist/schema-ipsECAso.d.ts +58 -0
  61. package/dist/schema.cjs +4 -0
  62. package/dist/schema.d.cts +2 -0
  63. package/dist/schema.d.ts +2 -0
  64. package/dist/schema.js +3 -0
  65. package/dist/state.cjs +765 -0
  66. package/dist/state.d.cts +129 -0
  67. package/dist/state.d.ts +129 -0
  68. package/dist/state.js +747 -0
  69. package/dist/styles.cjs +742 -0
  70. package/dist/styles.d.cts +701 -0
  71. package/dist/styles.d.ts +701 -0
  72. package/dist/styles.js +739 -0
  73. package/dist/ui.cjs +113 -0
  74. package/dist/ui.d.cts +30 -0
  75. package/dist/ui.d.ts +30 -0
  76. package/dist/ui.js +110 -0
  77. package/metro-config.cjs +18 -13
  78. package/package.json +47 -13
  79. package/templates/basic/app/index.tsx +130 -12
  80. package/templates/basic/app.config.ts +4 -2
  81. package/dist/app.d.cts.map +0 -1
  82. package/dist/app.d.ts.map +0 -1
  83. package/dist/app.js.map +0 -1
  84. package/dist/bundler.d.cts.map +0 -1
  85. package/dist/bundler.d.ts.map +0 -1
  86. package/dist/cli.js.map +0 -1
  87. package/dist/config.d.cts.map +0 -1
  88. package/dist/config.d.ts.map +0 -1
  89. package/dist/config.js.map +0 -1
  90. package/dist/crypto-BNhWeXMj.cjs +0 -15
  91. package/dist/crypto-Bg8cD8wX.d.cts +0 -8
  92. package/dist/crypto-Bg8cD8wX.d.cts.map +0 -1
  93. package/dist/crypto-CCA_hvao.js +0 -11
  94. package/dist/crypto-CCA_hvao.js.map +0 -1
  95. package/dist/crypto-IOzbNoJD.d.ts +0 -8
  96. package/dist/crypto-IOzbNoJD.d.ts.map +0 -1
  97. package/dist/dev-protocol.d.cts.map +0 -1
  98. package/dist/dev-protocol.d.ts.map +0 -1
  99. package/dist/dev-protocol.js.map +0 -1
  100. package/dist/fs-BK7joD1g.js +0 -13
  101. package/dist/fs-BK7joD1g.js.map +0 -1
  102. package/dist/fs-CEhcjuN6.d.ts +0 -9
  103. package/dist/fs-CEhcjuN6.d.ts.map +0 -1
  104. package/dist/fs-CfE8CHf_.d.cts +0 -9
  105. package/dist/fs-CfE8CHf_.d.cts.map +0 -1
  106. package/dist/fs-DKHYTPua.cjs +0 -18
  107. package/dist/native-runtime-BoqybBBf.js +0 -18
  108. package/dist/native-runtime-BoqybBBf.js.map +0 -1
  109. package/dist/native.d.cts.map +0 -1
  110. package/dist/native.d.ts.map +0 -1
  111. package/dist/native.js.map +0 -1
  112. package/dist/runtime.d.cts.map +0 -1
  113. package/dist/runtime.d.ts.map +0 -1
@@ -0,0 +1,286 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ let react = require("react");
3
+ react = require_chunk.__toESM(react);
4
+ let react_native = require("react-native");
5
+ react_native = require_chunk.__toESM(react_native);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
8
+
9
+ //#region src/animated.tsx
10
+ const isDev = process.env.NODE_ENV !== "production";
11
+ const transitionProperties = [
12
+ "opacity",
13
+ "scale",
14
+ "translateX",
15
+ "translateY",
16
+ "width",
17
+ "height"
18
+ ];
19
+ const spacing = {
20
+ "0": 0,
21
+ "1": 4,
22
+ "2": 8,
23
+ "4": 16
24
+ };
25
+ const durations = {
26
+ "75": 75,
27
+ "100": 100,
28
+ "150": 150,
29
+ "200": 200,
30
+ "300": 300,
31
+ "500": 500
32
+ };
33
+ const delays = {
34
+ "0": 0,
35
+ "75": 75,
36
+ "100": 100,
37
+ "150": 150,
38
+ "200": 200
39
+ };
40
+ function transitionStyle() {
41
+ return {
42
+ __bleamTransition: true,
43
+ targets: {}
44
+ };
45
+ }
46
+ function isTransitionStyle(input) {
47
+ return typeof input === "object" && input !== null && "__bleamTransition" in input && input.__bleamTransition === true;
48
+ }
49
+ function isTransitionObject(input) {
50
+ return typeof input === "object" && input !== null && !isTransitionStyle(input);
51
+ }
52
+ function assignTarget(style, property, value) {
53
+ style.targets[property] = value;
54
+ }
55
+ function parseToken(token, style) {
56
+ const opacityMatch = token.match(/^opacity-(\d+)$/);
57
+ if (opacityMatch) {
58
+ assignTarget(style, "opacity", Number(opacityMatch[1]) / 100);
59
+ return true;
60
+ }
61
+ const scaleMatch = token.match(/^scale-(\d+)$/);
62
+ if (scaleMatch) {
63
+ assignTarget(style, "scale", Number(scaleMatch[1]) / 100);
64
+ return true;
65
+ }
66
+ const translateMatch = token.match(/^translate-([xy])-(.+)$/);
67
+ if (translateMatch) {
68
+ const amount = spacing[translateMatch[2] ?? ""];
69
+ if (amount === void 0) return false;
70
+ assignTarget(style, translateMatch[1] === "x" ? "translateX" : "translateY", amount);
71
+ return true;
72
+ }
73
+ const durationMatch = token.match(/^duration-(\d+)$/);
74
+ if (durationMatch) {
75
+ const duration = durations[durationMatch[1] ?? ""];
76
+ if (duration === void 0) return false;
77
+ style.duration = duration;
78
+ return true;
79
+ }
80
+ const delayMatch = token.match(/^delay-(\d+)$/);
81
+ if (delayMatch) {
82
+ const delay = delays[delayMatch[1] ?? ""];
83
+ if (delay === void 0) return false;
84
+ style.delay = delay;
85
+ return true;
86
+ }
87
+ if (token === "ease-linear") {
88
+ style.easing = "linear";
89
+ return true;
90
+ }
91
+ if (token === "ease-in") {
92
+ style.easing = "in";
93
+ return true;
94
+ }
95
+ if (token === "ease-out") {
96
+ style.easing = "out";
97
+ return true;
98
+ }
99
+ if (token === "ease-in-out") {
100
+ style.easing = "in-out";
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+ function pushObject(input, style) {
106
+ for (const property of transitionProperties) {
107
+ const value = input[property];
108
+ if (typeof value === "number") assignTarget(style, property, value);
109
+ }
110
+ if (Array.isArray(input.transform)) for (const transform of input.transform) {
111
+ if ("scale" in transform) assignTarget(style, "scale", transform.scale);
112
+ if ("translateX" in transform) assignTarget(style, "translateX", transform.translateX);
113
+ if ("translateY" in transform) assignTarget(style, "translateY", transform.translateY);
114
+ }
115
+ style.duration = input.duration ?? input.transitionDuration ?? style.duration;
116
+ style.delay = input.delay ?? input.transitionDelay ?? style.delay;
117
+ style.easing = input.easing ?? style.easing;
118
+ }
119
+ function pushInput(input, style) {
120
+ if (!input) return;
121
+ if (isTransitionStyle(input)) {
122
+ Object.assign(style.targets, input.targets);
123
+ style.duration = input.duration ?? style.duration;
124
+ style.delay = input.delay ?? style.delay;
125
+ style.easing = input.easing ?? style.easing;
126
+ return;
127
+ }
128
+ if (isTransitionObject(input)) {
129
+ pushObject(input, style);
130
+ return;
131
+ }
132
+ if (/\s/.test(input)) {
133
+ if (isDev) throw new Error(`Bleam transition strings must contain exactly one token: ${input}`);
134
+ return;
135
+ }
136
+ if (parseToken(input, style)) return;
137
+ if (isDev) throw new Error(`Unknown bleam transition token: ${input}`);
138
+ }
139
+ function tx(...inputs) {
140
+ const style = transitionStyle();
141
+ for (const input of inputs) pushInput(input, style);
142
+ return style;
143
+ }
144
+ function easingFunction(easing) {
145
+ if (easing === "linear") return react_native.Easing.linear;
146
+ if (easing === "in") return react_native.Easing.in(react_native.Easing.cubic);
147
+ if (easing === "in-out") return react_native.Easing.inOut(react_native.Easing.cubic);
148
+ return react_native.Easing.out(react_native.Easing.cubic);
149
+ }
150
+ function splitStyles(style) {
151
+ const styles = Array.isArray(style) ? style : [style];
152
+ const hostStyles = [];
153
+ let transition;
154
+ for (const item of styles) {
155
+ if (!item) continue;
156
+ if (isTransitionStyle(item)) {
157
+ transition = transition ? tx(transition, item) : item;
158
+ continue;
159
+ }
160
+ hostStyles.push(item);
161
+ }
162
+ return {
163
+ hostStyles,
164
+ transition
165
+ };
166
+ }
167
+ function useAnimatedTransition(transition) {
168
+ const state = (0, react.useRef)({
169
+ values: /* @__PURE__ */ new Map(),
170
+ targets: /* @__PURE__ */ new Map(),
171
+ animations: /* @__PURE__ */ new Map()
172
+ }).current;
173
+ const targets = transition?.targets ?? {};
174
+ const heightTarget = targets.height;
175
+ const opacityTarget = targets.opacity;
176
+ const scaleTarget = targets.scale;
177
+ const translateXTarget = targets.translateX;
178
+ const translateYTarget = targets.translateY;
179
+ const widthTarget = targets.width;
180
+ const duration = transition?.duration ?? 200;
181
+ const delay = transition?.delay ?? 0;
182
+ const easing = easingFunction(transition?.easing);
183
+ for (const property of transitionProperties) {
184
+ const target = targets[property];
185
+ if (typeof target !== "number") continue;
186
+ if (!state.values.has(property)) state.values.set(property, new react_native.Animated.Value(target));
187
+ }
188
+ (0, react.useEffect)(() => {
189
+ const nextTargets = {
190
+ height: heightTarget,
191
+ opacity: opacityTarget,
192
+ scale: scaleTarget,
193
+ translateX: translateXTarget,
194
+ translateY: translateYTarget,
195
+ width: widthTarget
196
+ };
197
+ for (const property of transitionProperties) {
198
+ const target = nextTargets[property];
199
+ if (typeof target !== "number") continue;
200
+ const previousTarget = state.targets.get(property);
201
+ if (previousTarget === void 0) {
202
+ state.targets.set(property, target);
203
+ continue;
204
+ }
205
+ if (previousTarget === target) continue;
206
+ state.animations.get(property)?.stop();
207
+ const value = state.values.get(property);
208
+ if (!value) continue;
209
+ const animation = react_native.Animated.timing(value, {
210
+ toValue: target,
211
+ duration,
212
+ delay,
213
+ easing,
214
+ isInteraction: false,
215
+ useNativeDriver: true
216
+ });
217
+ state.animations.set(property, animation);
218
+ state.targets.set(property, target);
219
+ animation.start(({ finished }) => {
220
+ if (finished && state.animations.get(property) === animation) state.animations.delete(property);
221
+ });
222
+ }
223
+ }, [
224
+ delay,
225
+ duration,
226
+ easing,
227
+ heightTarget,
228
+ opacityTarget,
229
+ scaleTarget,
230
+ state,
231
+ translateXTarget,
232
+ translateYTarget,
233
+ widthTarget
234
+ ]);
235
+ (0, react.useEffect)(() => {
236
+ return () => {
237
+ state.animations.forEach((animation) => {
238
+ animation.stop();
239
+ });
240
+ state.animations.clear();
241
+ };
242
+ }, [state]);
243
+ if (!transition) return;
244
+ const animatedStyle = {};
245
+ const transform = [];
246
+ const opacity = state.values.get("opacity");
247
+ if (opacity) animatedStyle.opacity = opacity;
248
+ const width = state.values.get("width");
249
+ if (width) animatedStyle.width = width;
250
+ const height = state.values.get("height");
251
+ if (height) animatedStyle.height = height;
252
+ const scale = state.values.get("scale");
253
+ if (scale) transform.push({ scale });
254
+ const translateX = state.values.get("translateX");
255
+ if (translateX) transform.push({ translateX });
256
+ const translateY = state.values.get("translateY");
257
+ if (translateY) transform.push({ translateY });
258
+ if (transform.length > 0) animatedStyle.transform = transform;
259
+ return animatedStyle;
260
+ }
261
+ const AnimatedView = (0, react.forwardRef)(function AnimatedView$1({ style,...props }, ref) {
262
+ const { hostStyles, transition } = splitStyles(style);
263
+ const animatedStyle = useAnimatedTransition(transition);
264
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Animated.View, {
265
+ ref,
266
+ style: [...hostStyles, animatedStyle],
267
+ ...props
268
+ });
269
+ });
270
+ const AnimatedText = (0, react.forwardRef)(function AnimatedText$1({ style,...props }, ref) {
271
+ const { hostStyles, transition } = splitStyles(style);
272
+ const animatedStyle = useAnimatedTransition(transition);
273
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Animated.Text, {
274
+ ref,
275
+ style: [...hostStyles, animatedStyle],
276
+ ...props
277
+ });
278
+ });
279
+ const Animated = {
280
+ View: AnimatedView,
281
+ Text: AnimatedText
282
+ };
283
+
284
+ //#endregion
285
+ exports.Animated = Animated;
286
+ exports.tx = tx;
@@ -0,0 +1,47 @@
1
+ import * as react0 from "react";
2
+ import { Text, TextProps, TextStyle, View, ViewProps, ViewStyle } from "react-native";
3
+
4
+ //#region src/animated.d.ts
5
+ type TransitionProperty = 'opacity' | 'scale' | 'translateX' | 'translateY' | 'width' | 'height';
6
+ type TransitionTransform = {
7
+ scale: number;
8
+ } | {
9
+ translateX: number;
10
+ } | {
11
+ translateY: number;
12
+ };
13
+ type TransitionObject = {
14
+ opacity?: number;
15
+ scale?: number;
16
+ translateX?: number;
17
+ translateY?: number;
18
+ width?: number;
19
+ height?: number;
20
+ transform?: TransitionTransform[];
21
+ duration?: number;
22
+ delay?: number;
23
+ easing?: TransitionEasing;
24
+ transitionDuration?: number;
25
+ transitionDelay?: number;
26
+ };
27
+ type TransitionEasing = 'linear' | 'in' | 'out' | 'in-out';
28
+ type TransitionInput = string | TransitionStyle | TransitionObject | false | null | undefined;
29
+ type TransitionStyle = {
30
+ readonly __bleamTransition: true;
31
+ targets: Partial<Record<TransitionProperty, number>>;
32
+ duration?: number;
33
+ delay?: number;
34
+ easing?: TransitionEasing;
35
+ };
36
+ type AnimatedHostStyle = ViewStyle | TextStyle | TransitionStyle | false | null | undefined;
37
+ declare function tx(...inputs: TransitionInput[]): TransitionStyle;
38
+ declare const Animated: {
39
+ View: react0.ForwardRefExoticComponent<Omit<ViewProps, "style"> & {
40
+ style?: AnimatedHostStyle | AnimatedHostStyle[];
41
+ } & react0.RefAttributes<View>>;
42
+ Text: react0.ForwardRefExoticComponent<Omit<TextProps, "style"> & {
43
+ style?: AnimatedHostStyle | AnimatedHostStyle[];
44
+ } & react0.RefAttributes<Text>>;
45
+ };
46
+ //#endregion
47
+ export { Animated, TransitionStyle, tx };
@@ -0,0 +1,47 @@
1
+ import * as react0 from "react";
2
+ import { Text, TextProps, TextStyle, View, ViewProps, ViewStyle } from "react-native";
3
+
4
+ //#region src/animated.d.ts
5
+ type TransitionProperty = 'opacity' | 'scale' | 'translateX' | 'translateY' | 'width' | 'height';
6
+ type TransitionTransform = {
7
+ scale: number;
8
+ } | {
9
+ translateX: number;
10
+ } | {
11
+ translateY: number;
12
+ };
13
+ type TransitionObject = {
14
+ opacity?: number;
15
+ scale?: number;
16
+ translateX?: number;
17
+ translateY?: number;
18
+ width?: number;
19
+ height?: number;
20
+ transform?: TransitionTransform[];
21
+ duration?: number;
22
+ delay?: number;
23
+ easing?: TransitionEasing;
24
+ transitionDuration?: number;
25
+ transitionDelay?: number;
26
+ };
27
+ type TransitionEasing = 'linear' | 'in' | 'out' | 'in-out';
28
+ type TransitionInput = string | TransitionStyle | TransitionObject | false | null | undefined;
29
+ type TransitionStyle = {
30
+ readonly __bleamTransition: true;
31
+ targets: Partial<Record<TransitionProperty, number>>;
32
+ duration?: number;
33
+ delay?: number;
34
+ easing?: TransitionEasing;
35
+ };
36
+ type AnimatedHostStyle = ViewStyle | TextStyle | TransitionStyle | false | null | undefined;
37
+ declare function tx(...inputs: TransitionInput[]): TransitionStyle;
38
+ declare const Animated: {
39
+ View: react0.ForwardRefExoticComponent<Omit<ViewProps, "style"> & {
40
+ style?: AnimatedHostStyle | AnimatedHostStyle[];
41
+ } & react0.RefAttributes<View>>;
42
+ Text: react0.ForwardRefExoticComponent<Omit<TextProps, "style"> & {
43
+ style?: AnimatedHostStyle | AnimatedHostStyle[];
44
+ } & react0.RefAttributes<Text>>;
45
+ };
46
+ //#endregion
47
+ export { Animated, TransitionStyle, tx };
@@ -0,0 +1,281 @@
1
+ import { forwardRef, useEffect, useRef } from "react";
2
+ import { Animated as Animated$1, Easing } from "react-native";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/animated.tsx
6
+ const isDev = process.env.NODE_ENV !== "production";
7
+ const transitionProperties = [
8
+ "opacity",
9
+ "scale",
10
+ "translateX",
11
+ "translateY",
12
+ "width",
13
+ "height"
14
+ ];
15
+ const spacing = {
16
+ "0": 0,
17
+ "1": 4,
18
+ "2": 8,
19
+ "4": 16
20
+ };
21
+ const durations = {
22
+ "75": 75,
23
+ "100": 100,
24
+ "150": 150,
25
+ "200": 200,
26
+ "300": 300,
27
+ "500": 500
28
+ };
29
+ const delays = {
30
+ "0": 0,
31
+ "75": 75,
32
+ "100": 100,
33
+ "150": 150,
34
+ "200": 200
35
+ };
36
+ function transitionStyle() {
37
+ return {
38
+ __bleamTransition: true,
39
+ targets: {}
40
+ };
41
+ }
42
+ function isTransitionStyle(input) {
43
+ return typeof input === "object" && input !== null && "__bleamTransition" in input && input.__bleamTransition === true;
44
+ }
45
+ function isTransitionObject(input) {
46
+ return typeof input === "object" && input !== null && !isTransitionStyle(input);
47
+ }
48
+ function assignTarget(style, property, value) {
49
+ style.targets[property] = value;
50
+ }
51
+ function parseToken(token, style) {
52
+ const opacityMatch = token.match(/^opacity-(\d+)$/);
53
+ if (opacityMatch) {
54
+ assignTarget(style, "opacity", Number(opacityMatch[1]) / 100);
55
+ return true;
56
+ }
57
+ const scaleMatch = token.match(/^scale-(\d+)$/);
58
+ if (scaleMatch) {
59
+ assignTarget(style, "scale", Number(scaleMatch[1]) / 100);
60
+ return true;
61
+ }
62
+ const translateMatch = token.match(/^translate-([xy])-(.+)$/);
63
+ if (translateMatch) {
64
+ const amount = spacing[translateMatch[2] ?? ""];
65
+ if (amount === void 0) return false;
66
+ assignTarget(style, translateMatch[1] === "x" ? "translateX" : "translateY", amount);
67
+ return true;
68
+ }
69
+ const durationMatch = token.match(/^duration-(\d+)$/);
70
+ if (durationMatch) {
71
+ const duration = durations[durationMatch[1] ?? ""];
72
+ if (duration === void 0) return false;
73
+ style.duration = duration;
74
+ return true;
75
+ }
76
+ const delayMatch = token.match(/^delay-(\d+)$/);
77
+ if (delayMatch) {
78
+ const delay = delays[delayMatch[1] ?? ""];
79
+ if (delay === void 0) return false;
80
+ style.delay = delay;
81
+ return true;
82
+ }
83
+ if (token === "ease-linear") {
84
+ style.easing = "linear";
85
+ return true;
86
+ }
87
+ if (token === "ease-in") {
88
+ style.easing = "in";
89
+ return true;
90
+ }
91
+ if (token === "ease-out") {
92
+ style.easing = "out";
93
+ return true;
94
+ }
95
+ if (token === "ease-in-out") {
96
+ style.easing = "in-out";
97
+ return true;
98
+ }
99
+ return false;
100
+ }
101
+ function pushObject(input, style) {
102
+ for (const property of transitionProperties) {
103
+ const value = input[property];
104
+ if (typeof value === "number") assignTarget(style, property, value);
105
+ }
106
+ if (Array.isArray(input.transform)) for (const transform of input.transform) {
107
+ if ("scale" in transform) assignTarget(style, "scale", transform.scale);
108
+ if ("translateX" in transform) assignTarget(style, "translateX", transform.translateX);
109
+ if ("translateY" in transform) assignTarget(style, "translateY", transform.translateY);
110
+ }
111
+ style.duration = input.duration ?? input.transitionDuration ?? style.duration;
112
+ style.delay = input.delay ?? input.transitionDelay ?? style.delay;
113
+ style.easing = input.easing ?? style.easing;
114
+ }
115
+ function pushInput(input, style) {
116
+ if (!input) return;
117
+ if (isTransitionStyle(input)) {
118
+ Object.assign(style.targets, input.targets);
119
+ style.duration = input.duration ?? style.duration;
120
+ style.delay = input.delay ?? style.delay;
121
+ style.easing = input.easing ?? style.easing;
122
+ return;
123
+ }
124
+ if (isTransitionObject(input)) {
125
+ pushObject(input, style);
126
+ return;
127
+ }
128
+ if (/\s/.test(input)) {
129
+ if (isDev) throw new Error(`Bleam transition strings must contain exactly one token: ${input}`);
130
+ return;
131
+ }
132
+ if (parseToken(input, style)) return;
133
+ if (isDev) throw new Error(`Unknown bleam transition token: ${input}`);
134
+ }
135
+ function tx(...inputs) {
136
+ const style = transitionStyle();
137
+ for (const input of inputs) pushInput(input, style);
138
+ return style;
139
+ }
140
+ function easingFunction(easing) {
141
+ if (easing === "linear") return Easing.linear;
142
+ if (easing === "in") return Easing.in(Easing.cubic);
143
+ if (easing === "in-out") return Easing.inOut(Easing.cubic);
144
+ return Easing.out(Easing.cubic);
145
+ }
146
+ function splitStyles(style) {
147
+ const styles = Array.isArray(style) ? style : [style];
148
+ const hostStyles = [];
149
+ let transition;
150
+ for (const item of styles) {
151
+ if (!item) continue;
152
+ if (isTransitionStyle(item)) {
153
+ transition = transition ? tx(transition, item) : item;
154
+ continue;
155
+ }
156
+ hostStyles.push(item);
157
+ }
158
+ return {
159
+ hostStyles,
160
+ transition
161
+ };
162
+ }
163
+ function useAnimatedTransition(transition) {
164
+ const state = useRef({
165
+ values: /* @__PURE__ */ new Map(),
166
+ targets: /* @__PURE__ */ new Map(),
167
+ animations: /* @__PURE__ */ new Map()
168
+ }).current;
169
+ const targets = transition?.targets ?? {};
170
+ const heightTarget = targets.height;
171
+ const opacityTarget = targets.opacity;
172
+ const scaleTarget = targets.scale;
173
+ const translateXTarget = targets.translateX;
174
+ const translateYTarget = targets.translateY;
175
+ const widthTarget = targets.width;
176
+ const duration = transition?.duration ?? 200;
177
+ const delay = transition?.delay ?? 0;
178
+ const easing = easingFunction(transition?.easing);
179
+ for (const property of transitionProperties) {
180
+ const target = targets[property];
181
+ if (typeof target !== "number") continue;
182
+ if (!state.values.has(property)) state.values.set(property, new Animated$1.Value(target));
183
+ }
184
+ useEffect(() => {
185
+ const nextTargets = {
186
+ height: heightTarget,
187
+ opacity: opacityTarget,
188
+ scale: scaleTarget,
189
+ translateX: translateXTarget,
190
+ translateY: translateYTarget,
191
+ width: widthTarget
192
+ };
193
+ for (const property of transitionProperties) {
194
+ const target = nextTargets[property];
195
+ if (typeof target !== "number") continue;
196
+ const previousTarget = state.targets.get(property);
197
+ if (previousTarget === void 0) {
198
+ state.targets.set(property, target);
199
+ continue;
200
+ }
201
+ if (previousTarget === target) continue;
202
+ state.animations.get(property)?.stop();
203
+ const value = state.values.get(property);
204
+ if (!value) continue;
205
+ const animation = Animated$1.timing(value, {
206
+ toValue: target,
207
+ duration,
208
+ delay,
209
+ easing,
210
+ isInteraction: false,
211
+ useNativeDriver: true
212
+ });
213
+ state.animations.set(property, animation);
214
+ state.targets.set(property, target);
215
+ animation.start(({ finished }) => {
216
+ if (finished && state.animations.get(property) === animation) state.animations.delete(property);
217
+ });
218
+ }
219
+ }, [
220
+ delay,
221
+ duration,
222
+ easing,
223
+ heightTarget,
224
+ opacityTarget,
225
+ scaleTarget,
226
+ state,
227
+ translateXTarget,
228
+ translateYTarget,
229
+ widthTarget
230
+ ]);
231
+ useEffect(() => {
232
+ return () => {
233
+ state.animations.forEach((animation) => {
234
+ animation.stop();
235
+ });
236
+ state.animations.clear();
237
+ };
238
+ }, [state]);
239
+ if (!transition) return;
240
+ const animatedStyle = {};
241
+ const transform = [];
242
+ const opacity = state.values.get("opacity");
243
+ if (opacity) animatedStyle.opacity = opacity;
244
+ const width = state.values.get("width");
245
+ if (width) animatedStyle.width = width;
246
+ const height = state.values.get("height");
247
+ if (height) animatedStyle.height = height;
248
+ const scale = state.values.get("scale");
249
+ if (scale) transform.push({ scale });
250
+ const translateX = state.values.get("translateX");
251
+ if (translateX) transform.push({ translateX });
252
+ const translateY = state.values.get("translateY");
253
+ if (translateY) transform.push({ translateY });
254
+ if (transform.length > 0) animatedStyle.transform = transform;
255
+ return animatedStyle;
256
+ }
257
+ const AnimatedView = forwardRef(function AnimatedView$1({ style,...props }, ref) {
258
+ const { hostStyles, transition } = splitStyles(style);
259
+ const animatedStyle = useAnimatedTransition(transition);
260
+ return /* @__PURE__ */ jsx(Animated$1.View, {
261
+ ref,
262
+ style: [...hostStyles, animatedStyle],
263
+ ...props
264
+ });
265
+ });
266
+ const AnimatedText = forwardRef(function AnimatedText$1({ style,...props }, ref) {
267
+ const { hostStyles, transition } = splitStyles(style);
268
+ const animatedStyle = useAnimatedTransition(transition);
269
+ return /* @__PURE__ */ jsx(Animated$1.Text, {
270
+ ref,
271
+ style: [...hostStyles, animatedStyle],
272
+ ...props
273
+ });
274
+ });
275
+ const Animated = {
276
+ View: AnimatedView,
277
+ Text: AnimatedText
278
+ };
279
+
280
+ //#endregion
281
+ export { Animated, tx };
package/dist/app.d.cts CHANGED
@@ -3,5 +3,4 @@ import { ComponentType } from "react";
3
3
  //#region src/app.d.ts
4
4
  declare function registerApp(component: ComponentType): void;
5
5
  //#endregion
6
- export { registerApp };
7
- //# sourceMappingURL=app.d.cts.map
6
+ export { registerApp };
package/dist/app.d.ts CHANGED
@@ -3,5 +3,4 @@ import { ComponentType } from "react";
3
3
  //#region src/app.d.ts
4
4
  declare function registerApp(component: ComponentType): void;
5
5
  //#endregion
6
- export { registerApp };
7
- //# sourceMappingURL=app.d.ts.map
6
+ export { registerApp };
package/dist/app.js CHANGED
@@ -6,5 +6,4 @@ function registerApp(component) {
6
6
  }
7
7
 
8
8
  //#endregion
9
- export { registerApp };
10
- //# sourceMappingURL=app.js.map
9
+ export { registerApp };
@@ -24,5 +24,4 @@ interface Bundler {
24
24
  bundle(options: BundleOptions): Promise<BundleResult>;
25
25
  }
26
26
  //#endregion
27
- export { BundleOptions, BundleResult, Bundler, DevServer, DevServerHandle, DevServerOptions };
28
- //# sourceMappingURL=bundler.d.cts.map
27
+ export { BundleOptions, BundleResult, Bundler, DevServer, DevServerHandle, DevServerOptions };
package/dist/bundler.d.ts CHANGED
@@ -24,5 +24,4 @@ interface Bundler {
24
24
  bundle(options: BundleOptions): Promise<BundleResult>;
25
25
  }
26
26
  //#endregion
27
- export { BundleOptions, BundleResult, Bundler, DevServer, DevServerHandle, DevServerOptions };
28
- //# sourceMappingURL=bundler.d.ts.map
27
+ export { BundleOptions, BundleResult, Bundler, DevServer, DevServerHandle, DevServerOptions };