@uniformdev/next-app-router 20.7.1-alpha.136 → 20.48.1-alpha.11

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
@@ -347,11 +347,25 @@ async function handleRateLimits(callApi) {
347
347
  }
348
348
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
349
349
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
350
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
350
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
351
351
  backoffRetriesLeft -= 1;
352
352
  }
353
353
  return response;
354
354
  }
355
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
356
+ function rewriteFiltersForApi(filters) {
357
+ return Object.entries(filters != null ? filters : {}).reduce(
358
+ (acc, [key, value]) => {
359
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
360
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
361
+ return {
362
+ ...acc,
363
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
364
+ };
365
+ },
366
+ {}
367
+ );
368
+ }
355
369
  var _url;
356
370
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
357
371
  constructor(options) {
@@ -1135,20 +1149,6 @@ function createLimitPolicy({
1135
1149
  return currentFunc();
1136
1150
  };
1137
1151
  }
1138
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1139
- function rewriteFilters(filters) {
1140
- return Object.entries(filters != null ? filters : {}).reduce(
1141
- (acc, [key, value]) => {
1142
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1143
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1144
- return {
1145
- ...acc,
1146
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1147
- };
1148
- },
1149
- {}
1150
- );
1151
- }
1152
1152
  var CANVAS_URL = "/api/v1/canvas";
1153
1153
  var CanvasClient = class extends ApiClient {
1154
1154
  constructor(options) {
@@ -1164,7 +1164,7 @@ var CanvasClient = class extends ApiClient {
1164
1164
  async getCompositionList(params = {}) {
1165
1165
  const { projectId } = this.options;
1166
1166
  const { resolveData, filters, ...originParams } = params;
1167
- const rewrittenFilters = rewriteFilters(filters);
1167
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1168
1168
  if (!resolveData) {
1169
1169
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
1170
1170
  return this.apiClient(fetchUri);
@@ -1284,7 +1284,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1284
1284
  getEntries(options) {
1285
1285
  const { projectId } = this.options;
1286
1286
  const { skipDataResolution, filters, ...params } = options;
1287
- const rewrittenFilters = rewriteFilters(filters);
1287
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1288
1288
  if (skipDataResolution) {
1289
1289
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1290
1290
  return this.apiClient(url);
@@ -1477,13 +1477,19 @@ function parseVariableExpression(serialized, onToken) {
1477
1477
  bufferEndIndex = index + 1;
1478
1478
  continue;
1479
1479
  }
1480
- state = "variable";
1481
- if (bufferEndIndex > bufferStartIndex) {
1480
+ if (state === "variable") {
1481
+ const textStart = bufferStartIndex - variablePrefix.length;
1482
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1483
+ return tokenCount;
1484
+ }
1485
+ bufferStartIndex = bufferEndIndex;
1486
+ } else if (bufferEndIndex > bufferStartIndex) {
1482
1487
  if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1483
1488
  return tokenCount;
1484
1489
  }
1485
1490
  bufferStartIndex = bufferEndIndex;
1486
1491
  }
1492
+ state = "variable";
1487
1493
  index += variablePrefix.length - 1;
1488
1494
  bufferStartIndex += variablePrefix.length;
1489
1495
  continue;
@@ -1505,11 +1511,11 @@ function parseVariableExpression(serialized, onToken) {
1505
1511
  }
1506
1512
  bufferEndIndex++;
1507
1513
  }
1508
- if (bufferEndIndex > bufferStartIndex) {
1509
- if (state === "variable") {
1510
- state = "text";
1511
- bufferStartIndex -= variablePrefix.length;
1512
- }
1514
+ if (state === "variable") {
1515
+ state = "text";
1516
+ bufferStartIndex -= variablePrefix.length;
1517
+ }
1518
+ if (bufferStartIndex < serialized.length) {
1513
1519
  handleToken(serialized.substring(bufferStartIndex), state);
1514
1520
  }
1515
1521
  return tokenCount;
@@ -1870,6 +1876,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1870
1876
  _baseUrl = /* @__PURE__ */ new WeakMap();
1871
1877
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1872
1878
  var _url22;
1879
+ var _projectsUrl;
1873
1880
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1874
1881
  constructor(options) {
1875
1882
  super({ ...options, bypassCache: true });
@@ -1879,6 +1886,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1879
1886
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1880
1887
  return await this.apiClient(fetchUri);
1881
1888
  }
1889
+ /**
1890
+ * Fetches projects grouped by team.
1891
+ * When teamId is provided, returns a single team with its projects.
1892
+ * When omitted, returns all accessible teams and their projects.
1893
+ */
1894
+ async getProjects(options) {
1895
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1896
+ return await this.apiClient(fetchUri);
1897
+ }
1882
1898
  /** Updates or creates (based on id) a Project */
1883
1899
  async upsert(body) {
1884
1900
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1898,7 +1914,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1898
1914
  }
1899
1915
  };
1900
1916
  _url22 = /* @__PURE__ */ new WeakMap();
1917
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1901
1918
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1919
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1902
1920
  var ROUTE_URL = "/api/v1/route";
1903
1921
  var RouteClient = class extends ApiClient {
1904
1922
  constructor(options) {
@@ -2000,8 +2018,15 @@ var isIncontextEditingEnabled = ({
2000
2018
  var isDevelopmentEnvironment = () => {
2001
2019
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
2002
2020
  };
2021
+ var shouldIgnoreRedirects = ({ state }) => {
2022
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
2023
+ return isNotPublished ? true : void 0;
2024
+ };
2003
2025
 
2004
2026
  // src/clients/cache.ts
2027
+ var isSpecificCacheMode = (options) => {
2028
+ return "cache" in options;
2029
+ };
2005
2030
  var isStateCacheMode = (options) => {
2006
2031
  return "state" in options;
2007
2032
  };
@@ -2028,7 +2053,9 @@ var resolveCache = ({
2028
2053
  }) => {
2029
2054
  let cache2 = void 0;
2030
2055
  if (options) {
2031
- if (isStateCacheMode(options)) {
2056
+ if (isSpecificCacheMode(options)) {
2057
+ cache2 = options.cache;
2058
+ } else if (isStateCacheMode(options)) {
2032
2059
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
2033
2060
  cache2 = {
2034
2061
  type: "no-cache",
@@ -2672,7 +2699,7 @@ var getRouteClient = (options) => {
2672
2699
 
2673
2700
  // src/components/UniformComposition.tsx
2674
2701
  var import_core = require("@uniformdev/canvas-react/core");
2675
- var import_next_app_router_client4 = require("@uniformdev/next-app-router-client");
2702
+ var import_next_app_router_client5 = require("@uniformdev/next-app-router-client");
2676
2703
  var import_next_app_router_shared4 = require("@uniformdev/next-app-router-shared");
2677
2704
  var import_navigation = require("next/navigation");
2678
2705
  var import_react6 = __toESM(require("react"));
@@ -2766,6 +2793,13 @@ var createTestComponentProps = ({
2766
2793
  test
2767
2794
  }) => {
2768
2795
  var _a;
2796
+ if (pageState.isPrefetch) {
2797
+ return {
2798
+ ...common,
2799
+ index: void 0,
2800
+ test
2801
+ };
2802
+ }
2769
2803
  const component = (0, import_next_app_router_shared2.resolveComponentFromPageState)({
2770
2804
  pageState,
2771
2805
  componentId
@@ -2804,6 +2838,7 @@ var applyEditableParameters = ({
2804
2838
  };
2805
2839
 
2806
2840
  // src/components/Test.tsx
2841
+ var import_next_app_router_client2 = require("@uniformdev/next-app-router-client");
2807
2842
  var import_react2 = require("react");
2808
2843
 
2809
2844
  // src/components/ContextTestTransfer.tsx
@@ -2816,7 +2851,14 @@ var ContextTestTransfer = ({ event }) => {
2816
2851
  // src/components/Test.tsx
2817
2852
  var Test = ({ index, slots, test, component, context: compositionContext }) => {
2818
2853
  var _a, _b, _c, _d, _e, _f;
2819
- const indexToShow = typeof index === "number" ? (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null : null;
2854
+ if (typeof index !== "number") {
2855
+ return (0, import_react2.createElement)(import_next_app_router_client2.ClientTest, {
2856
+ slots,
2857
+ test,
2858
+ context: compositionContext
2859
+ });
2860
+ }
2861
+ const indexToShow = (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null;
2820
2862
  const event = {
2821
2863
  name: test.name,
2822
2864
  control: (_d = (_c = test.variations[index]) == null ? void 0 : _c.control) != null ? _d : false,
@@ -2848,7 +2890,7 @@ var UniformCompositionWrapper = ({
2848
2890
  };
2849
2891
 
2850
2892
  // src/components/UniformContext.tsx
2851
- var import_next_app_router_client2 = require("@uniformdev/next-app-router-client");
2893
+ var import_next_app_router_client3 = require("@uniformdev/next-app-router-client");
2852
2894
  var import_react4 = __toESM(require("react"));
2853
2895
 
2854
2896
  // src/config/helpers.ts
@@ -2873,6 +2915,9 @@ var getQuirkSerialization = () => {
2873
2915
  return true;
2874
2916
  };
2875
2917
  var getMiddlewareRuntimeCache = () => {
2918
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
2919
+ return false;
2920
+ }
2876
2921
  if (typeof import_resolved.default.middlewareRuntimeCache === "boolean") {
2877
2922
  return import_resolved.default.middlewareRuntimeCache;
2878
2923
  }
@@ -2898,7 +2943,7 @@ var UniformContext = async ({ clientContextComponent, result }) => {
2898
2943
  dynamicInputs: route.dynamicInputs,
2899
2944
  matchedRoute: route.matchedRoute
2900
2945
  } : void 0;
2901
- const ContextComponent = clientContextComponent || import_next_app_router_client2.DefaultUniformClientContext;
2946
+ const ContextComponent = clientContextComponent || import_next_app_router_client3.DefaultUniformClientContext;
2902
2947
  const disableDevTools = getDisabledDevTools();
2903
2948
  const defaultConsent = (_a = result == null ? void 0 : result.pageState.defaultConsent) != null ? _a : getDefaultConsent();
2904
2949
  const experimentalQuirkSerialization = getQuirkSerialization();
@@ -2915,14 +2960,14 @@ var UniformContext = async ({ clientContextComponent, result }) => {
2915
2960
  };
2916
2961
 
2917
2962
  // src/components/VisibilityRulesWrapper.tsx
2918
- var import_next_app_router_client3 = require("@uniformdev/next-app-router-client");
2963
+ var import_next_app_router_client4 = require("@uniformdev/next-app-router-client");
2919
2964
  var import_react5 = __toESM(require("react"));
2920
2965
  var VisibilityRulesWrapper = ({
2921
2966
  parameter,
2922
2967
  initialIsVisible,
2923
2968
  children
2924
2969
  }) => {
2925
- return /* @__PURE__ */ import_react5.default.createElement(import_next_app_router_client3.VisibilityRulesWrapperClient, { parameter, initialIsVisible }, children);
2970
+ return /* @__PURE__ */ import_react5.default.createElement(import_next_app_router_client4.VisibilityRulesWrapperClient, { parameter, initialIsVisible }, children);
2926
2971
  };
2927
2972
 
2928
2973
  // src/components/UniformComposition.tsx
@@ -2985,7 +3030,7 @@ async function UniformCompositionInner({
2985
3030
  route
2986
3031
  }
2987
3032
  }
2988
- )), (pageState.compositionState === CANVAS_EDITOR_STATE || pageState.compositionState === CANVAS_DRAFT_STATE) && /* @__PURE__ */ import_react6.default.createElement(import_next_app_router_client4.UniformScript, null));
3033
+ )), (pageState.compositionState === CANVAS_EDITOR_STATE || pageState.compositionState === CANVAS_DRAFT_STATE) && /* @__PURE__ */ import_react6.default.createElement(import_next_app_router_client5.UniformScript, null));
2989
3034
  }
2990
3035
  var resolveComponents = ({
2991
3036
  target,
@@ -3081,7 +3126,7 @@ var resolveComponents = ({
3081
3126
  }
3082
3127
  let tagElement = null;
3083
3128
  if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
3084
- tagElement = (0, import_react6.createElement)(import_next_app_router_client4.ContextUpdateTransfer, {
3129
+ tagElement = (0, import_react6.createElement)(import_next_app_router_client5.ContextUpdateTransfer, {
3085
3130
  key: `${slotName}-${componentIndex}-tags`,
3086
3131
  update: {
3087
3132
  enrichments: enrichmentTags
@@ -3156,7 +3201,7 @@ var createResolvedComponent = ({
3156
3201
  componentId: component._id,
3157
3202
  pageState
3158
3203
  });
3159
- return (0, import_react6.createElement)(import_next_app_router_client4.Personalize, { ...personalizeProps, key });
3204
+ return (0, import_react6.createElement)(import_next_app_router_client5.Personalize, { ...personalizeProps, key });
3160
3205
  }
3161
3206
  if (component.type === CANVAS_TEST_TYPE) {
3162
3207
  const extractedTest = extractTest({
@@ -3592,7 +3637,8 @@ var generatePossiblePageStates = ({
3592
3637
  defaultConsent: void 0,
3593
3638
  previewMode: void 0,
3594
3639
  rules: void 0,
3595
- locale
3640
+ locale,
3641
+ isPrefetch: void 0
3596
3642
  };
3597
3643
  const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
3598
3644
  return allStates.map((payload) => (0, import_next_app_router_shared8.serializeEvaluationResult)({ payload }));
@@ -3644,7 +3690,10 @@ var DefaultDataClient = class {
3644
3690
  }
3645
3691
  }
3646
3692
  const manifest = await getManifest({
3647
- cache: {
3693
+ cache: isDevelopmentEnvironment() ? {
3694
+ type: "no-cache",
3695
+ bypassCache: true
3696
+ } : {
3648
3697
  type: "force-cache"
3649
3698
  }
3650
3699
  });
@@ -3747,12 +3796,13 @@ var DefaultDataClient = class {
3747
3796
  };
3748
3797
  }
3749
3798
  async getRoutePageState(options) {
3799
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
3750
3800
  const routeClient = getRouteClient({
3751
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
3752
- type: "force-cache"
3753
- } : {
3801
+ cache: shouldBypassCache ? {
3754
3802
  type: "no-cache",
3755
3803
  bypassCache: true
3804
+ } : {
3805
+ type: "force-cache"
3756
3806
  }
3757
3807
  });
3758
3808
  const originalRoute = {
@@ -3760,7 +3810,8 @@ var DefaultDataClient = class {
3760
3810
  state: options.pageState.compositionState,
3761
3811
  withComponentIDs: true,
3762
3812
  releaseId: options.pageState.releaseId,
3763
- locale: options.pageState.locale
3813
+ locale: options.pageState.locale,
3814
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
3764
3815
  };
3765
3816
  const resolvedRoute = await this.getRouteFromApi({
3766
3817
  source: "pageState",
package/dist/index.mjs CHANGED
@@ -320,11 +320,25 @@ async function handleRateLimits(callApi) {
320
320
  }
321
321
  const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
322
322
  const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
323
- await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
323
+ await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
324
324
  backoffRetriesLeft -= 1;
325
325
  }
326
326
  return response;
327
327
  }
328
+ var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
329
+ function rewriteFiltersForApi(filters) {
330
+ return Object.entries(filters != null ? filters : {}).reduce(
331
+ (acc, [key, value]) => {
332
+ const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
333
+ const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
334
+ return {
335
+ ...acc,
336
+ [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
337
+ };
338
+ },
339
+ {}
340
+ );
341
+ }
328
342
  var _url;
329
343
  var _AggregateClient = class _AggregateClient2 extends ApiClient {
330
344
  constructor(options) {
@@ -1108,20 +1122,6 @@ function createLimitPolicy({
1108
1122
  return currentFunc();
1109
1123
  };
1110
1124
  }
1111
- var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
1112
- function rewriteFilters(filters) {
1113
- return Object.entries(filters != null ? filters : {}).reduce(
1114
- (acc, [key, value]) => {
1115
- const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
1116
- const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
1117
- return {
1118
- ...acc,
1119
- [lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
1120
- };
1121
- },
1122
- {}
1123
- );
1124
- }
1125
1125
  var CANVAS_URL = "/api/v1/canvas";
1126
1126
  var CanvasClient = class extends ApiClient {
1127
1127
  constructor(options) {
@@ -1137,7 +1137,7 @@ var CanvasClient = class extends ApiClient {
1137
1137
  async getCompositionList(params = {}) {
1138
1138
  const { projectId } = this.options;
1139
1139
  const { resolveData, filters, ...originParams } = params;
1140
- const rewrittenFilters = rewriteFilters(filters);
1140
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1141
1141
  if (!resolveData) {
1142
1142
  const fetchUri = this.createUrl(CANVAS_URL, { ...originParams, projectId, ...rewrittenFilters });
1143
1143
  return this.apiClient(fetchUri);
@@ -1257,7 +1257,7 @@ var _ContentClient = class _ContentClient2 extends ApiClient {
1257
1257
  getEntries(options) {
1258
1258
  const { projectId } = this.options;
1259
1259
  const { skipDataResolution, filters, ...params } = options;
1260
- const rewrittenFilters = rewriteFilters(filters);
1260
+ const rewrittenFilters = rewriteFiltersForApi(filters);
1261
1261
  if (skipDataResolution) {
1262
1262
  const url = this.createUrl(__privateGet2(_ContentClient2, _entriesUrl), { ...params, ...rewrittenFilters, projectId });
1263
1263
  return this.apiClient(url);
@@ -1450,13 +1450,19 @@ function parseVariableExpression(serialized, onToken) {
1450
1450
  bufferEndIndex = index + 1;
1451
1451
  continue;
1452
1452
  }
1453
- state = "variable";
1454
- if (bufferEndIndex > bufferStartIndex) {
1453
+ if (state === "variable") {
1454
+ const textStart = bufferStartIndex - variablePrefix.length;
1455
+ if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
1456
+ return tokenCount;
1457
+ }
1458
+ bufferStartIndex = bufferEndIndex;
1459
+ } else if (bufferEndIndex > bufferStartIndex) {
1455
1460
  if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
1456
1461
  return tokenCount;
1457
1462
  }
1458
1463
  bufferStartIndex = bufferEndIndex;
1459
1464
  }
1465
+ state = "variable";
1460
1466
  index += variablePrefix.length - 1;
1461
1467
  bufferStartIndex += variablePrefix.length;
1462
1468
  continue;
@@ -1478,11 +1484,11 @@ function parseVariableExpression(serialized, onToken) {
1478
1484
  }
1479
1485
  bufferEndIndex++;
1480
1486
  }
1481
- if (bufferEndIndex > bufferStartIndex) {
1482
- if (state === "variable") {
1483
- state = "text";
1484
- bufferStartIndex -= variablePrefix.length;
1485
- }
1487
+ if (state === "variable") {
1488
+ state = "text";
1489
+ bufferStartIndex -= variablePrefix.length;
1490
+ }
1491
+ if (bufferStartIndex < serialized.length) {
1486
1492
  handleToken(serialized.substring(bufferStartIndex), state);
1487
1493
  }
1488
1494
  return tokenCount;
@@ -1843,6 +1849,7 @@ var _IntegrationPropertyEditorsClient = class _IntegrationPropertyEditorsClient2
1843
1849
  _baseUrl = /* @__PURE__ */ new WeakMap();
1844
1850
  __privateAdd2(_IntegrationPropertyEditorsClient, _baseUrl, "/api/v1/integration-property-editors");
1845
1851
  var _url22;
1852
+ var _projectsUrl;
1846
1853
  var _ProjectClient = class _ProjectClient2 extends ApiClient {
1847
1854
  constructor(options) {
1848
1855
  super({ ...options, bypassCache: true });
@@ -1852,6 +1859,15 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1852
1859
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22), { ...options });
1853
1860
  return await this.apiClient(fetchUri);
1854
1861
  }
1862
+ /**
1863
+ * Fetches projects grouped by team.
1864
+ * When teamId is provided, returns a single team with its projects.
1865
+ * When omitted, returns all accessible teams and their projects.
1866
+ */
1867
+ async getProjects(options) {
1868
+ const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _projectsUrl), options ? { ...options } : {});
1869
+ return await this.apiClient(fetchUri);
1870
+ }
1855
1871
  /** Updates or creates (based on id) a Project */
1856
1872
  async upsert(body) {
1857
1873
  const fetchUri = this.createUrl(__privateGet2(_ProjectClient2, _url22));
@@ -1871,7 +1887,9 @@ var _ProjectClient = class _ProjectClient2 extends ApiClient {
1871
1887
  }
1872
1888
  };
1873
1889
  _url22 = /* @__PURE__ */ new WeakMap();
1890
+ _projectsUrl = /* @__PURE__ */ new WeakMap();
1874
1891
  __privateAdd2(_ProjectClient, _url22, "/api/v1/project");
1892
+ __privateAdd2(_ProjectClient, _projectsUrl, "/api/v1/projects");
1875
1893
  var ROUTE_URL = "/api/v1/route";
1876
1894
  var RouteClient = class extends ApiClient {
1877
1895
  constructor(options) {
@@ -1973,8 +1991,15 @@ var isIncontextEditingEnabled = ({
1973
1991
  var isDevelopmentEnvironment = () => {
1974
1992
  return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
1975
1993
  };
1994
+ var shouldIgnoreRedirects = ({ state }) => {
1995
+ const isNotPublished = state !== CANVAS_PUBLISHED_STATE;
1996
+ return isNotPublished ? true : void 0;
1997
+ };
1976
1998
 
1977
1999
  // src/clients/cache.ts
2000
+ var isSpecificCacheMode = (options) => {
2001
+ return "cache" in options;
2002
+ };
1978
2003
  var isStateCacheMode = (options) => {
1979
2004
  return "state" in options;
1980
2005
  };
@@ -2001,7 +2026,9 @@ var resolveCache = ({
2001
2026
  }) => {
2002
2027
  let cache2 = void 0;
2003
2028
  if (options) {
2004
- if (isStateCacheMode(options)) {
2029
+ if (isSpecificCacheMode(options)) {
2030
+ cache2 = options.cache;
2031
+ } else if (isStateCacheMode(options)) {
2005
2032
  if (options.state === CANVAS_DRAFT_STATE || options.state === CANVAS_EDITOR_STATE) {
2006
2033
  cache2 = {
2007
2034
  type: "no-cache",
@@ -2743,6 +2770,13 @@ var createTestComponentProps = ({
2743
2770
  test
2744
2771
  }) => {
2745
2772
  var _a;
2773
+ if (pageState.isPrefetch) {
2774
+ return {
2775
+ ...common,
2776
+ index: void 0,
2777
+ test
2778
+ };
2779
+ }
2746
2780
  const component = resolveComponentFromPageState({
2747
2781
  pageState,
2748
2782
  componentId
@@ -2781,6 +2815,7 @@ var applyEditableParameters = ({
2781
2815
  };
2782
2816
 
2783
2817
  // src/components/Test.tsx
2818
+ import { ClientTest } from "@uniformdev/next-app-router-client";
2784
2819
  import { createElement, Fragment } from "react";
2785
2820
 
2786
2821
  // src/components/ContextTestTransfer.tsx
@@ -2793,7 +2828,14 @@ var ContextTestTransfer = ({ event }) => {
2793
2828
  // src/components/Test.tsx
2794
2829
  var Test = ({ index, slots, test, component, context: compositionContext }) => {
2795
2830
  var _a, _b, _c, _d, _e, _f;
2796
- const indexToShow = typeof index === "number" ? (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null : null;
2831
+ if (typeof index !== "number") {
2832
+ return createElement(ClientTest, {
2833
+ slots,
2834
+ test,
2835
+ context: compositionContext
2836
+ });
2837
+ }
2838
+ const indexToShow = (_b = (_a = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]) != null ? _b : null;
2797
2839
  const event = {
2798
2840
  name: test.name,
2799
2841
  control: (_d = (_c = test.variations[index]) == null ? void 0 : _c.control) != null ? _d : false,
@@ -2850,6 +2892,9 @@ var getQuirkSerialization = () => {
2850
2892
  return true;
2851
2893
  };
2852
2894
  var getMiddlewareRuntimeCache = () => {
2895
+ if (process.env.NODE_ENV === "development" && !process.env.RUNTIME_CACHE_ENDPOINT) {
2896
+ return false;
2897
+ }
2853
2898
  if (typeof config.middlewareRuntimeCache === "boolean") {
2854
2899
  return config.middlewareRuntimeCache;
2855
2900
  }
@@ -3571,7 +3616,8 @@ var generatePossiblePageStates = ({
3571
3616
  defaultConsent: void 0,
3572
3617
  previewMode: void 0,
3573
3618
  rules: void 0,
3574
- locale
3619
+ locale,
3620
+ isPrefetch: void 0
3575
3621
  };
3576
3622
  const allStates = generateStatesRecursively(dependencyMap, void 0, initialState);
3577
3623
  return allStates.map((payload) => serializeEvaluationResult({ payload }));
@@ -3623,7 +3669,10 @@ var DefaultDataClient = class {
3623
3669
  }
3624
3670
  }
3625
3671
  const manifest = await getManifest({
3626
- cache: {
3672
+ cache: isDevelopmentEnvironment() ? {
3673
+ type: "no-cache",
3674
+ bypassCache: true
3675
+ } : {
3627
3676
  type: "force-cache"
3628
3677
  }
3629
3678
  });
@@ -3726,12 +3775,13 @@ var DefaultDataClient = class {
3726
3775
  };
3727
3776
  }
3728
3777
  async getRoutePageState(options) {
3778
+ const shouldBypassCache = options.pageState.compositionState !== CANVAS_PUBLISHED_STATE || isDevelopmentEnvironment();
3729
3779
  const routeClient = getRouteClient({
3730
- cache: options.pageState.compositionState === CANVAS_PUBLISHED_STATE ? {
3731
- type: "force-cache"
3732
- } : {
3780
+ cache: shouldBypassCache ? {
3733
3781
  type: "no-cache",
3734
3782
  bypassCache: true
3783
+ } : {
3784
+ type: "force-cache"
3735
3785
  }
3736
3786
  });
3737
3787
  const originalRoute = {
@@ -3739,7 +3789,8 @@ var DefaultDataClient = class {
3739
3789
  state: options.pageState.compositionState,
3740
3790
  withComponentIDs: true,
3741
3791
  releaseId: options.pageState.releaseId,
3742
- locale: options.pageState.locale
3792
+ locale: options.pageState.locale,
3793
+ ignoreRedirects: shouldIgnoreRedirects({ state: options.pageState.compositionState })
3743
3794
  };
3744
3795
  const resolvedRoute = await this.getRouteFromApi({
3745
3796
  source: "pageState",