@rpcbase/client 0.309.0 → 0.311.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 +58 -1
- package/dist/initWithRoutes.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -124,6 +124,7 @@ const SsrErrorFallback = ({ state, renderErrorExtra }) => {
|
|
|
124
124
|
extra ? /* @__PURE__ */ jsx("div", { className: "mt-10 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-center", children: extra }) : null
|
|
125
125
|
] }) });
|
|
126
126
|
};
|
|
127
|
+
const ROUTER_DEBUG = env.RB_PUBLIC_ROUTER_DEBUG;
|
|
127
128
|
const isProduction = env.MODE === "production";
|
|
128
129
|
const showErrorOverlay = (err) => {
|
|
129
130
|
const ErrorOverlay = customElements.get("vite-error-overlay");
|
|
@@ -165,6 +166,8 @@ const hydrateSsrFallbackIfPresent = (rootElement, renderErrorExtra) => {
|
|
|
165
166
|
return true;
|
|
166
167
|
};
|
|
167
168
|
const initWithRoutes = async (routesElement, opts) => {
|
|
169
|
+
const enableRouterInstrumentation = ROUTER_DEBUG === "1" || ROUTER_DEBUG === "true" || ROUTER_DEBUG === true;
|
|
170
|
+
console.log("Router instrumentation enabled:", enableRouterInstrumentation);
|
|
168
171
|
const rootElement = getRootElement();
|
|
169
172
|
if (hydrateSsrFallbackIfPresent(rootElement, opts?.renderErrorExtra)) {
|
|
170
173
|
return;
|
|
@@ -174,7 +177,61 @@ const initWithRoutes = async (routesElement, opts) => {
|
|
|
174
177
|
handleServerErrors();
|
|
175
178
|
const routes = createRoutesFromElements(routesElement);
|
|
176
179
|
const router = createBrowserRouter(routes, {
|
|
177
|
-
basename: "/"
|
|
180
|
+
basename: "/",
|
|
181
|
+
...enableRouterInstrumentation ? {
|
|
182
|
+
unstable_instrumentations: [{
|
|
183
|
+
router(router2) {
|
|
184
|
+
router2.instrument({
|
|
185
|
+
navigate: async (handler, info) => {
|
|
186
|
+
console.info("[rr7 navigate]", info);
|
|
187
|
+
const result = await handler();
|
|
188
|
+
if (result?.status === "error") {
|
|
189
|
+
console.error("[rr7 navigate error]", result.error);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
fetch: async (handler, info) => {
|
|
193
|
+
console.info("[rr7 fetch]", info);
|
|
194
|
+
const result = await handler();
|
|
195
|
+
if (result?.status === "error") {
|
|
196
|
+
console.error("[rr7 fetch error]", result.error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
route(route) {
|
|
202
|
+
route.instrument({
|
|
203
|
+
loader: async (handler, info) => {
|
|
204
|
+
console.info("[rr7 loader]", route.id, info);
|
|
205
|
+
const result = await handler();
|
|
206
|
+
if (result?.status === "error") {
|
|
207
|
+
console.error("[rr7 loader error]", route.id, result.error);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
action: async (handler, info) => {
|
|
211
|
+
console.info("[rr7 action]", route.id, info);
|
|
212
|
+
const result = await handler();
|
|
213
|
+
if (result?.status === "error") {
|
|
214
|
+
console.error("[rr7 action error]", route.id, result.error);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
middleware: async (handler, info) => {
|
|
218
|
+
console.info("[rr7 middleware]", route.id, info);
|
|
219
|
+
const result = await handler();
|
|
220
|
+
if (result?.status === "error") {
|
|
221
|
+
console.error("[rr7 middleware error]", route.id, result.error);
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
lazy: async (handler, info) => {
|
|
225
|
+
console.info("[rr7 lazy]", route.id, info);
|
|
226
|
+
const result = await handler();
|
|
227
|
+
if (result?.status === "error") {
|
|
228
|
+
console.error("[rr7 lazy error]", route.id, result.error);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}]
|
|
234
|
+
} : {}
|
|
178
235
|
});
|
|
179
236
|
const toError = (error) => error instanceof Error ? error : new Error(String(error));
|
|
180
237
|
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;
|
|
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;AAmCxB,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,kBA8I7B,CAAA"}
|