@buoy-gg/route-events 1.7.2

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 (79) hide show
  1. package/README.md +654 -0
  2. package/lib/commonjs/RouteObserver.js +54 -0
  3. package/lib/commonjs/RouteParser.js +310 -0
  4. package/lib/commonjs/RouteTracker.js +39 -0
  5. package/lib/commonjs/components/NavigationStack.js +584 -0
  6. package/lib/commonjs/components/RouteEventDetailContent.js +492 -0
  7. package/lib/commonjs/components/RouteEventExpandedContent.js +187 -0
  8. package/lib/commonjs/components/RouteEventItemCompact.js +175 -0
  9. package/lib/commonjs/components/RouteEventsModalWithTabs.js +560 -0
  10. package/lib/commonjs/components/RouteEventsTimeline.js +82 -0
  11. package/lib/commonjs/components/RouteFilterViewV2.js +42 -0
  12. package/lib/commonjs/components/RoutesSitemap.js +948 -0
  13. package/lib/commonjs/expoRouterStore.js +104 -0
  14. package/lib/commonjs/index.js +99 -0
  15. package/lib/commonjs/package.json +1 -0
  16. package/lib/commonjs/preset.js +83 -0
  17. package/lib/commonjs/useNavigationStack.js +241 -0
  18. package/lib/commonjs/useRouteObserver.js +73 -0
  19. package/lib/commonjs/useRouteSitemap.js +234 -0
  20. package/lib/commonjs/utils/safeExpoRouter.js +129 -0
  21. package/lib/commonjs/utils/safeReactNavigation.js +104 -0
  22. package/lib/module/RouteObserver.js +49 -0
  23. package/lib/module/RouteParser.js +305 -0
  24. package/lib/module/RouteTracker.js +35 -0
  25. package/lib/module/components/NavigationStack.js +580 -0
  26. package/lib/module/components/RouteEventDetailContent.js +487 -0
  27. package/lib/module/components/RouteEventExpandedContent.js +183 -0
  28. package/lib/module/components/RouteEventItemCompact.js +171 -0
  29. package/lib/module/components/RouteEventsModalWithTabs.js +557 -0
  30. package/lib/module/components/RouteEventsTimeline.js +78 -0
  31. package/lib/module/components/RouteFilterViewV2.js +38 -0
  32. package/lib/module/components/RoutesSitemap.js +944 -0
  33. package/lib/module/expoRouterStore.js +98 -0
  34. package/lib/module/index.js +23 -0
  35. package/lib/module/preset.js +79 -0
  36. package/lib/module/useNavigationStack.js +238 -0
  37. package/lib/module/useRouteObserver.js +70 -0
  38. package/lib/module/useRouteSitemap.js +229 -0
  39. package/lib/module/utils/safeExpoRouter.js +120 -0
  40. package/lib/module/utils/safeReactNavigation.js +98 -0
  41. package/lib/typescript/RouteObserver.d.ts +37 -0
  42. package/lib/typescript/RouteObserver.d.ts.map +1 -0
  43. package/lib/typescript/RouteParser.d.ts +129 -0
  44. package/lib/typescript/RouteParser.d.ts.map +1 -0
  45. package/lib/typescript/RouteTracker.d.ts +29 -0
  46. package/lib/typescript/RouteTracker.d.ts.map +1 -0
  47. package/lib/typescript/components/NavigationStack.d.ts +11 -0
  48. package/lib/typescript/components/NavigationStack.d.ts.map +1 -0
  49. package/lib/typescript/components/RouteEventDetailContent.d.ts +21 -0
  50. package/lib/typescript/components/RouteEventDetailContent.d.ts.map +1 -0
  51. package/lib/typescript/components/RouteEventExpandedContent.d.ts +16 -0
  52. package/lib/typescript/components/RouteEventExpandedContent.d.ts.map +1 -0
  53. package/lib/typescript/components/RouteEventItemCompact.d.ts +15 -0
  54. package/lib/typescript/components/RouteEventItemCompact.d.ts.map +1 -0
  55. package/lib/typescript/components/RouteEventsModalWithTabs.d.ts +15 -0
  56. package/lib/typescript/components/RouteEventsModalWithTabs.d.ts.map +1 -0
  57. package/lib/typescript/components/RouteEventsTimeline.d.ts +17 -0
  58. package/lib/typescript/components/RouteEventsTimeline.d.ts.map +1 -0
  59. package/lib/typescript/components/RouteFilterViewV2.d.ts +9 -0
  60. package/lib/typescript/components/RouteFilterViewV2.d.ts.map +1 -0
  61. package/lib/typescript/components/RoutesSitemap.d.ts +15 -0
  62. package/lib/typescript/components/RoutesSitemap.d.ts.map +1 -0
  63. package/lib/typescript/expoRouterStore.d.ts +28 -0
  64. package/lib/typescript/expoRouterStore.d.ts.map +1 -0
  65. package/lib/typescript/index.d.ts +18 -0
  66. package/lib/typescript/index.d.ts.map +1 -0
  67. package/lib/typescript/preset.d.ts +76 -0
  68. package/lib/typescript/preset.d.ts.map +1 -0
  69. package/lib/typescript/useNavigationStack.d.ts +48 -0
  70. package/lib/typescript/useNavigationStack.d.ts.map +1 -0
  71. package/lib/typescript/useRouteObserver.d.ts +27 -0
  72. package/lib/typescript/useRouteObserver.d.ts.map +1 -0
  73. package/lib/typescript/useRouteSitemap.d.ts +102 -0
  74. package/lib/typescript/useRouteSitemap.d.ts.map +1 -0
  75. package/lib/typescript/utils/safeExpoRouter.d.ts +13 -0
  76. package/lib/typescript/utils/safeExpoRouter.d.ts.map +1 -0
  77. package/lib/typescript/utils/safeReactNavigation.d.ts +10 -0
  78. package/lib/typescript/utils/safeReactNavigation.d.ts.map +1 -0
  79. package/package.json +72 -0
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * RouteEventItemCompact - Compact list item for route events
5
+ *
6
+ * Uses CompactRow pattern matching network/storage components
7
+ */
8
+
9
+ import { useMemo } from "react";
10
+ import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
11
+ import { CompactRow, formatRelativeTime, buoyColors } from "@buoy-gg/shared-ui";
12
+ import { RouteEventExpandedContent } from "./RouteEventExpandedContent";
13
+
14
+ // Route type for color coding
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ // Infer route template from pathname and segments
17
+ function getRouteTemplate(pathname, segments) {
18
+ if (!segments || segments.length === 0) return null;
19
+ const templateParts = segments.map(segment => {
20
+ // Check if this segment appears to be a dynamic parameter
21
+ if (/^\d+$/.test(segment)) {
22
+ return "[id]";
23
+ }
24
+ if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment)) {
25
+ return "[id]";
26
+ }
27
+ return segment;
28
+ });
29
+ const template = "/" + templateParts.join("/");
30
+ return template !== pathname ? template : null;
31
+ }
32
+
33
+ // Get route type for color coding
34
+ function getRouteType(event) {
35
+ if (event.pathname === "/") {
36
+ return "home";
37
+ }
38
+ if (getRouteTemplate(event.pathname, event.segments)) {
39
+ return "dynamic";
40
+ }
41
+ if (event.params && Object.keys(event.params).length > 0) {
42
+ return "with-params";
43
+ }
44
+ return "default";
45
+ }
46
+
47
+ // Get color for route type
48
+ function getRouteTypeColor(routeType) {
49
+ switch (routeType) {
50
+ case "home":
51
+ return buoyColors.success;
52
+ // Teal
53
+ case "dynamic":
54
+ return buoyColors.primary;
55
+ // Teal
56
+ case "with-params":
57
+ return buoyColors.warning;
58
+ // Orange
59
+ default:
60
+ return buoyColors.border;
61
+ // Gray
62
+ }
63
+ }
64
+
65
+ // Get status label (route type name)
66
+ function getStatusLabel(routeType) {
67
+ switch (routeType) {
68
+ case "home":
69
+ return "Home";
70
+ case "dynamic":
71
+ return "Dynamic";
72
+ case "with-params":
73
+ return "Params";
74
+ default:
75
+ return "Static";
76
+ }
77
+ }
78
+
79
+ // Get secondary text (param count + route type)
80
+ function getSecondaryText(event, routeType) {
81
+ const hasParams = event.params && Object.keys(event.params).length > 0;
82
+ if (!hasParams) {
83
+ return undefined;
84
+ }
85
+ const paramCount = Object.keys(event.params).length;
86
+ const paramText = `${paramCount} param${paramCount !== 1 ? 's' : ''}`;
87
+ return `${paramText} • ${getStatusLabel(routeType)}`;
88
+ }
89
+ export function RouteEventItemCompact({
90
+ event,
91
+ visitNumber,
92
+ isExpanded,
93
+ onPress,
94
+ onNavigate
95
+ }) {
96
+ const routeType = useMemo(() => getRouteType(event), [event]);
97
+ const routeTemplate = useMemo(() => getRouteTemplate(event.pathname, event.segments), [event.pathname, event.segments]);
98
+ const statusColor = useMemo(() => getRouteTypeColor(routeType), [routeType]);
99
+ const statusLabel = useMemo(() => getStatusLabel(routeType), [routeType]);
100
+ const secondaryText = useMemo(() => getSecondaryText(event, routeType), [event, routeType]);
101
+ const timeLabel = useMemo(() => formatRelativeTime(new Date(event.timestamp)), [event.timestamp]);
102
+ const expandedContent = useMemo(() => {
103
+ if (!isExpanded) return undefined;
104
+ return /*#__PURE__*/_jsx(RouteEventExpandedContent, {
105
+ event: event,
106
+ visitNumber: visitNumber,
107
+ routeTemplate: routeTemplate
108
+ });
109
+ }, [isExpanded, event, visitNumber, routeTemplate]);
110
+ const customBadge = useMemo(() => {
111
+ if (!onNavigate) {
112
+ return /*#__PURE__*/_jsx(Text, {
113
+ style: styles.timeText,
114
+ children: timeLabel
115
+ });
116
+ }
117
+ return /*#__PURE__*/_jsxs(View, {
118
+ style: styles.badgeContainer,
119
+ children: [/*#__PURE__*/_jsx(Text, {
120
+ style: styles.timeText,
121
+ children: timeLabel
122
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
123
+ style: styles.goButton,
124
+ onPress: e => {
125
+ e.stopPropagation();
126
+ onNavigate(event.pathname);
127
+ },
128
+ children: /*#__PURE__*/_jsx(Text, {
129
+ style: styles.goButtonText,
130
+ children: "Go"
131
+ })
132
+ })]
133
+ });
134
+ }, [timeLabel, onNavigate, event.pathname]);
135
+ return /*#__PURE__*/_jsx(CompactRow, {
136
+ statusDotColor: statusColor,
137
+ statusLabel: statusLabel,
138
+ primaryText: event.pathname,
139
+ secondaryText: secondaryText,
140
+ customBadge: customBadge,
141
+ showChevron: true,
142
+ expandedContent: expandedContent,
143
+ isExpanded: isExpanded,
144
+ expandedGlowColor: statusColor,
145
+ onPress: onPress
146
+ });
147
+ }
148
+ const styles = StyleSheet.create({
149
+ badgeContainer: {
150
+ flexDirection: "row",
151
+ alignItems: "center",
152
+ gap: 6
153
+ },
154
+ timeText: {
155
+ fontSize: 10,
156
+ color: buoyColors.textMuted,
157
+ fontFamily: "monospace"
158
+ },
159
+ goButton: {
160
+ backgroundColor: buoyColors.primary,
161
+ paddingHorizontal: 8,
162
+ paddingVertical: 4,
163
+ borderRadius: 4
164
+ },
165
+ goButtonText: {
166
+ fontSize: 10,
167
+ fontWeight: "600",
168
+ color: "#FFFFFF",
169
+ fontFamily: "monospace"
170
+ }
171
+ });