@rpcbase/client 0.312.0 → 0.314.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.
@@ -1 +1 @@
1
- {"version":3,"file":"getFeatureFlag.d.ts","sourceRoot":"","sources":["../src/getFeatureFlag.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CAuDtC,CAAA"}
1
+ {"version":3,"file":"getFeatureFlag.d.ts","sourceRoot":"","sources":["../src/getFeatureFlag.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CA8DtC,CAAA"}
package/dist/index.js CHANGED
@@ -124,7 +124,6 @@ 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;
128
127
  const isProduction = env.MODE === "production";
129
128
  const LOADER_TIMEOUT_MS = 8e3;
130
129
  const showErrorOverlay = (err) => {
@@ -201,8 +200,6 @@ const hydrateSsrFallbackIfPresent = (rootElement, renderErrorExtra) => {
201
200
  return true;
202
201
  };
203
202
  const initWithRoutes = async (routesElement, opts) => {
204
- const enableRouterInstrumentation = ROUTER_DEBUG === "1" || ROUTER_DEBUG === "true" || ROUTER_DEBUG === true;
205
- console.log("Router instrumentation enabled:", enableRouterInstrumentation);
206
203
  const rootElement = getRootElement();
207
204
  if (hydrateSsrFallbackIfPresent(rootElement, opts?.renderErrorExtra)) {
208
205
  return;
@@ -212,63 +209,7 @@ const initWithRoutes = async (routesElement, opts) => {
212
209
  handleServerErrors();
213
210
  const routes = createRoutesFromElements(routesElement);
214
211
  applyLoaderTimeouts(routes);
215
- const router = createBrowserRouter(routes, {
216
- basename: "/",
217
- ...enableRouterInstrumentation ? {
218
- unstable_instrumentations: [{
219
- router(router2) {
220
- router2.instrument({
221
- navigate: async (handler, info) => {
222
- console.info("[rr7 navigate]", info);
223
- const result = await handler();
224
- if (result?.status === "error") {
225
- console.error("[rr7 navigate error]", result.error);
226
- }
227
- },
228
- fetch: async (handler, info) => {
229
- console.info("[rr7 fetch]", info);
230
- const result = await handler();
231
- if (result?.status === "error") {
232
- console.error("[rr7 fetch error]", result.error);
233
- }
234
- }
235
- });
236
- },
237
- route(route) {
238
- route.instrument({
239
- loader: async (handler, info) => {
240
- console.info("[rr7 loader]", route.id, info);
241
- const result = await handler();
242
- if (result?.status === "error") {
243
- console.error("[rr7 loader error]", route.id, result.error);
244
- }
245
- },
246
- action: async (handler, info) => {
247
- console.info("[rr7 action]", route.id, info);
248
- const result = await handler();
249
- if (result?.status === "error") {
250
- console.error("[rr7 action error]", route.id, result.error);
251
- }
252
- },
253
- middleware: async (handler, info) => {
254
- console.info("[rr7 middleware]", route.id, info);
255
- const result = await handler();
256
- if (result?.status === "error") {
257
- console.error("[rr7 middleware error]", route.id, result.error);
258
- }
259
- },
260
- lazy: async (handler, info) => {
261
- console.info("[rr7 lazy]", route.id, info);
262
- const result = await handler();
263
- if (result?.status === "error") {
264
- console.error("[rr7 lazy error]", route.id, result.error);
265
- }
266
- }
267
- });
268
- }
269
- }]
270
- } : {}
271
- });
212
+ const router = createBrowserRouter(routes, {});
272
213
  const toError = (error) => error instanceof Error ? error : new Error(String(error));
273
214
  const mentionsHydration = (value, depth = 0) => {
274
215
  if (depth > 5) {
@@ -857,12 +798,16 @@ const getFeatureFlag = async (flag) => {
857
798
  return value;
858
799
  } else {
859
800
  let waitForFeatureFlags = function() {
860
- return new Promise((resolve) => {
801
+ return new Promise((resolve, reject) => {
861
802
  if (hasLoadedFeatureFlags) {
862
803
  resolve();
863
804
  } else {
805
+ const timeout = setTimeout(() => {
806
+ reject(new Error(`PostHog feature flags did not load within ${TIMEOUT_MS}ms`));
807
+ }, TIMEOUT_MS);
864
808
  posthog2.onFeatureFlags(() => {
865
809
  hasLoadedFeatureFlags = true;
810
+ clearTimeout(timeout);
866
811
  resolve();
867
812
  });
868
813
  }
@@ -874,6 +819,7 @@ const getFeatureFlag = async (flag) => {
874
819
  const startTime = performance.now();
875
820
  const { posthog: posthog2 } = await import("posthog-js");
876
821
  let hasLoadedFeatureFlags = false;
822
+ const TIMEOUT_MS = 8e3;
877
823
  await waitForFeatureFlags();
878
824
  const endTime = performance.now();
879
825
  console.log(`Client: Feature flag "${flag}" loaded in ${(endTime - startTime).toFixed(2)}ms`);
@@ -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;AAiFxB,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,kBA+I7B,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;AAgFxB,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,kBAgF7B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.312.0",
3
+ "version": "0.314.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"