@buoy-gg/route-events 7.0.29 → 7.0.31

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.
@@ -118,6 +118,49 @@ const routeEventsSyncAdapter = exports.routeEventsSyncAdapter = {
118
118
  clearEvents: () => {
119
119
  _routeEventStore.routeEventStore.clearEvents();
120
120
  },
121
+ /**
122
+ * Just where the app is right now — no sitemap, no history.
123
+ *
124
+ * The full snapshot carries the parsed route tree, which is the wrong
125
+ * thing to hand a caller that polls (the macro recorder reads this several
126
+ * times a second to notice a screen change). Reading the last route event
127
+ * is also what makes this honest about apps with no <RouteTracker />: they
128
+ * get `{ path: null }` rather than a plausible-looking guess.
129
+ */
130
+ getCurrentRoute: () => {
131
+ // BaseEventStore is newest-FIRST, and the store only captures while
132
+ // something is subscribed.
133
+ const latest = _routeEventStore.routeEventStore.getEvents()[0];
134
+ if (latest) {
135
+ return {
136
+ path: latest.pathname,
137
+ params: toWireParams(latest.params),
138
+ at: latest.timestamp,
139
+ source: "event"
140
+ };
141
+ }
142
+ // Nothing has navigated yet — which is exactly the state a freshly
143
+ // launched app is in, and exactly when a macro recorder needs to know
144
+ // where it is starting from. The live stack knows even when the history
145
+ // is empty, so falling back to it is the difference between a macro that
146
+ // can run from anywhere and one that only works if you happen to be on
147
+ // the screen it was recorded from.
148
+ const focused = _navigationStackStore.navigationStackStore.getStack().find(item => item.isFocused) ?? _navigationStackStore.navigationStackStore.getStack().slice(-1)[0];
149
+ if (focused?.pathname) {
150
+ return {
151
+ path: focused.pathname,
152
+ params: toWireParams(focused.params ?? {}),
153
+ at: null,
154
+ source: "stack"
155
+ };
156
+ }
157
+ return {
158
+ path: null,
159
+ params: {},
160
+ at: null,
161
+ source: null
162
+ };
163
+ },
121
164
  /**
122
165
  * Navigate the device to a concrete path. The dashboard resolves any
123
166
  * dynamic params into a concrete path before invoking this.
@@ -116,6 +116,49 @@ export const routeEventsSyncAdapter = {
116
116
  clearEvents: () => {
117
117
  routeEventStore.clearEvents();
118
118
  },
119
+ /**
120
+ * Just where the app is right now — no sitemap, no history.
121
+ *
122
+ * The full snapshot carries the parsed route tree, which is the wrong
123
+ * thing to hand a caller that polls (the macro recorder reads this several
124
+ * times a second to notice a screen change). Reading the last route event
125
+ * is also what makes this honest about apps with no <RouteTracker />: they
126
+ * get `{ path: null }` rather than a plausible-looking guess.
127
+ */
128
+ getCurrentRoute: () => {
129
+ // BaseEventStore is newest-FIRST, and the store only captures while
130
+ // something is subscribed.
131
+ const latest = routeEventStore.getEvents()[0];
132
+ if (latest) {
133
+ return {
134
+ path: latest.pathname,
135
+ params: toWireParams(latest.params),
136
+ at: latest.timestamp,
137
+ source: "event"
138
+ };
139
+ }
140
+ // Nothing has navigated yet — which is exactly the state a freshly
141
+ // launched app is in, and exactly when a macro recorder needs to know
142
+ // where it is starting from. The live stack knows even when the history
143
+ // is empty, so falling back to it is the difference between a macro that
144
+ // can run from anywhere and one that only works if you happen to be on
145
+ // the screen it was recorded from.
146
+ const focused = navigationStackStore.getStack().find(item => item.isFocused) ?? navigationStackStore.getStack().slice(-1)[0];
147
+ if (focused?.pathname) {
148
+ return {
149
+ path: focused.pathname,
150
+ params: toWireParams(focused.params ?? {}),
151
+ at: null,
152
+ source: "stack"
153
+ };
154
+ }
155
+ return {
156
+ path: null,
157
+ params: {},
158
+ at: null,
159
+ source: null
160
+ };
161
+ },
119
162
  /**
120
163
  * Navigate the device to a concrete path. The dashboard resolves any
121
164
  * dynamic params into a concrete path before invoking this.
@@ -52,6 +52,31 @@ export declare const routeEventsSyncAdapter: {
52
52
  subscribe: (onChange: () => void) => () => void;
53
53
  actions: {
54
54
  clearEvents: () => void;
55
+ /**
56
+ * Just where the app is right now — no sitemap, no history.
57
+ *
58
+ * The full snapshot carries the parsed route tree, which is the wrong
59
+ * thing to hand a caller that polls (the macro recorder reads this several
60
+ * times a second to notice a screen change). Reading the last route event
61
+ * is also what makes this honest about apps with no <RouteTracker />: they
62
+ * get `{ path: null }` rather than a plausible-looking guess.
63
+ */
64
+ getCurrentRoute: () => {
65
+ path: string;
66
+ params: Record<string, string | string[]>;
67
+ at: number;
68
+ source: "event";
69
+ } | {
70
+ path: string;
71
+ params: Record<string, any>;
72
+ at: null;
73
+ source: "stack";
74
+ } | {
75
+ path: null;
76
+ params: {};
77
+ at: null;
78
+ source: null;
79
+ };
55
80
  /**
56
81
  * Navigate the device to a concrete path. The dashboard resolves any
57
82
  * dynamic params into a concrete path before invoking this.
@@ -1 +1 @@
1
- {"version":3,"file":"routeEventsSyncAdapter.d.ts","sourceRoot":"","sources":["../../../src/sync/routeEventsSyncAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,QAAY,CAAC;AA4BrD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,mEAAmE;IACnE,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,8EAA8E;IAC9E,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAWD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;;uBAEhB,sBAAsB;0BAKjB,MAAM,IAAI;;;QAkC9B;;;WAGG;4BACiB,OAAO;;;;wCAsBK,OAAO;;;mCAUZ,OAAO;;;;;;;;;;CAuBrC,CAAC"}
1
+ {"version":3,"file":"routeEventsSyncAdapter.d.ts","sourceRoot":"","sources":["../../../src/sync/routeEventsSyncAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,QAAY,CAAC;AA4BrD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,mEAAmE;IACnE,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,8EAA8E;IAC9E,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAWD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;;uBAEhB,sBAAsB;0BAKjB,MAAM,IAAI;;;QAkC9B;;;;;;;;WAQG;;;;;;;;;;;;;;;;;QAgCH;;;WAGG;4BACiB,OAAO;;;;wCAsBK,OAAO;;;mCAUZ,OAAO;;;;;;;;;;CAuBrC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/route-events",
3
- "version": "7.0.29",
3
+ "version": "7.0.31",
4
4
  "description": "Navigation devtool for React Native — live stack, full sitemap, jump to any screen. Expo Router & React Navigation. Part of Buoy devtools.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -26,11 +26,11 @@
26
26
  ],
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
- "@buoy-gg/floating-tools-core": "^7.0.29",
30
- "@buoy-gg/shared-ui": "^7.0.29"
29
+ "@buoy-gg/shared-ui": "^7.0.31",
30
+ "@buoy-gg/floating-tools-core": "^7.0.31"
31
31
  },
32
32
  "peerDependencies": {
33
- "@buoy-gg/license": "7.0.29",
33
+ "@buoy-gg/license": "7.0.31",
34
34
  "@react-native-async-storage/async-storage": "^2.0.0 || ^3.1.0",
35
35
  "@react-navigation/native": "*",
36
36
  "expo-router": "*",
@@ -52,7 +52,7 @@
52
52
  "@types/react-native": "^0.73.0",
53
53
  "expo-router": "~5.0.7",
54
54
  "typescript": "~5.8.3",
55
- "@buoy-gg/license": "^7.0.29"
55
+ "@buoy-gg/license": "^7.0.31"
56
56
  },
57
57
  "react-native-builder-bob": {
58
58
  "source": "src",