@plasmicapp/react-web 0.2.295 → 0.2.297

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/all.d.ts CHANGED
@@ -12334,7 +12334,9 @@ type Queries = {
12334
12334
  };
12335
12335
  declare function createUseScreenVariants(isMulti: boolean, screenQueries: Queries): () => string | string[] | undefined;
12336
12336
 
12337
- interface PlasmicDataSourceContextValue {
12337
+ declare const PlasmicDataSourceContextProvider: React__default.Provider<PlasmicDataSourceContextValue | undefined>;
12338
+
12339
+ declare interface PlasmicDataSourceContextValue {
12338
12340
  userAuthToken?: string | null;
12339
12341
  isUserLoading?: boolean;
12340
12342
  authRedirectUri?: string;
@@ -12347,6 +12349,7 @@ interface PlasmicDataSourceContextValue {
12347
12349
  roleNames: string[];
12348
12350
  } | null;
12349
12351
  }
12352
+
12350
12353
  declare function useCurrentUser(): {
12351
12354
  email: string;
12352
12355
  properties: Record<string, unknown> | null;
@@ -12357,7 +12360,6 @@ declare function useCurrentUser(): {
12357
12360
  } | {
12358
12361
  isLoggedIn: boolean;
12359
12362
  };
12360
- declare const PlasmicDataSourceContextProvider: React__default.Provider<PlasmicDataSourceContextValue | undefined>;
12361
12363
 
12362
12364
  /**
12363
12365
  * Returns whether the component is currently being server side rendered or
package/dist/index.cjs.js CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  var classNames$1 = require('classnames');
5
5
  var dataSourcesContext = require('@plasmicapp/data-sources-context');
6
+ var plasmicQuery = require('@plasmicapp/query');
6
7
  var React = require('react');
7
8
  var get = require('dlv');
8
9
  var host = require('@plasmicapp/host');
@@ -43,6 +44,7 @@ function _interopNamespaceDefault(e) {
43
44
  return Object.freeze(n);
44
45
  }
45
46
 
47
+ var plasmicQuery__namespace = /*#__PURE__*/_interopNamespaceDefault(plasmicQuery);
46
48
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
47
49
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
48
50
 
@@ -242,6 +244,7 @@ function triggerLogin(appId, authorizeEndpoint, redirectUri) {
242
244
  });
243
245
  }
244
246
  function PlasmicPageGuard(props) {
247
+ var _a;
245
248
  var appId = props.appId, authorizeEndpoint = props.authorizeEndpoint, minRole = props.minRole, canTriggerLogin = props.canTriggerLogin, children = props.children, unauthorizedComp = props.unauthorizedComp;
246
249
  var dataSourceCtxValue = dataSourcesContext.usePlasmicDataSourceContext();
247
250
  React.useEffect(function () {
@@ -273,6 +276,12 @@ function PlasmicPageGuard(props) {
273
276
  }
274
277
  return dataSourceCtxValue.user.roleIds.includes(minRole);
275
278
  }
279
+ // If we are in prepass, PlasmicPageGuard should not render anything
280
+ // it's expected that pages are only equipped with PlasmicPageGuard
281
+ // when it's known that it will disable prepass/prefetching
282
+ if ((_a = plasmicQuery__namespace.isPlasmicPrepass) === null || _a === void 0 ? void 0 : _a.call(plasmicQuery__namespace)) {
283
+ return null;
284
+ }
276
285
  /*
277
286
  PlasmicPageGuard has three cases:
278
287
  1. No value of dataSourceCtxValue, user is loading or a trigger login should be performed.