@rpcbase/client 0.309.0 → 0.310.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.
package/dist/index.js CHANGED
@@ -165,6 +165,7 @@ const hydrateSsrFallbackIfPresent = (rootElement, renderErrorExtra) => {
165
165
  return true;
166
166
  };
167
167
  const initWithRoutes = async (routesElement, opts) => {
168
+ const enableRouterInstrumentation = env.ROUTER_DEBUG === "1" || env.ROUTER_DEBUG === "true" || env.ROUTER_DEBUG === true;
168
169
  const rootElement = getRootElement();
169
170
  if (hydrateSsrFallbackIfPresent(rootElement, opts?.renderErrorExtra)) {
170
171
  return;
@@ -174,7 +175,61 @@ const initWithRoutes = async (routesElement, opts) => {
174
175
  handleServerErrors();
175
176
  const routes = createRoutesFromElements(routesElement);
176
177
  const router = createBrowserRouter(routes, {
177
- basename: "/"
178
+ basename: "/",
179
+ ...enableRouterInstrumentation ? {
180
+ unstable_instrumentations: [{
181
+ router(router2) {
182
+ router2.instrument({
183
+ navigate: async (handler, info) => {
184
+ console.info("[rr7 navigate]", info);
185
+ const result = await handler();
186
+ if (result?.status === "error") {
187
+ console.error("[rr7 navigate error]", result.error);
188
+ }
189
+ },
190
+ fetch: async (handler, info) => {
191
+ console.info("[rr7 fetch]", info);
192
+ const result = await handler();
193
+ if (result?.status === "error") {
194
+ console.error("[rr7 fetch error]", result.error);
195
+ }
196
+ }
197
+ });
198
+ },
199
+ route(route) {
200
+ route.instrument({
201
+ loader: async (handler, info) => {
202
+ console.info("[rr7 loader]", route.id, info);
203
+ const result = await handler();
204
+ if (result?.status === "error") {
205
+ console.error("[rr7 loader error]", route.id, result.error);
206
+ }
207
+ },
208
+ action: async (handler, info) => {
209
+ console.info("[rr7 action]", route.id, info);
210
+ const result = await handler();
211
+ if (result?.status === "error") {
212
+ console.error("[rr7 action error]", route.id, result.error);
213
+ }
214
+ },
215
+ middleware: async (handler, info) => {
216
+ console.info("[rr7 middleware]", route.id, info);
217
+ const result = await handler();
218
+ if (result?.status === "error") {
219
+ console.error("[rr7 middleware error]", route.id, result.error);
220
+ }
221
+ },
222
+ lazy: async (handler, info) => {
223
+ console.info("[rr7 lazy]", route.id, info);
224
+ const result = await handler();
225
+ if (result?.status === "error") {
226
+ console.error("[rr7 lazy error]", route.id, result.error);
227
+ }
228
+ }
229
+ });
230
+ }
231
+ }]
232
+ } : {}
178
233
  });
179
234
  const toError = (error) => error instanceof Error ? error : new Error(String(error));
180
235
  const mentionsHydration = (value, depth = 0) => {
@@ -1 +1 @@
1
- {"version":3,"file":"initWithRoutes.d.ts","sourceRoot":"","sources":["../src/initWithRoutes.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAc,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAsB,wBAAwB,EAAiB,MAAM,iBAAiB,CAAA;AAK7F,OAAO,EAGL,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAkCxB,KAAK,qBAAqB,GAAG;IAC3B,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAA;CAC9D,CAAA;AAED,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAA;AA8BnE,eAAO,MAAM,cAAc,GACzB,eAAe,aAAa,EAC5B,OAAO,qBAAqB,kBAiF7B,CAAA"}
1
+ {"version":3,"file":"initWithRoutes.d.ts","sourceRoot":"","sources":["../src/initWithRoutes.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAc,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAsB,wBAAwB,EAAiB,MAAM,iBAAiB,CAAA;AAK7F,OAAO,EAGL,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAkCxB,KAAK,qBAAqB,GAAG;IAC3B,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAA;CAC9D,CAAA;AAED,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAA;AA8BnE,eAAO,MAAM,cAAc,GACzB,eAAe,aAAa,EAC5B,OAAO,qBAAqB,kBA4I7B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.309.0",
3
+ "version": "0.310.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"