@devtravelcode/widget-native 1.0.0

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 (208) hide show
  1. package/LICENSE +18 -0
  2. package/dist/App.d.ts +10 -0
  3. package/dist/App.js +192 -0
  4. package/dist/TravelHubWidget.d.ts +12 -0
  5. package/dist/TravelHubWidget.js +58 -0
  6. package/dist/components/ErrorBoundary.d.ts +18 -0
  7. package/dist/components/ErrorBoundary.js +63 -0
  8. package/dist/components/ui/Modal.d.ts +11 -0
  9. package/dist/components/ui/Modal.js +66 -0
  10. package/dist/components/ui/Skeleton.d.ts +8 -0
  11. package/dist/components/ui/Skeleton.js +33 -0
  12. package/dist/components/ui/badge.d.ts +11 -0
  13. package/dist/components/ui/badge.js +54 -0
  14. package/dist/components/ui/button.d.ts +14 -0
  15. package/dist/components/ui/button.js +101 -0
  16. package/dist/components/ui/card.d.ts +16 -0
  17. package/dist/components/ui/card.js +51 -0
  18. package/dist/components/ui/input.d.ts +8 -0
  19. package/dist/components/ui/input.js +61 -0
  20. package/dist/components/ui/label.d.ts +8 -0
  21. package/dist/components/ui/label.js +17 -0
  22. package/dist/context/WidgetContext.d.ts +29 -0
  23. package/dist/context/WidgetContext.js +64 -0
  24. package/dist/icons/CarIcon.d.ts +4 -0
  25. package/dist/icons/CarIcon.js +3 -0
  26. package/dist/icons/CloseIcon.d.ts +7 -0
  27. package/dist/icons/CloseIcon.js +3 -0
  28. package/dist/icons/FlightIcon.d.ts +4 -0
  29. package/dist/icons/FlightIcon.js +3 -0
  30. package/dist/icons/HotelIcon.d.ts +4 -0
  31. package/dist/icons/HotelIcon.js +3 -0
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +1 -0
  34. package/dist/lib/utils.d.ts +2 -0
  35. package/dist/lib/utils.js +3 -0
  36. package/dist/locales/widgetTranslations.d.ts +1 -0
  37. package/dist/locales/widgetTranslations.js +732 -0
  38. package/dist/modules/hooks/useAirportSearch.d.ts +21 -0
  39. package/dist/modules/hooks/useAirportSearch.js +48 -0
  40. package/dist/modules/hooks/useCarOffers.d.ts +7 -0
  41. package/dist/modules/hooks/useCarOffers.js +47 -0
  42. package/dist/modules/hooks/useCountriesByCodes.d.ts +4 -0
  43. package/dist/modules/hooks/useCountriesByCodes.js +60 -0
  44. package/dist/modules/hooks/useCountriesSearch.d.ts +11 -0
  45. package/dist/modules/hooks/useCountriesSearch.js +55 -0
  46. package/dist/modules/hooks/useDefaultHotelLocation.d.ts +7 -0
  47. package/dist/modules/hooks/useDefaultHotelLocation.js +44 -0
  48. package/dist/modules/hooks/useDetectNationality.d.ts +1 -0
  49. package/dist/modules/hooks/useDetectNationality.js +20 -0
  50. package/dist/modules/hooks/useFlightSearch.d.ts +20 -0
  51. package/dist/modules/hooks/useFlightSearch.js +243 -0
  52. package/dist/modules/hooks/useHotelDetails.d.ts +7 -0
  53. package/dist/modules/hooks/useHotelDetails.js +80 -0
  54. package/dist/modules/hooks/useHotelLocations.d.ts +5 -0
  55. package/dist/modules/hooks/useHotelLocations.js +42 -0
  56. package/dist/modules/hooks/useHotelMapData.d.ts +12 -0
  57. package/dist/modules/hooks/useHotelMapData.js +78 -0
  58. package/dist/modules/hooks/useHotelOffers.d.ts +11 -0
  59. package/dist/modules/hooks/useHotelOffers.js +122 -0
  60. package/dist/modules/hooks/useHotelSearchSSE.d.ts +18 -0
  61. package/dist/modules/hooks/useHotelSearchSSE.js +411 -0
  62. package/dist/modules/hooks/useSearchExpiration.d.ts +6 -0
  63. package/dist/modules/hooks/useSearchExpiration.js +35 -0
  64. package/dist/modules/hooks/useTranslationsHub.d.ts +5 -0
  65. package/dist/modules/hooks/useTranslationsHub.js +48 -0
  66. package/dist/modules/navbar/Navbar.d.ts +8 -0
  67. package/dist/modules/navbar/Navbar.js +69 -0
  68. package/dist/modules/search-form/AgeSelector.d.ts +9 -0
  69. package/dist/modules/search-form/AgeSelector.js +109 -0
  70. package/dist/modules/search-form/CustomSelect.d.ts +14 -0
  71. package/dist/modules/search-form/CustomSelect.js +94 -0
  72. package/dist/modules/search-form/FiltersSkeleton.d.ts +6 -0
  73. package/dist/modules/search-form/FiltersSkeleton.js +35 -0
  74. package/dist/modules/search-form/NationalityInput.d.ts +18 -0
  75. package/dist/modules/search-form/NationalityInput.js +172 -0
  76. package/dist/modules/search-form/Pagination.d.ts +8 -0
  77. package/dist/modules/search-form/Pagination.js +84 -0
  78. package/dist/modules/search-form/SearchExpiredPopup.d.ts +10 -0
  79. package/dist/modules/search-form/SearchExpiredPopup.js +91 -0
  80. package/dist/modules/search-form/SkeletonWidget.d.ts +2 -0
  81. package/dist/modules/search-form/SkeletonWidget.js +33 -0
  82. package/dist/modules/search-form/TimePicker.d.ts +9 -0
  83. package/dist/modules/search-form/TimePicker.js +182 -0
  84. package/dist/modules/search-form/cars/CarEmptyState.d.ts +6 -0
  85. package/dist/modules/search-form/cars/CarEmptyState.js +42 -0
  86. package/dist/modules/search-form/cars/CarFiltersSkeleton.d.ts +6 -0
  87. package/dist/modules/search-form/cars/CarFiltersSkeleton.js +35 -0
  88. package/dist/modules/search-form/cars/CarOffersList.d.ts +43 -0
  89. package/dist/modules/search-form/cars/CarOffersList.js +214 -0
  90. package/dist/modules/search-form/cars/CarResults.d.ts +25 -0
  91. package/dist/modules/search-form/cars/CarResults.js +116 -0
  92. package/dist/modules/search-form/cars/CarSearchForm.d.ts +19 -0
  93. package/dist/modules/search-form/cars/CarSearchForm.js +173 -0
  94. package/dist/modules/search-form/cars/CarSkeleton.d.ts +6 -0
  95. package/dist/modules/search-form/cars/CarSkeleton.js +46 -0
  96. package/dist/modules/search-form/cars/CarTopOffersSlider.d.ts +20 -0
  97. package/dist/modules/search-form/cars/CarTopOffersSlider.js +100 -0
  98. package/dist/modules/search-form/cars/car-filters/CarFilters.d.ts +8 -0
  99. package/dist/modules/search-form/cars/car-filters/CarFilters.js +318 -0
  100. package/dist/modules/search-form/cars/car-filters/FilterSection.d.ts +9 -0
  101. package/dist/modules/search-form/cars/car-filters/FilterSection.js +30 -0
  102. package/dist/modules/search-form/cars/car-filters/index.d.ts +6 -0
  103. package/dist/modules/search-form/cars/car-filters/index.js +3 -0
  104. package/dist/modules/search-form/cars/car-filters/useCarFilters.d.ts +24 -0
  105. package/dist/modules/search-form/cars/car-filters/useCarFilters.js +121 -0
  106. package/dist/modules/search-form/flight/AirlinesSelector.d.ts +8 -0
  107. package/dist/modules/search-form/flight/AirlinesSelector.js +235 -0
  108. package/dist/modules/search-form/flight/CabinClassSelector.d.ts +9 -0
  109. package/dist/modules/search-form/flight/CabinClassSelector.js +63 -0
  110. package/dist/modules/search-form/flight/DatePicker.d.ts +12 -0
  111. package/dist/modules/search-form/flight/DatePicker.js +536 -0
  112. package/dist/modules/search-form/flight/FlightSearchForm.d.ts +18 -0
  113. package/dist/modules/search-form/flight/FlightSearchForm.js +147 -0
  114. package/dist/modules/search-form/flight/LocationInput.d.ts +11 -0
  115. package/dist/modules/search-form/flight/LocationInput.js +294 -0
  116. package/dist/modules/search-form/flight/PassengersPicker.d.ts +16 -0
  117. package/dist/modules/search-form/flight/PassengersPicker.js +203 -0
  118. package/dist/modules/search-form/flight/SwitchLocationBtn.d.ts +9 -0
  119. package/dist/modules/search-form/flight/SwitchLocationBtn.js +48 -0
  120. package/dist/modules/search-form/flight/flight-filters/FiltersContent.d.ts +21 -0
  121. package/dist/modules/search-form/flight/flight-filters/FiltersContent.js +145 -0
  122. package/dist/modules/search-form/flight/flight-filters/FlightFiltersDynamic.d.ts +11 -0
  123. package/dist/modules/search-form/flight/flight-filters/FlightFiltersDynamic.js +213 -0
  124. package/dist/modules/search-form/flight/flight-filters/RangeBlock.d.ts +22 -0
  125. package/dist/modules/search-form/flight/flight-filters/RangeBlock.js +164 -0
  126. package/dist/modules/search-form/flight/flight-filters/index.d.ts +1 -0
  127. package/dist/modules/search-form/flight/flight-filters/index.js +1 -0
  128. package/dist/modules/search-form/flight/flight-results/FlightAdditionalInfo.d.ts +16 -0
  129. package/dist/modules/search-form/flight/flight-results/FlightAdditionalInfo.js +229 -0
  130. package/dist/modules/search-form/flight/flight-results/FlightBaggageToggle.d.ts +15 -0
  131. package/dist/modules/search-form/flight/flight-results/FlightBaggageToggle.js +110 -0
  132. package/dist/modules/search-form/flight/flight-results/FlightCard.d.ts +14 -0
  133. package/dist/modules/search-form/flight/flight-results/FlightCard.js +436 -0
  134. package/dist/modules/search-form/flight/flight-results/FlightInfo.d.ts +12 -0
  135. package/dist/modules/search-form/flight/flight-results/FlightInfo.js +48 -0
  136. package/dist/modules/search-form/flight/flight-results/FlightPriceBlock.d.ts +11 -0
  137. package/dist/modules/search-form/flight/flight-results/FlightPriceBlock.js +36 -0
  138. package/dist/modules/search-form/flight/flight-results/FlightResults.d.ts +22 -0
  139. package/dist/modules/search-form/flight/flight-results/FlightResults.js +109 -0
  140. package/dist/modules/search-form/flight/flight-results/FlightSegments.d.ts +40 -0
  141. package/dist/modules/search-form/flight/flight-results/FlightSegments.js +162 -0
  142. package/dist/modules/search-form/flight/flight-results/FlightsSkeleton.d.ts +6 -0
  143. package/dist/modules/search-form/flight/flight-results/FlightsSkeleton.js +52 -0
  144. package/dist/modules/search-form/flight/flight-results/ProvidersLoader.d.ts +9 -0
  145. package/dist/modules/search-form/flight/flight-results/ProvidersLoader.js +242 -0
  146. package/dist/modules/search-form/hotel/DatePicker.d.ts +1 -0
  147. package/dist/modules/search-form/hotel/DatePicker.js +1 -0
  148. package/dist/modules/search-form/hotel/GuestSelector.d.ts +13 -0
  149. package/dist/modules/search-form/hotel/GuestSelector.js +272 -0
  150. package/dist/modules/search-form/hotel/GuestSelectorMobilePopup.d.ts +2 -0
  151. package/dist/modules/search-form/hotel/GuestSelectorMobilePopup.js +1 -0
  152. package/dist/modules/search-form/hotel/HotelLocation.d.ts +17 -0
  153. package/dist/modules/search-form/hotel/HotelLocation.js +178 -0
  154. package/dist/modules/search-form/hotel/HotelLocationMobilePopup.d.ts +2 -0
  155. package/dist/modules/search-form/hotel/HotelLocationMobilePopup.js +1 -0
  156. package/dist/modules/search-form/hotel/HotelResults.d.ts +21 -0
  157. package/dist/modules/search-form/hotel/HotelResults.js +333 -0
  158. package/dist/modules/search-form/hotel/HotelSearchForm.d.ts +13 -0
  159. package/dist/modules/search-form/hotel/HotelSearchForm.js +130 -0
  160. package/dist/modules/search-form/hotel/HotelsSkeleton.d.ts +6 -0
  161. package/dist/modules/search-form/hotel/HotelsSkeleton.js +40 -0
  162. package/dist/modules/search-form/hotel/PassengersPicker.d.ts +2 -0
  163. package/dist/modules/search-form/hotel/PassengersPicker.js +1 -0
  164. package/dist/modules/search-form/hotel/components/HotelCard.d.ts +11 -0
  165. package/dist/modules/search-form/hotel/components/HotelCard.js +180 -0
  166. package/dist/modules/search-form/hotel/components/HotelEmptyState.d.ts +6 -0
  167. package/dist/modules/search-form/hotel/components/HotelEmptyState.js +34 -0
  168. package/dist/modules/search-form/hotel/components/HotelGallery.d.ts +6 -0
  169. package/dist/modules/search-form/hotel/components/HotelGallery.js +77 -0
  170. package/dist/modules/search-form/hotel/components/HotelList.d.ts +9 -0
  171. package/dist/modules/search-form/hotel/components/HotelList.js +12 -0
  172. package/dist/modules/search-form/hotel/components/HotelMap.d.ts +26 -0
  173. package/dist/modules/search-form/hotel/components/HotelMap.js +707 -0
  174. package/dist/modules/search-form/hotel/components/HotelPin.d.ts +7 -0
  175. package/dist/modules/search-form/hotel/components/HotelPin.js +1 -0
  176. package/dist/modules/search-form/hotel/hotel-filters/HotelFilters.d.ts +29 -0
  177. package/dist/modules/search-form/hotel/hotel-filters/HotelFilters.js +339 -0
  178. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersBar.d.ts +3 -0
  179. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersBar.js +2 -0
  180. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersContent.d.ts +2 -0
  181. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersContent.js +1 -0
  182. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersDynamic.d.ts +2 -0
  183. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersDynamic.js +1 -0
  184. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersMobilePopup.d.ts +2 -0
  185. package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersMobilePopup.js +1 -0
  186. package/dist/modules/search-form/hotel/hotel-filters/RangeBlock.d.ts +1 -0
  187. package/dist/modules/search-form/hotel/hotel-filters/RangeBlock.js +1 -0
  188. package/dist/modules/search-form/hotel/hotel-filters/index.d.ts +1 -0
  189. package/dist/modules/search-form/hotel/hotel-filters/index.js +1 -0
  190. package/dist/modules/tabs/FlightsTab.d.ts +1 -0
  191. package/dist/modules/tabs/FlightsTab.js +1 -0
  192. package/dist/modules/tabs/HotelsTab.d.ts +1 -0
  193. package/dist/modules/tabs/HotelsTab.js +1 -0
  194. package/dist/store/index.d.ts +22 -0
  195. package/dist/store/index.js +19 -0
  196. package/dist/theme/colors.d.ts +56 -0
  197. package/dist/theme/colors.js +56 -0
  198. package/dist/theme/formStyles.d.ts +76 -0
  199. package/dist/theme/formStyles.js +78 -0
  200. package/dist/utils/applyWidgetColors.d.ts +1 -0
  201. package/dist/utils/applyWidgetColors.js +2 -0
  202. package/dist/utils/dateTime.d.ts +2 -0
  203. package/dist/utils/dateTime.js +23 -0
  204. package/dist/utils/fetchSSE.d.ts +23 -0
  205. package/dist/utils/fetchSSE.js +104 -0
  206. package/dist/utils/getToken.d.ts +3 -0
  207. package/dist/utils/getToken.js +12 -0
  208. package/package.json +64 -0
@@ -0,0 +1,78 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { Colors, Spacing, BorderRadius, FontSize } from "./colors";
3
+ export const formStyles = StyleSheet.create({
4
+ formCard: {
5
+ backgroundColor: Colors.surface,
6
+ borderRadius: BorderRadius.xxl,
7
+ padding: Spacing.xl,
8
+ gap: Spacing.lg,
9
+ marginHorizontal: Spacing.lg,
10
+ marginTop: Spacing.lg,
11
+ },
12
+ label: {
13
+ color: Colors.label,
14
+ fontWeight: "600",
15
+ fontSize: FontSize.sm,
16
+ marginBottom: 5,
17
+ },
18
+ inputTrigger: {
19
+ backgroundColor: Colors.inputBg,
20
+ borderRadius: BorderRadius.lg,
21
+ paddingHorizontal: Spacing.lg,
22
+ paddingVertical: Spacing.md,
23
+ minHeight: 56,
24
+ justifyContent: "center",
25
+ },
26
+ inputTriggerRow: {
27
+ flexDirection: "row",
28
+ alignItems: "center",
29
+ justifyContent: "space-between",
30
+ },
31
+ inputTriggerText: {
32
+ fontSize: FontSize.md,
33
+ color: Colors.text,
34
+ flex: 1,
35
+ fontWeight: "400",
36
+ },
37
+ inputTriggerPlaceholder: {
38
+ color: Colors.textTertiary,
39
+ },
40
+ inputTriggerCode: {
41
+ fontSize: FontSize.sm,
42
+ color: Colors.textTertiary,
43
+ fontWeight: "400",
44
+ marginLeft: Spacing.sm,
45
+ },
46
+ searchButton: {
47
+ borderRadius: BorderRadius.lg,
48
+ paddingVertical: Spacing.lg,
49
+ alignItems: "center",
50
+ justifyContent: "center",
51
+ minHeight: 48,
52
+ },
53
+ searchButtonDisabled: {
54
+ opacity: 0.7,
55
+ },
56
+ searchButtonContent: {
57
+ flexDirection: "row",
58
+ alignItems: "center",
59
+ gap: Spacing.sm,
60
+ },
61
+ searchButtonText: {
62
+ color: Colors.textOnPrimary,
63
+ fontSize: FontSize.lg,
64
+ fontWeight: "500",
65
+ },
66
+ errorText: {
67
+ fontSize: FontSize.sm,
68
+ color: Colors.error,
69
+ marginTop: Spacing.xs,
70
+ fontWeight: "500",
71
+ },
72
+ searchError: {
73
+ fontSize: FontSize.sm,
74
+ color: Colors.error,
75
+ textAlign: "center",
76
+ padding: Spacing.sm,
77
+ },
78
+ });
@@ -0,0 +1 @@
1
+ export declare function applyWidgetColors(_config: any): void;
@@ -0,0 +1,2 @@
1
+ export function applyWidgetColors(_config) {
2
+ }
@@ -0,0 +1,2 @@
1
+ export type DateTimeFormatType = "usa" | "europe";
2
+ export declare const formatTimeByDateTimeFormat: (value: string | null | undefined, dateTimeFormat: string | undefined, fallback?: string) => string;
@@ -0,0 +1,23 @@
1
+ const normalizeDateTimeFormat = (value) => {
2
+ return value === "usa" ? "usa" : "europe";
3
+ };
4
+ export const formatTimeByDateTimeFormat = (value, dateTimeFormat, fallback = "--:--") => {
5
+ if (!value || typeof value !== "string")
6
+ return fallback;
7
+ const date = new Date(value);
8
+ if (isNaN(date.getTime()))
9
+ return fallback;
10
+ const format = normalizeDateTimeFormat(dateTimeFormat);
11
+ const isUsa = format === "usa";
12
+ return date.toLocaleTimeString(isUsa ? "en-US" : "ru-RU", isUsa
13
+ ? {
14
+ hour: "numeric",
15
+ minute: "2-digit",
16
+ hour12: true,
17
+ }
18
+ : {
19
+ hour: "2-digit",
20
+ minute: "2-digit",
21
+ hour12: false,
22
+ });
23
+ };
@@ -0,0 +1,23 @@
1
+ type SSEEvent = {
2
+ event: string;
3
+ data: string;
4
+ };
5
+ export declare function parseSSEBuffer(buffer: string): {
6
+ events: SSEEvent[];
7
+ remainder: string;
8
+ };
9
+ export declare function mergeHotels(existing: Map<string, any>, batch: any[]): {
10
+ merged: Map<string, any>;
11
+ updated: Set<string>;
12
+ };
13
+ type FetchSSEOptions = {
14
+ url: string;
15
+ body: Record<string, any>;
16
+ token: string;
17
+ onEvent: (event: string, data: string) => void;
18
+ onError: (error: Error) => void;
19
+ onComplete: () => void;
20
+ signal?: AbortSignal;
21
+ };
22
+ export declare function fetchSSE({ url, body, token, onEvent, onError, onComplete, signal, }: FetchSSEOptions): void;
23
+ export {};
@@ -0,0 +1,104 @@
1
+ export function parseSSEBuffer(buffer) {
2
+ const events = [];
3
+ const blocks = buffer.split("\n\n");
4
+ const remainder = blocks.pop() || "";
5
+ for (const block of blocks) {
6
+ if (!block.trim())
7
+ continue;
8
+ let eventName = "";
9
+ const dataLines = [];
10
+ for (const line of block.split("\n")) {
11
+ if (line.startsWith("event:")) {
12
+ eventName = line.slice(6).trim();
13
+ }
14
+ else if (line.startsWith("data:")) {
15
+ dataLines.push(line.slice(5).trim());
16
+ }
17
+ }
18
+ if (eventName || dataLines.length > 0) {
19
+ events.push({ event: eventName, data: dataLines.join("\n") });
20
+ }
21
+ }
22
+ return { events, remainder };
23
+ }
24
+ export function mergeHotels(existing, batch) {
25
+ const merged = new Map(existing);
26
+ const updated = new Set();
27
+ for (const hotel of batch) {
28
+ const id = String(hotel.id);
29
+ const prev = merged.get(id);
30
+ if (prev && hotel.price != null && hotel.price < prev.price) {
31
+ updated.add(id);
32
+ merged.set(id, hotel);
33
+ }
34
+ else if (!prev) {
35
+ merged.set(id, hotel);
36
+ }
37
+ }
38
+ return { merged, updated };
39
+ }
40
+ export function fetchSSE({ url, body, token, onEvent, onError, onComplete, signal, }) {
41
+ const xhr = new XMLHttpRequest();
42
+ let buffer = "";
43
+ let processedLength = 0;
44
+ if (signal) {
45
+ if (signal.aborted) {
46
+ onError(new DOMException("Aborted", "AbortError"));
47
+ return;
48
+ }
49
+ const onAbort = () => {
50
+ xhr.abort();
51
+ };
52
+ signal.addEventListener("abort", onAbort, { once: true });
53
+ xhr.addEventListener("loadend", () => {
54
+ signal.removeEventListener("abort", onAbort);
55
+ });
56
+ }
57
+ xhr.open("POST", url, true);
58
+ xhr.setRequestHeader("Content-Type", "application/json");
59
+ xhr.setRequestHeader("Accept", "text/event-stream");
60
+ xhr.setRequestHeader("Authorization", `Bearer ${token}`);
61
+ xhr.responseType = "";
62
+ xhr.onprogress = () => {
63
+ const newText = xhr.responseText.slice(processedLength);
64
+ processedLength = xhr.responseText.length;
65
+ if (!newText)
66
+ return;
67
+ buffer += newText;
68
+ const { events, remainder } = parseSSEBuffer(buffer);
69
+ buffer = remainder;
70
+ for (const sse of events) {
71
+ if (signal?.aborted)
72
+ break;
73
+ onEvent(sse.event, sse.data);
74
+ }
75
+ };
76
+ xhr.onload = () => {
77
+ if (buffer.trim()) {
78
+ const { events } = parseSSEBuffer(buffer + "\n\n");
79
+ for (const sse of events) {
80
+ if (signal?.aborted)
81
+ break;
82
+ onEvent(sse.event, sse.data);
83
+ }
84
+ }
85
+ if (xhr.status >= 200 && xhr.status < 300) {
86
+ onComplete();
87
+ }
88
+ else {
89
+ onError(new Error(`Stream request failed: ${xhr.status}`));
90
+ }
91
+ };
92
+ xhr.onerror = () => {
93
+ onError(new Error("Network error during SSE stream"));
94
+ };
95
+ xhr.ontimeout = () => {
96
+ onError(new Error("SSE stream timed out"));
97
+ };
98
+ xhr.onabort = () => {
99
+ const err = new DOMException("Aborted", "AbortError");
100
+ onError(err);
101
+ };
102
+ xhr.timeout = 180000;
103
+ xhr.send(JSON.stringify(body));
104
+ }
@@ -0,0 +1,3 @@
1
+ export declare function useApiToken(): string;
2
+ export declare function setGlobalToken(t: string): void;
3
+ export declare function getApiToken(): string;
@@ -0,0 +1,12 @@
1
+ import { useWidget } from "../context/WidgetContext";
2
+ export function useApiToken() {
3
+ const { token } = useWidget();
4
+ return token;
5
+ }
6
+ let _token = "";
7
+ export function setGlobalToken(t) {
8
+ _token = t;
9
+ }
10
+ export function getApiToken() {
11
+ return _token;
12
+ }
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@devtravelcode/widget-native",
3
+ "version": "1.0.0",
4
+ "description": "TravelHub search widget for React Native (flights, hotels, cars)",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "!dist/**/*.map"
10
+ ],
11
+ "scripts": {
12
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
13
+ "prepublishOnly": "npm run build",
14
+ "test": "npx tsc --noEmit",
15
+ "start": "npx expo start",
16
+ "android": "npx expo start --android",
17
+ "ios": "npx expo start --ios"
18
+ },
19
+ "peerDependencies": {
20
+ "@react-native-async-storage/async-storage": ">=1.21.0",
21
+ "react": ">=18.0.0",
22
+ "react-native": ">=0.72.0",
23
+ "react-native-gesture-handler": ">=2.14.0",
24
+ "react-native-maps": ">=1.10.0",
25
+ "react-native-reanimated": ">=3.6.0",
26
+ "react-native-safe-area-context": ">=4.8.0",
27
+ "react-native-svg": ">=14.0.0"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "react-native-maps": {
31
+ "optional": true
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@reduxjs/toolkit": "^2.9.0",
36
+ "date-fns": "^4.1.0",
37
+ "react-native-map-clustering": "^4.0.0",
38
+ "react-redux": "^9.2.0"
39
+ },
40
+ "devDependencies": {
41
+ "@react-native-async-storage/async-storage": "^2.1.2",
42
+ "@types/react": "~19.1.10",
43
+ "expo": "~54.0.0",
44
+ "expo-asset": "~12.0.12",
45
+ "expo-constants": "~18.0.13",
46
+ "expo-file-system": "~19.0.21",
47
+ "expo-font": "~14.0.11",
48
+ "expo-status-bar": "~3.0.9",
49
+ "lucide-react-native": "^0.475.0",
50
+ "react": "^19.1.0",
51
+ "react-native": "^0.81.5",
52
+ "react-native-gesture-handler": "~2.28.0",
53
+ "react-native-maps": "^1.20.1",
54
+ "react-native-reanimated": "~3.16.0",
55
+ "react-native-safe-area-context": "~5.4.0",
56
+ "react-native-svg": "^15.12.1",
57
+ "typescript": "^5.9.2"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "license": "SEE LICENSE IN LICENSE",
63
+ "private": false
64
+ }