zelune 1.5.4 → 1.5.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.
- package/CHANGELOG.md +26 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/plugins/viteReactNativeFallbackPlugin.ts +13 -53
- package/src/canvas/CanvasApp.tsx +165 -57
- package/src/canvas/FlowArrowsLayer.tsx +2 -2
- package/src/canvas/ScreenArtboard.tsx +17 -3
- package/src/main.tsx +1 -0
- package/src/runtime/MockNavigationContext.tsx +577 -56
- package/src/runtime/nativewindShim.ts +972 -0
- package/src/runtime/reactNativeShim.ts +99 -0
- package/vite.config.ts +58 -0
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ScrollView as RNScrollView,
|
|
12
12
|
FlatList as RNFlatList,
|
|
13
13
|
} from 'react-native';
|
|
14
|
+
import { withNativeWind } from './nativewindShim';
|
|
14
15
|
|
|
15
16
|
export interface NavigationController {
|
|
16
17
|
navigate: (targetRoute: string, params?: Record<string, unknown>) => void;
|
|
@@ -128,13 +129,17 @@ export function useRoute(): { key: string; name: string; params: Record<string,
|
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
export function useFocusEffect(effect: () => void | (() => void)): void {
|
|
132
|
+
const ctx = useContext(MockNavigationContext);
|
|
133
|
+
const effectRef = useRef(effect);
|
|
134
|
+
effectRef.current = effect;
|
|
131
135
|
useEffect(() => {
|
|
132
136
|
try {
|
|
133
|
-
|
|
137
|
+
const cleanup = effectRef.current();
|
|
138
|
+
return typeof cleanup === 'function' ? cleanup : undefined;
|
|
134
139
|
} catch {
|
|
135
140
|
return undefined;
|
|
136
141
|
}
|
|
137
|
-
}, [
|
|
142
|
+
}, [ctx.currentRoute]);
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
export function useIsFocused(): boolean {
|
|
@@ -242,7 +247,7 @@ export function usePathname(): string {
|
|
|
242
247
|
|
|
243
248
|
export function useSegments(): string[] {
|
|
244
249
|
const ctx = useContext(MockNavigationContext);
|
|
245
|
-
return [ctx.currentRoute.toLowerCase()];
|
|
250
|
+
return useMemo(() => [ctx.currentRoute.toLowerCase()], [ctx.currentRoute]);
|
|
246
251
|
}
|
|
247
252
|
|
|
248
253
|
export function useRootNavigationState() {
|
|
@@ -287,16 +292,26 @@ export const SplashScreen = {
|
|
|
287
292
|
// ============================================================================
|
|
288
293
|
// 3. React Native Safe Area Context Shims (react-native-safe-area-context)
|
|
289
294
|
// ============================================================================
|
|
290
|
-
export const SafeAreaProvider: React.FC<{
|
|
291
|
-
children
|
|
292
|
-
style
|
|
293
|
-
|
|
295
|
+
export const SafeAreaProvider: React.FC<{
|
|
296
|
+
children?: React.ReactNode;
|
|
297
|
+
style?: unknown;
|
|
298
|
+
className?: string;
|
|
299
|
+
}> = ({ children, style, className, ...rest }) => (
|
|
300
|
+
<View className={className as never} style={[{ flex: 1 }, style as never]} {...rest}>
|
|
301
|
+
{children}
|
|
302
|
+
</View>
|
|
303
|
+
);
|
|
294
304
|
|
|
295
305
|
export const SafeAreaView: React.FC<{
|
|
296
306
|
children?: React.ReactNode;
|
|
297
307
|
style?: unknown;
|
|
308
|
+
className?: string;
|
|
298
309
|
edges?: string[];
|
|
299
|
-
}> = ({ children, style
|
|
310
|
+
}> = ({ children, style, className, edges: _edges, ...rest }) => (
|
|
311
|
+
<View className={className as never} style={[{ flex: 1 }, style as never]} {...rest}>
|
|
312
|
+
{children}
|
|
313
|
+
</View>
|
|
314
|
+
);
|
|
300
315
|
|
|
301
316
|
export function useSafeAreaInsets(): { top: number; right: number; bottom: number; left: number } {
|
|
302
317
|
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
@@ -474,16 +489,27 @@ export function createIconSetFromFontello() {
|
|
|
474
489
|
// 6. Expo Linear Gradient, Blur, Image & FlashList Shims
|
|
475
490
|
// ============================================================================
|
|
476
491
|
export const LinearGradient: React.FC<{
|
|
477
|
-
colors?: string[];
|
|
478
|
-
locations?: number[];
|
|
492
|
+
colors?: readonly string[] | string[];
|
|
493
|
+
locations?: readonly number[] | number[];
|
|
479
494
|
start?: { x: number; y: number } | [number, number];
|
|
480
495
|
end?: { x: number; y: number } | [number, number];
|
|
481
496
|
style?: unknown;
|
|
497
|
+
className?: string;
|
|
482
498
|
children?: React.ReactNode;
|
|
483
|
-
}> = ({
|
|
499
|
+
}> = ({
|
|
500
|
+
colors = ['#1E293B', '#0F172A'],
|
|
501
|
+
locations: _locations,
|
|
502
|
+
start: _start,
|
|
503
|
+
end: _end,
|
|
504
|
+
style,
|
|
505
|
+
className,
|
|
506
|
+
children,
|
|
507
|
+
...rest
|
|
508
|
+
}) => {
|
|
484
509
|
const safeColors = Array.isArray(colors) && colors.length >= 2 ? colors : ['#1E293B', '#0F172A'];
|
|
485
510
|
return (
|
|
486
511
|
<View
|
|
512
|
+
className={className as never}
|
|
487
513
|
style={[
|
|
488
514
|
{
|
|
489
515
|
backgroundColor: safeColors[0],
|
|
@@ -491,6 +517,7 @@ export const LinearGradient: React.FC<{
|
|
|
491
517
|
} as never,
|
|
492
518
|
style as never,
|
|
493
519
|
]}
|
|
520
|
+
{...rest}
|
|
494
521
|
>
|
|
495
522
|
{children}
|
|
496
523
|
</View>
|
|
@@ -501,11 +528,13 @@ export const BlurView: React.FC<{
|
|
|
501
528
|
intensity?: number;
|
|
502
529
|
tint?: string;
|
|
503
530
|
style?: unknown;
|
|
531
|
+
className?: string;
|
|
504
532
|
children?: React.ReactNode;
|
|
505
|
-
}> = ({ intensity = 40, tint = 'dark', style, children }) => {
|
|
533
|
+
}> = ({ intensity = 40, tint = 'dark', style, className, children, ...rest }) => {
|
|
506
534
|
const bg = tint === 'light' ? 'rgba(255, 255, 255, 0.65)' : 'rgba(15, 23, 42, 0.65)';
|
|
507
535
|
return (
|
|
508
536
|
<View
|
|
537
|
+
className={className as never}
|
|
509
538
|
style={[
|
|
510
539
|
{
|
|
511
540
|
backgroundColor: bg,
|
|
@@ -513,6 +542,7 @@ export const BlurView: React.FC<{
|
|
|
513
542
|
} as never,
|
|
514
543
|
style as never,
|
|
515
544
|
]}
|
|
545
|
+
{...rest}
|
|
516
546
|
>
|
|
517
547
|
{children}
|
|
518
548
|
</View>
|
|
@@ -523,15 +553,52 @@ export const Image: React.FC<Record<string, unknown>> = ({
|
|
|
523
553
|
contentFit,
|
|
524
554
|
resizeMode,
|
|
525
555
|
source,
|
|
556
|
+
placeholder,
|
|
557
|
+
transition: _transition,
|
|
558
|
+
className,
|
|
559
|
+
style,
|
|
526
560
|
...rest
|
|
527
561
|
}) => {
|
|
528
|
-
|
|
562
|
+
let uri = '';
|
|
563
|
+
if (typeof source === 'string') {
|
|
564
|
+
uri = source;
|
|
565
|
+
} else if (Array.isArray(source) && source[0] && typeof source[0] === 'object') {
|
|
566
|
+
uri = String((source[0] as Record<string, unknown>).uri ?? '');
|
|
567
|
+
} else if (source && typeof source === 'object') {
|
|
568
|
+
uri = String((source as Record<string, unknown>).uri ?? '');
|
|
569
|
+
}
|
|
570
|
+
const placeholderBg =
|
|
571
|
+
placeholder && typeof placeholder === 'object' && 'color' in placeholder
|
|
572
|
+
? String((placeholder as Record<string, unknown>).color ?? 'transparent')
|
|
573
|
+
: undefined;
|
|
574
|
+
const fit = String(contentFit ?? resizeMode ?? 'cover') as React.CSSProperties['objectFit'];
|
|
575
|
+
|
|
529
576
|
return (
|
|
530
|
-
<
|
|
531
|
-
|
|
532
|
-
|
|
577
|
+
<View
|
|
578
|
+
className={className as never}
|
|
579
|
+
style={[
|
|
580
|
+
{
|
|
581
|
+
overflow: 'hidden',
|
|
582
|
+
...(placeholderBg ? { backgroundColor: placeholderBg } : {}),
|
|
583
|
+
} as never,
|
|
584
|
+
style as never,
|
|
585
|
+
]}
|
|
533
586
|
{...(rest as Record<string, unknown>)}
|
|
534
|
-
|
|
587
|
+
>
|
|
588
|
+
{uri ? (
|
|
589
|
+
<img
|
|
590
|
+
src={uri}
|
|
591
|
+
alt=""
|
|
592
|
+
draggable={false}
|
|
593
|
+
style={{
|
|
594
|
+
width: '100%',
|
|
595
|
+
height: '100%',
|
|
596
|
+
objectFit: fit,
|
|
597
|
+
display: 'block',
|
|
598
|
+
}}
|
|
599
|
+
/>
|
|
600
|
+
) : null}
|
|
601
|
+
</View>
|
|
535
602
|
);
|
|
536
603
|
};
|
|
537
604
|
|
|
@@ -726,7 +793,9 @@ export const Easing = {
|
|
|
726
793
|
};
|
|
727
794
|
|
|
728
795
|
export function createAnimatedComponent<P extends object>(Component: React.ComponentType<P>) {
|
|
729
|
-
return
|
|
796
|
+
return withNativeWind(
|
|
797
|
+
Component as unknown as React.ComponentType<Record<string, unknown>>
|
|
798
|
+
) as unknown as React.ComponentType<P>;
|
|
730
799
|
}
|
|
731
800
|
|
|
732
801
|
export const Animated = {
|
|
@@ -751,10 +820,15 @@ export const Animated = {
|
|
|
751
820
|
};
|
|
752
821
|
|
|
753
822
|
// React Native Gesture Handler Shims
|
|
754
|
-
export const GestureHandlerRootView: React.FC<{
|
|
755
|
-
children
|
|
756
|
-
style
|
|
757
|
-
|
|
823
|
+
export const GestureHandlerRootView: React.FC<{
|
|
824
|
+
children?: React.ReactNode;
|
|
825
|
+
style?: unknown;
|
|
826
|
+
className?: string;
|
|
827
|
+
}> = ({ children, style, className, ...rest }) => (
|
|
828
|
+
<View className={className as never} style={[{ flex: 1 }, style as never]} {...rest}>
|
|
829
|
+
{children}
|
|
830
|
+
</View>
|
|
831
|
+
);
|
|
758
832
|
|
|
759
833
|
export const ScrollView = RNScrollView;
|
|
760
834
|
export const FlatList = RNFlatList;
|
|
@@ -973,53 +1047,477 @@ export const QueryClientProvider: React.FC<{ client?: unknown; children?: React.
|
|
|
973
1047
|
children,
|
|
974
1048
|
}) => <>{children}</>;
|
|
975
1049
|
|
|
1050
|
+
const singletonQueryClient = new QueryClient();
|
|
1051
|
+
|
|
976
1052
|
export function useQueryClient() {
|
|
977
|
-
return
|
|
1053
|
+
return singletonQueryClient;
|
|
978
1054
|
}
|
|
979
1055
|
|
|
1056
|
+
const STABLE_EMPTY_ARRAY: unknown[] = [];
|
|
1057
|
+
|
|
1058
|
+
const STABLE_QUERY_RESULT = {
|
|
1059
|
+
data: undefined,
|
|
1060
|
+
error: null,
|
|
1061
|
+
isLoading: false,
|
|
1062
|
+
isPending: false,
|
|
1063
|
+
isFetching: false,
|
|
1064
|
+
isError: false,
|
|
1065
|
+
isSuccess: true,
|
|
1066
|
+
status: 'success',
|
|
1067
|
+
refetch: async () => ({ data: undefined, error: null }),
|
|
1068
|
+
};
|
|
1069
|
+
|
|
980
1070
|
export function useQuery() {
|
|
981
|
-
return
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
}
|
|
1071
|
+
return STABLE_QUERY_RESULT;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
const STABLE_INFINITE_QUERY_RESULT = {
|
|
1075
|
+
data: { pages: STABLE_EMPTY_ARRAY, pageParams: STABLE_EMPTY_ARRAY },
|
|
1076
|
+
error: null,
|
|
1077
|
+
isLoading: false,
|
|
1078
|
+
isPending: false,
|
|
1079
|
+
isFetching: false,
|
|
1080
|
+
isFetchingNextPage: false,
|
|
1081
|
+
hasNextPage: false,
|
|
1082
|
+
fetchNextPage: async () => ({}),
|
|
1083
|
+
refetch: async () => ({}),
|
|
1084
|
+
};
|
|
993
1085
|
|
|
994
1086
|
export function useInfiniteQuery() {
|
|
995
|
-
return
|
|
996
|
-
data: { pages: [], pageParams: [] },
|
|
997
|
-
error: null,
|
|
998
|
-
isLoading: false,
|
|
999
|
-
isPending: false,
|
|
1000
|
-
isFetching: false,
|
|
1001
|
-
isFetchingNextPage: false,
|
|
1002
|
-
hasNextPage: false,
|
|
1003
|
-
fetchNextPage: async () => ({}),
|
|
1004
|
-
refetch: async () => ({}),
|
|
1005
|
-
};
|
|
1087
|
+
return STABLE_INFINITE_QUERY_RESULT;
|
|
1006
1088
|
}
|
|
1007
1089
|
|
|
1090
|
+
const STABLE_MUTATION_RESULT = {
|
|
1091
|
+
mutate: () => undefined,
|
|
1092
|
+
mutateAsync: async () => ({}),
|
|
1093
|
+
reset: () => undefined,
|
|
1094
|
+
data: undefined,
|
|
1095
|
+
error: null,
|
|
1096
|
+
isLoading: false,
|
|
1097
|
+
isPending: false,
|
|
1098
|
+
isError: false,
|
|
1099
|
+
isSuccess: false,
|
|
1100
|
+
status: 'idle',
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1008
1103
|
export function useMutation() {
|
|
1104
|
+
return STABLE_MUTATION_RESULT;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// ============================================================================
|
|
1108
|
+
// 11. Universal Chainable Proxy, Zod, React Hook Form & Context Fallbacks
|
|
1109
|
+
// ============================================================================
|
|
1110
|
+
export function createSafeChainableProxy(): unknown {
|
|
1111
|
+
const fnTarget = function (..._args: unknown[]) {
|
|
1112
|
+
return proxy;
|
|
1113
|
+
};
|
|
1114
|
+
const proxy: unknown = new Proxy(fnTarget, {
|
|
1115
|
+
get(_target, prop) {
|
|
1116
|
+
if (prop === Symbol.toPrimitive) {
|
|
1117
|
+
return (hint: string) => (hint === 'number' ? 0 : '');
|
|
1118
|
+
}
|
|
1119
|
+
if (prop === 'valueOf') return () => 0;
|
|
1120
|
+
if (prop === 'toString') return () => '';
|
|
1121
|
+
if (prop === Symbol.iterator) {
|
|
1122
|
+
return function* () {
|
|
1123
|
+
yield proxy;
|
|
1124
|
+
yield proxy;
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
if (prop === 'then') {
|
|
1128
|
+
return (onFulfilled?: (v: unknown) => unknown, onRejected?: (e: unknown) => unknown) =>
|
|
1129
|
+
Promise.resolve({ data: null, error: null }).then(onFulfilled, onRejected);
|
|
1130
|
+
}
|
|
1131
|
+
if (prop === 'catch') return () => Promise.resolve({ data: null, error: null });
|
|
1132
|
+
if (prop === 'finally')
|
|
1133
|
+
return (cb?: () => void) => Promise.resolve({ data: null, error: null }).finally(cb);
|
|
1134
|
+
if (prop === 'safeParse' || prop === 'spa' || prop === 'safeParseAsync') {
|
|
1135
|
+
return (val?: unknown) => ({ success: true, data: val ?? {}, error: null });
|
|
1136
|
+
}
|
|
1137
|
+
if (prop === 'parse' || prop === 'parseAsync') {
|
|
1138
|
+
return (val?: unknown) => val ?? {};
|
|
1139
|
+
}
|
|
1140
|
+
if (
|
|
1141
|
+
prop === 'isLoading' ||
|
|
1142
|
+
prop === 'loading' ||
|
|
1143
|
+
prop === 'isPending' ||
|
|
1144
|
+
prop === 'isError' ||
|
|
1145
|
+
prop === 'disabled' ||
|
|
1146
|
+
prop === 'isSubmitting'
|
|
1147
|
+
) {
|
|
1148
|
+
return false;
|
|
1149
|
+
}
|
|
1150
|
+
if (
|
|
1151
|
+
prop === 'isReady' ||
|
|
1152
|
+
prop === 'granted' ||
|
|
1153
|
+
prop === 'isSuccess' ||
|
|
1154
|
+
prop === 'isAuthenticated' ||
|
|
1155
|
+
prop === 'isValid'
|
|
1156
|
+
) {
|
|
1157
|
+
return true;
|
|
1158
|
+
}
|
|
1159
|
+
if (prop === 'error' || prop === 'errors') return null;
|
|
1160
|
+
if (prop === 'status') return 'granted';
|
|
1161
|
+
if (prop === 'data' || prop === 'items' || prop === 'results' || prop === 'list') {
|
|
1162
|
+
return STABLE_EMPTY_ARRAY;
|
|
1163
|
+
}
|
|
1164
|
+
if (prop === 'length' || prop === 'size' || prop === 'count' || prop === 'value') return 0;
|
|
1165
|
+
if (prop === 'ref') return { current: null };
|
|
1166
|
+
if (prop === 'map' || prop === 'filter' || prop === 'slice' || prop === 'flatMap') {
|
|
1167
|
+
return () => STABLE_EMPTY_ARRAY;
|
|
1168
|
+
}
|
|
1169
|
+
if (prop === 'forEach') return () => undefined;
|
|
1170
|
+
if (prop === 'reduce') return (_fn: unknown, init: unknown) => init;
|
|
1171
|
+
if (prop === 'shape' || prop === '_def') return {};
|
|
1172
|
+
return proxy;
|
|
1173
|
+
},
|
|
1174
|
+
});
|
|
1175
|
+
return proxy;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
export const SAFE_CHAINABLE_PROXY = createSafeChainableProxy();
|
|
1179
|
+
|
|
1180
|
+
// Zod Shims (import { z } from 'zod' or import * as z from 'zod')
|
|
1181
|
+
export const z = SAFE_CHAINABLE_PROXY as Record<string, unknown>;
|
|
1182
|
+
export const string = () => SAFE_CHAINABLE_PROXY;
|
|
1183
|
+
export const number = () => SAFE_CHAINABLE_PROXY;
|
|
1184
|
+
export const boolean = () => SAFE_CHAINABLE_PROXY;
|
|
1185
|
+
export const object = () => SAFE_CHAINABLE_PROXY;
|
|
1186
|
+
export const array = () => SAFE_CHAINABLE_PROXY;
|
|
1187
|
+
export const union = () => SAFE_CHAINABLE_PROXY;
|
|
1188
|
+
export const literal = () => SAFE_CHAINABLE_PROXY;
|
|
1189
|
+
export const record = () => SAFE_CHAINABLE_PROXY;
|
|
1190
|
+
export const tuple = () => SAFE_CHAINABLE_PROXY;
|
|
1191
|
+
export const any = () => SAFE_CHAINABLE_PROXY;
|
|
1192
|
+
export const unknown = () => SAFE_CHAINABLE_PROXY;
|
|
1193
|
+
export const optional = () => SAFE_CHAINABLE_PROXY;
|
|
1194
|
+
export const nullable = () => SAFE_CHAINABLE_PROXY;
|
|
1195
|
+
export const coerce = SAFE_CHAINABLE_PROXY;
|
|
1196
|
+
export const zodResolver = () => async (values: unknown) => ({
|
|
1197
|
+
values: values ?? {},
|
|
1198
|
+
errors: {},
|
|
1199
|
+
});
|
|
1200
|
+
export const yupResolver = zodResolver;
|
|
1201
|
+
|
|
1202
|
+
// Common React Native Sizing & Classname Utility Shims
|
|
1203
|
+
export const scale = (size: number) => size;
|
|
1204
|
+
export const verticalScale = (size: number) => size;
|
|
1205
|
+
export const moderateScale = (size: number) => size;
|
|
1206
|
+
export const moderateVerticalScale = (size: number) => size;
|
|
1207
|
+
export const s = scale;
|
|
1208
|
+
export const vs = verticalScale;
|
|
1209
|
+
export const ms = moderateScale;
|
|
1210
|
+
export const mvs = moderateVerticalScale;
|
|
1211
|
+
export const RFValue = (size: number) => size;
|
|
1212
|
+
export const RFPercentage = (pct: number) => Math.round(pct * 8);
|
|
1213
|
+
export const widthPercentageToDP = (pct: number | string) =>
|
|
1214
|
+
typeof pct === 'number' ? Math.round((393 * pct) / 100) : 100;
|
|
1215
|
+
export const heightPercentageToDP = (pct: number | string) =>
|
|
1216
|
+
typeof pct === 'number' ? Math.round((852 * pct) / 100) : 100;
|
|
1217
|
+
export const wp = widthPercentageToDP;
|
|
1218
|
+
export const hp = heightPercentageToDP;
|
|
1219
|
+
export const clsx = (...args: unknown[]) =>
|
|
1220
|
+
args.filter((a): a is string => typeof a === 'string' && a.length > 0).join(' ');
|
|
1221
|
+
export const cn = clsx;
|
|
1222
|
+
export const twMerge = clsx;
|
|
1223
|
+
|
|
1224
|
+
// React Hook Form Shims (react-hook-form)
|
|
1225
|
+
export function useForm(config?: { defaultValues?: Record<string, unknown> }) {
|
|
1226
|
+
const defaults = config?.defaultValues ?? {};
|
|
1009
1227
|
return {
|
|
1010
|
-
|
|
1011
|
-
|
|
1228
|
+
control: {},
|
|
1229
|
+
register: (name: string) => ({
|
|
1230
|
+
name,
|
|
1231
|
+
onChange: () => undefined,
|
|
1232
|
+
onBlur: () => undefined,
|
|
1233
|
+
ref: () => undefined,
|
|
1234
|
+
}),
|
|
1235
|
+
handleSubmit: (onValid?: (data: Record<string, unknown>) => unknown) => () =>
|
|
1236
|
+
onValid?.(defaults),
|
|
1237
|
+
watch: (name?: string) => (name ? defaults[name] ?? '' : defaults),
|
|
1238
|
+
getValues: (name?: string) => (name ? defaults[name] : defaults),
|
|
1239
|
+
setValue: () => undefined,
|
|
1012
1240
|
reset: () => undefined,
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1241
|
+
clearErrors: () => undefined,
|
|
1242
|
+
setError: () => undefined,
|
|
1243
|
+
trigger: async () => true,
|
|
1244
|
+
formState: {
|
|
1245
|
+
errors: {},
|
|
1246
|
+
isDirty: false,
|
|
1247
|
+
isLoading: false,
|
|
1248
|
+
isSubmitted: false,
|
|
1249
|
+
isSubmitting: false,
|
|
1250
|
+
isSubmitSuccessful: false,
|
|
1251
|
+
isValid: true,
|
|
1252
|
+
dirtyFields: {},
|
|
1253
|
+
touchedFields: {},
|
|
1254
|
+
},
|
|
1020
1255
|
};
|
|
1021
1256
|
}
|
|
1022
1257
|
|
|
1258
|
+
export const useFormContext = () => useForm();
|
|
1259
|
+
export const FormProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
|
|
1260
|
+
<>{children}</>
|
|
1261
|
+
);
|
|
1262
|
+
export const useWatch = () => '';
|
|
1263
|
+
export const useFieldArray = () => ({
|
|
1264
|
+
fields: STABLE_EMPTY_ARRAY,
|
|
1265
|
+
append: () => undefined,
|
|
1266
|
+
prepend: () => undefined,
|
|
1267
|
+
remove: () => undefined,
|
|
1268
|
+
insert: () => undefined,
|
|
1269
|
+
move: () => undefined,
|
|
1270
|
+
update: () => undefined,
|
|
1271
|
+
replace: () => undefined,
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
export const Controller: React.FC<{
|
|
1275
|
+
name?: string;
|
|
1276
|
+
defaultValue?: unknown;
|
|
1277
|
+
render?: (params: {
|
|
1278
|
+
field: {
|
|
1279
|
+
name: string;
|
|
1280
|
+
value: unknown;
|
|
1281
|
+
onChange: (...args: unknown[]) => void;
|
|
1282
|
+
onBlur: () => void;
|
|
1283
|
+
ref: () => void;
|
|
1284
|
+
};
|
|
1285
|
+
fieldState: { invalid: boolean; isTouched: boolean; isDirty: boolean; error: undefined };
|
|
1286
|
+
formState: { errors: Record<string, unknown>; isSubmitting: boolean; isValid: boolean };
|
|
1287
|
+
}) => React.ReactNode;
|
|
1288
|
+
children?: React.ReactNode;
|
|
1289
|
+
}> = ({ name = '', defaultValue = '', render, children }) => {
|
|
1290
|
+
if (typeof render === 'function') {
|
|
1291
|
+
return (
|
|
1292
|
+
<>
|
|
1293
|
+
{render({
|
|
1294
|
+
field: {
|
|
1295
|
+
name,
|
|
1296
|
+
value: defaultValue ?? '',
|
|
1297
|
+
onChange: () => undefined,
|
|
1298
|
+
onBlur: () => undefined,
|
|
1299
|
+
ref: () => undefined,
|
|
1300
|
+
},
|
|
1301
|
+
fieldState: { invalid: false, isTouched: false, isDirty: false, error: undefined },
|
|
1302
|
+
formState: { errors: {}, isSubmitting: false, isValid: true },
|
|
1303
|
+
})}
|
|
1304
|
+
</>
|
|
1305
|
+
);
|
|
1306
|
+
}
|
|
1307
|
+
return <>{children}</>;
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
// Universal Unmounted Context Fallback (prevents "useAuth must be used within an AuthProvider")
|
|
1311
|
+
const previewUserBase: Record<string, unknown> = {
|
|
1312
|
+
id: 'usr_preview_01',
|
|
1313
|
+
uid: 'usr_preview_01',
|
|
1314
|
+
email: 'alex.morgan@example.com',
|
|
1315
|
+
name: 'Alex Morgan',
|
|
1316
|
+
fullName: 'Alex Morgan',
|
|
1317
|
+
full_name: 'Alex Morgan',
|
|
1318
|
+
firstName: 'Alex',
|
|
1319
|
+
first_name: 'Alex',
|
|
1320
|
+
lastName: 'Morgan',
|
|
1321
|
+
last_name: 'Morgan',
|
|
1322
|
+
displayName: 'Alex Morgan',
|
|
1323
|
+
display_name: 'Alex Morgan',
|
|
1324
|
+
username: 'alexmorgan',
|
|
1325
|
+
phone: '+1 (555) 019-2834',
|
|
1326
|
+
phoneNumber: '+1 (555) 019-2834',
|
|
1327
|
+
phone_number: '+1 (555) 019-2834',
|
|
1328
|
+
role: 'buyer',
|
|
1329
|
+
accountType: 'buyer',
|
|
1330
|
+
account_type: 'buyer',
|
|
1331
|
+
location: 'San Francisco, CA',
|
|
1332
|
+
city: 'San Francisco',
|
|
1333
|
+
bio: 'Product designer & automotive enthusiast.',
|
|
1334
|
+
avatar: '',
|
|
1335
|
+
avatarUrl: '',
|
|
1336
|
+
avatar_url: '',
|
|
1337
|
+
photoURL: '',
|
|
1338
|
+
profileImage: '',
|
|
1339
|
+
profile_image: '',
|
|
1340
|
+
isVerified: true,
|
|
1341
|
+
is_verified: true,
|
|
1342
|
+
verified: true,
|
|
1343
|
+
createdAt: '2025-01-15T10:00:00Z',
|
|
1344
|
+
created_at: '2025-01-15T10:00:00Z',
|
|
1345
|
+
user_metadata: {
|
|
1346
|
+
full_name: 'Alex Morgan',
|
|
1347
|
+
name: 'Alex Morgan',
|
|
1348
|
+
email: 'alex.morgan@example.com',
|
|
1349
|
+
role: 'buyer',
|
|
1350
|
+
avatar_url: '',
|
|
1351
|
+
},
|
|
1352
|
+
app_metadata: {
|
|
1353
|
+
provider: 'email',
|
|
1354
|
+
role: 'buyer',
|
|
1355
|
+
},
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
const previewUserProxy = new Proxy(previewUserBase, {
|
|
1359
|
+
get(target, prop) {
|
|
1360
|
+
if (prop in target) return target[prop as keyof typeof target];
|
|
1361
|
+
if (prop === Symbol.toPrimitive) return () => 'Alex Morgan';
|
|
1362
|
+
if (typeof prop === 'string') return '';
|
|
1363
|
+
return undefined;
|
|
1364
|
+
},
|
|
1365
|
+
});
|
|
1366
|
+
|
|
1367
|
+
const previewColorsBase: Record<string, string> = {
|
|
1368
|
+
primary: '#2563EB',
|
|
1369
|
+
primaryLight: '#DBEAFE',
|
|
1370
|
+
secondary: '#64748B',
|
|
1371
|
+
accent: '#4F46E5',
|
|
1372
|
+
background: '#FFFFFF',
|
|
1373
|
+
backgroundSecondary: '#F8FAFC',
|
|
1374
|
+
surface: '#F8FAFC',
|
|
1375
|
+
card: '#FFFFFF',
|
|
1376
|
+
text: '#0F172A',
|
|
1377
|
+
textPrimary: '#0F172A',
|
|
1378
|
+
textSecondary: '#475569',
|
|
1379
|
+
textMuted: '#94A3B8',
|
|
1380
|
+
muted: '#94A3B8',
|
|
1381
|
+
placeholder: '#94A3B8',
|
|
1382
|
+
border: '#E2E8F0',
|
|
1383
|
+
divider: '#E2E8F0',
|
|
1384
|
+
error: '#EF4444',
|
|
1385
|
+
danger: '#EF4444',
|
|
1386
|
+
success: '#10B981',
|
|
1387
|
+
warning: '#F59E0B',
|
|
1388
|
+
info: '#3B82F6',
|
|
1389
|
+
white: '#FFFFFF',
|
|
1390
|
+
black: '#0F172A',
|
|
1391
|
+
tint: '#2563EB',
|
|
1392
|
+
icon: '#64748B',
|
|
1393
|
+
tabIconDefault: '#94A3B8',
|
|
1394
|
+
tabIconSelected: '#2563EB',
|
|
1395
|
+
notification: '#EF4444',
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
const previewColorsProxy = new Proxy(previewColorsBase, {
|
|
1399
|
+
get(target, prop) {
|
|
1400
|
+
if (prop in target) return target[prop as keyof typeof target];
|
|
1401
|
+
return '#64748B';
|
|
1402
|
+
},
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
const safeContextFallbackBase: Record<string, unknown> = {
|
|
1406
|
+
user: previewUserProxy,
|
|
1407
|
+
currentUser: previewUserProxy,
|
|
1408
|
+
profile: previewUserProxy,
|
|
1409
|
+
session: {
|
|
1410
|
+
access_token: 'preview-access-token',
|
|
1411
|
+
refresh_token: 'preview-refresh-token',
|
|
1412
|
+
user: previewUserProxy,
|
|
1413
|
+
},
|
|
1414
|
+
isAuthenticated: true,
|
|
1415
|
+
isLoggedIn: true,
|
|
1416
|
+
isSignedIn: true,
|
|
1417
|
+
isLoading: false,
|
|
1418
|
+
loading: false,
|
|
1419
|
+
isPending: false,
|
|
1420
|
+
isRefreshing: false,
|
|
1421
|
+
isInitialized: true,
|
|
1422
|
+
isReady: true,
|
|
1423
|
+
error: null,
|
|
1424
|
+
theme: 'light',
|
|
1425
|
+
colorScheme: 'light',
|
|
1426
|
+
isDark: false,
|
|
1427
|
+
dark: false,
|
|
1428
|
+
colors: previewColorsProxy,
|
|
1429
|
+
items: STABLE_EMPTY_ARRAY,
|
|
1430
|
+
cart: STABLE_EMPTY_ARRAY,
|
|
1431
|
+
favorites: STABLE_EMPTY_ARRAY,
|
|
1432
|
+
wishlist: STABLE_EMPTY_ARRAY,
|
|
1433
|
+
notifications: STABLE_EMPTY_ARRAY,
|
|
1434
|
+
bookings: STABLE_EMPTY_ARRAY,
|
|
1435
|
+
listings: STABLE_EMPTY_ARRAY,
|
|
1436
|
+
vehicles: STABLE_EMPTY_ARRAY,
|
|
1437
|
+
cars: STABLE_EMPTY_ARRAY,
|
|
1438
|
+
orders: STABLE_EMPTY_ARRAY,
|
|
1439
|
+
transactions: STABLE_EMPTY_ARRAY,
|
|
1440
|
+
messages: STABLE_EMPTY_ARRAY,
|
|
1441
|
+
chats: STABLE_EMPTY_ARRAY,
|
|
1442
|
+
unreadCount: 0,
|
|
1443
|
+
count: 0,
|
|
1444
|
+
total: 0,
|
|
1445
|
+
balance: 0,
|
|
1446
|
+
signIn: async () => ({ data: { user: previewUserProxy }, error: null }),
|
|
1447
|
+
signUp: async () => ({ data: { user: previewUserProxy }, error: null }),
|
|
1448
|
+
signOut: async () => ({ error: null }),
|
|
1449
|
+
login: async () => ({ data: { user: previewUserProxy }, error: null }),
|
|
1450
|
+
logout: async () => undefined,
|
|
1451
|
+
register: async () => ({ data: { user: previewUserProxy }, error: null }),
|
|
1452
|
+
refresh: async () => undefined,
|
|
1453
|
+
refetch: async () => undefined,
|
|
1454
|
+
updateProfile: async () => ({ error: null }),
|
|
1455
|
+
toggleTheme: () => undefined,
|
|
1456
|
+
setTheme: () => undefined,
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
export const SAFE_CONTEXT_FALLBACK: Record<string, unknown> = new Proxy(safeContextFallbackBase, {
|
|
1460
|
+
get(target, prop) {
|
|
1461
|
+
if (prop in target) return target[prop as keyof typeof target];
|
|
1462
|
+
if (prop === Symbol.iterator) {
|
|
1463
|
+
return function* () {
|
|
1464
|
+
yield SAFE_CONTEXT_FALLBACK;
|
|
1465
|
+
yield () => undefined;
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
return SAFE_CHAINABLE_PROXY;
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
// Install unmounted user-context fallback on React.createContext & React.useContext
|
|
1473
|
+
// (runs after react-native-web has already initialized its internal VirtualizedListContext)
|
|
1474
|
+
const origCreateContext = React.createContext;
|
|
1475
|
+
const origUseContext = React.useContext;
|
|
1476
|
+
|
|
1477
|
+
const wrappedCreateContext = function zeluneCreateContext(
|
|
1478
|
+
defaultValue: unknown,
|
|
1479
|
+
...rest: unknown[]
|
|
1480
|
+
) {
|
|
1481
|
+
const isEmptyDefault =
|
|
1482
|
+
defaultValue === undefined ||
|
|
1483
|
+
defaultValue === null ||
|
|
1484
|
+
(typeof defaultValue === 'object' &&
|
|
1485
|
+
defaultValue !== null &&
|
|
1486
|
+
Object.keys(defaultValue as object).length === 0);
|
|
1487
|
+
const effectiveDefault = isEmptyDefault ? SAFE_CONTEXT_FALLBACK : defaultValue;
|
|
1488
|
+
const ctx = (origCreateContext as (...a: unknown[]) => Record<string, unknown>).call(
|
|
1489
|
+
React,
|
|
1490
|
+
effectiveDefault,
|
|
1491
|
+
...rest
|
|
1492
|
+
);
|
|
1493
|
+
if (ctx && typeof ctx === 'object' && isEmptyDefault) {
|
|
1494
|
+
ctx.__zeluneUserContext = true;
|
|
1495
|
+
}
|
|
1496
|
+
return ctx;
|
|
1497
|
+
} as unknown as typeof React.createContext;
|
|
1498
|
+
|
|
1499
|
+
const wrappedUseContext = function zeluneUseContext(
|
|
1500
|
+
Context: React.Context<unknown>,
|
|
1501
|
+
...rest: unknown[]
|
|
1502
|
+
) {
|
|
1503
|
+
const val = (origUseContext as (...a: unknown[]) => unknown).call(React, Context, ...rest);
|
|
1504
|
+
if (
|
|
1505
|
+
val === undefined ||
|
|
1506
|
+
(val === null &&
|
|
1507
|
+
Boolean((Context as unknown as Record<string, unknown>)?.__zeluneUserContext))
|
|
1508
|
+
) {
|
|
1509
|
+
return SAFE_CONTEXT_FALLBACK;
|
|
1510
|
+
}
|
|
1511
|
+
return val;
|
|
1512
|
+
} as unknown as typeof React.useContext;
|
|
1513
|
+
|
|
1514
|
+
try {
|
|
1515
|
+
React.createContext = wrappedCreateContext;
|
|
1516
|
+
React.useContext = wrappedUseContext;
|
|
1517
|
+
} catch {
|
|
1518
|
+
// Ignore if React namespace is frozen in test environment
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1023
1521
|
function createSupabaseQueryBuilder(): Record<string, unknown> {
|
|
1024
1522
|
const resultPromise = Promise.resolve({ data: [], error: null, count: 0 });
|
|
1025
1523
|
const builder: Record<string, unknown> = new Proxy(
|
|
@@ -1146,6 +1644,29 @@ const defaultExportProperties = {
|
|
|
1146
1644
|
useInfiniteQuery,
|
|
1147
1645
|
useMutation,
|
|
1148
1646
|
createClient,
|
|
1647
|
+
z,
|
|
1648
|
+
string,
|
|
1649
|
+
number,
|
|
1650
|
+
boolean,
|
|
1651
|
+
object,
|
|
1652
|
+
array,
|
|
1653
|
+
union,
|
|
1654
|
+
literal,
|
|
1655
|
+
record,
|
|
1656
|
+
tuple,
|
|
1657
|
+
any,
|
|
1658
|
+
unknown,
|
|
1659
|
+
optional,
|
|
1660
|
+
nullable,
|
|
1661
|
+
coerce,
|
|
1662
|
+
zodResolver,
|
|
1663
|
+
yupResolver,
|
|
1664
|
+
useForm,
|
|
1665
|
+
useFormContext,
|
|
1666
|
+
FormProvider,
|
|
1667
|
+
useWatch,
|
|
1668
|
+
useFieldArray,
|
|
1669
|
+
Controller,
|
|
1149
1670
|
};
|
|
1150
1671
|
|
|
1151
1672
|
Object.assign(UniversalDefaultExportComponent, defaultExportProperties);
|
|
@@ -1161,7 +1682,7 @@ const defaultExportProxy = new Proxy(UniversalDefaultExportComponent, {
|
|
|
1161
1682
|
if (typeof prop === 'string' && /^[A-Z]/.test(prop)) {
|
|
1162
1683
|
return createVectorIconComponent(prop);
|
|
1163
1684
|
}
|
|
1164
|
-
return
|
|
1685
|
+
return SAFE_CHAINABLE_PROXY;
|
|
1165
1686
|
},
|
|
1166
1687
|
});
|
|
1167
1688
|
|