@hubspot/cms-dev-server 1.0.37 → 1.0.43

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/run.js CHANGED
@@ -780,8 +780,8 @@ import path8 from "path";
780
780
  import { normalizePath as normalizePath5 } from "vite";
781
781
 
782
782
  // src/lib/fullOriginalUrlFromRequest.ts
783
- function fullOriginalUrlFromRequest(request2) {
784
- return `${request2.protocol}://${request2.get("host")}${request2.originalUrl}`;
783
+ function fullOriginalUrlFromRequest(request) {
784
+ return `${request.protocol}://${request.get("host")}${request.originalUrl}`;
785
785
  }
786
786
 
787
787
  // src/lib/renderPartial.ts
@@ -811,7 +811,7 @@ function packagePath(metaUrl, projectPath) {
811
811
  );
812
812
  }
813
813
 
814
- // ../cms-js-internal/dist/types-BxnmA6nH.js
814
+ // ../cms-js-internal/dist/types-Bqf9htWu.js
815
815
  import path3 from "path";
816
816
  import { createHash } from "crypto";
817
817
  import fs2, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1048,9 +1048,7 @@ function getCMSAssetConfig(webRoot2) {
1048
1048
  var ENABLED_FEATURES_GATE_MAP = {
1049
1049
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
1050
1050
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
1051
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
1052
- "cms:jsr:clientOnlySupplementalFieldSerialization": "CMS:JSRenderer:ClientOnlySupplementalFieldSerialization",
1053
- "cms:react:unifiedThemePreview": "CMS:React:UnifiedThemePreview"
1051
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
1054
1052
  };
1055
1053
  function isUngatedFor(gates, gate) {
1056
1054
  return gates.includes(gate);
@@ -1190,7 +1188,7 @@ import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
1190
1188
  import * as cmsComponents from "@hubspot/cms-components";
1191
1189
  import { ServerRenderContext } from "@hubspot/cms-components";
1192
1190
  var { setProperty, getProperty, hasProperty } = dotProp;
1193
- var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
1191
+ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1194
1192
  const islandsArrayToSerialize = tweakedIslandsArray.map(
1195
1193
  ({
1196
1194
  id,
@@ -1236,7 +1234,7 @@ var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestD
1236
1234
  if (filteredSupplementalFieldValues) {
1237
1235
  output.supplementalFieldValues = filteredSupplementalFieldValues;
1238
1236
  }
1239
- if (isUngatedForClientOnlySupplementalFieldSerialization && output.clientOnly) {
1237
+ if (output.clientOnly) {
1240
1238
  output.supplementalFieldValues = supplementalFieldValues;
1241
1239
  }
1242
1240
  return output;
@@ -1334,7 +1332,7 @@ function getPerServerRequestUrls(perServerRequestData, viteDevServer) {
1334
1332
  });
1335
1333
  return perServerRequestDataWithUrls;
1336
1334
  }
1337
- var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
1335
+ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {
1338
1336
  const islands = getIslandUrls(roots, viteDevServer);
1339
1337
  const perServerRequestDataWithUrls = getPerServerRequestUrls(
1340
1338
  perServerRequestData,
@@ -1346,8 +1344,7 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
1346
1344
  islands,
1347
1345
  perServerRequestData,
1348
1346
  indent,
1349
- prettyPrint,
1350
- isUngatedForClientOnlySupplementalFieldSerialization
1347
+ prettyPrint
1351
1348
  )}${writeSharedStateToJsGlobal(
1352
1349
  islands,
1353
1350
  perServerRequestDataWithUrls,
@@ -2008,11 +2005,6 @@ var criticalDevErrorsToServerMessages_default = criticalDevErrorsToServerMessage
2008
2005
 
2009
2006
  // src/lib/templates.ts
2010
2007
  var { readFile } = fsPromises;
2011
- var getIsUngatedForClientOnlySupplementalFieldSerialization = (gates) => {
2012
- return gates.includes(
2013
- "CMS:JSRenderer:ClientOnlySupplementalFieldSerialization"
2014
- );
2015
- };
2016
2008
  var generateIslandSetupScriptBlock = () => {
2017
2009
  return `
2018
2010
  <script type="module">
@@ -2076,7 +2068,6 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, tit
2076
2068
  title,
2077
2069
  `${globalScriptBlock}${serverLogScript}`
2078
2070
  );
2079
- const isUngatedForClientOnlySupplementalFieldSerialization = getIsUngatedForClientOnlySupplementalFieldSerialization(jsRenderingGates);
2080
2071
  htmlTemplate = htmlTemplate.replace(
2081
2072
  "<!--islandsglobal-->",
2082
2073
  `<script>
@@ -2085,8 +2076,7 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, tit
2085
2076
  renderContext.perServerRequestData,
2086
2077
  viteServer,
2087
2078
  6,
2088
- prettyPrint,
2089
- isUngatedForClientOnlySupplementalFieldSerialization
2079
+ prettyPrint
2090
2080
  )}
2091
2081
  </script>
2092
2082
  `
@@ -2114,15 +2104,13 @@ var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerReque
2114
2104
  "/",
2115
2105
  generateIslandSetupScriptBlock()
2116
2106
  );
2117
- const isUngatedForClientOnlySupplementalFieldSerialization = getIsUngatedForClientOnlySupplementalFieldSerialization(gates);
2118
2107
  return `${islandRuntimeScript}
2119
2108
  <script>${createIslandsGlobalJsForClientInDev2(
2120
2109
  sortedIslandRoots,
2121
2110
  perServerRequestData,
2122
2111
  viteServer,
2123
2112
  4,
2124
- prettyPrint,
2125
- isUngatedForClientOnlySupplementalFieldSerialization
2113
+ prettyPrint
2126
2114
  )}</script>
2127
2115
  `;
2128
2116
  };
@@ -2166,7 +2154,7 @@ function trackUsage(action) {
2166
2154
  eventName: EVENT_NAME,
2167
2155
  action,
2168
2156
  nodeVersion: getNodeVersionData(),
2169
- version: "1.0.37",
2157
+ version: "1.0.43",
2170
2158
  os: getPlatform()
2171
2159
  };
2172
2160
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2913,8 +2901,8 @@ function isModuleFolderChild(filePath) {
2913
2901
  // src/lib/previewUtils.ts
2914
2902
  import path5 from "path";
2915
2903
  var removePreviewPrefix = (t2) => t2.split("/").slice(2).join("/");
2916
- var getPreviewUrl = (request2, queryParams) => {
2917
- const { authedPortalId, authedEnv, authedHublet, sslEnabled } = request2.app.locals;
2904
+ var getPreviewUrl = (request, queryParams) => {
2905
+ const { authedPortalId, authedEnv, authedHublet, sslEnabled } = request.app.locals;
2918
2906
  const protocol = sslEnabled ? "https" : "http";
2919
2907
  return `${protocol}://${authedPortalId}.hubspotpreview${authedEnv === "qa" ? "qa" : ""}-${authedHublet}.com/_hcms/preview/template/multi?${stringify(queryParams)}`;
2920
2908
  };
@@ -3053,11 +3041,11 @@ async function initiatePreviewSession(authedPortalId, absoluteWebRoot, themePrev
3053
3041
  }
3054
3042
 
3055
3043
  // src/proxyPage/proxyPage.ts
3056
- var getEntryPointBasePathFromProxyRequest = (request2) => {
3057
- if (!request2) {
3044
+ var getEntryPointBasePathFromProxyRequest = (request) => {
3045
+ if (!request) {
3058
3046
  return "";
3059
3047
  }
3060
- const { path: requestPath, pathParamDict } = request2;
3048
+ const { path: requestPath, pathParamDict } = request;
3061
3049
  if (!pathParamDict || !pathParamDict.dynamic_slug) {
3062
3050
  return requestPath;
3063
3051
  }
@@ -3250,7 +3238,7 @@ function renderComponentForPlaceholderModule(viteServer, resolvedPath, localModu
3250
3238
  }
3251
3239
  );
3252
3240
  }
3253
- async function proxySpecificPage(request2, response, portalId, hublet, contentId, webRoot2, viteServer, projectName, projectComponentPath, jsRenderingGates, urlToProxy, fullOriginalUrl) {
3241
+ async function proxySpecificPage(request, response, portalId, hublet, contentId, webRoot2, viteServer, projectName, projectComponentPath, jsRenderingGates, urlToProxy, fullOriginalUrl) {
3254
3242
  let accountId;
3255
3243
  let proxyEnv;
3256
3244
  const prettyPrint = isDebugUrlString3(urlToProxy);
@@ -3290,8 +3278,8 @@ async function proxySpecificPage(request2, response, portalId, hublet, contentId
3290
3278
  projectName,
3291
3279
  environmentConfig,
3292
3280
  jsRenderingGates,
3293
- request2.get("COOKIE"),
3294
- request2.app.locals.localPreviewToken
3281
+ request.get("COOKIE"),
3282
+ request.app.locals.localPreviewToken
3295
3283
  )).data;
3296
3284
  pageHtml = addRefreshScript(pageHtml);
3297
3285
  await infillReactModulesAndWriteResponse(
@@ -3494,7 +3482,7 @@ async function signUrl(authedPortalId, unsignedUrl, requestBody) {
3494
3482
  const formData = {
3495
3483
  module: [JSON.stringify(requestBody)]
3496
3484
  };
3497
- const request2 = {
3485
+ const request = {
3498
3486
  unsignedUrl,
3499
3487
  httpMethod: "POST",
3500
3488
  formData
@@ -3506,7 +3494,7 @@ async function signUrl(authedPortalId, unsignedUrl, requestBody) {
3506
3494
  "Content-Type": "application/json",
3507
3495
  Accept: "application/json"
3508
3496
  },
3509
- data: JSON.stringify(request2)
3497
+ data: JSON.stringify(request)
3510
3498
  });
3511
3499
  return response.data.signedUrl;
3512
3500
  } catch (error) {
@@ -3635,7 +3623,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
3635
3623
 
3636
3624
  // src/routes/partial.ts
3637
3625
  import { join as joinPosix3 } from "path/posix";
3638
- var partialRouteHandler = async (request2, response) => {
3626
+ var partialRouteHandler = async (request, response) => {
3639
3627
  sendTrackingRequest("view-partial-route");
3640
3628
  const {
3641
3629
  authedPortalId,
@@ -3646,8 +3634,8 @@ var partialRouteHandler = async (request2, response) => {
3646
3634
  jsRenderingGates,
3647
3635
  projectName,
3648
3636
  projectComponentPath
3649
- } = request2.app.locals;
3650
- const partialName = request2.params.partial;
3637
+ } = request.app.locals;
3638
+ const partialName = request.params.partial;
3651
3639
  const baseTemplatePath = packagePath(
3652
3640
  import.meta.url,
3653
3641
  "html/baseTemplate.html"
@@ -3682,7 +3670,7 @@ var partialRouteHandler = async (request2, response) => {
3682
3670
  viteServer,
3683
3671
  partialPath,
3684
3672
  {},
3685
- fullOriginalUrlFromRequest(request2),
3673
+ fullOriginalUrlFromRequest(request),
3686
3674
  basePath,
3687
3675
  environmentConfig,
3688
3676
  {
@@ -3724,7 +3712,7 @@ var partialRouteHandler = async (request2, response) => {
3724
3712
  remoteModule.path,
3725
3713
  authedPortalId,
3726
3714
  authedEnv,
3727
- request2.get("COOKIE")
3715
+ request.get("COOKIE")
3728
3716
  ).then((result) => ({
3729
3717
  remoteModule,
3730
3718
  result
@@ -3748,8 +3736,8 @@ var partialRouteHandler = async (request2, response) => {
3748
3736
  jsRenderingGates,
3749
3737
  projectName,
3750
3738
  projectComponentPath,
3751
- fullOriginalUrlFromRequest(request2),
3752
- request2.get("COOKIE")
3739
+ fullOriginalUrlFromRequest(request),
3740
+ request.get("COOKIE")
3753
3741
  ).then((result) => ({
3754
3742
  localProjectModule,
3755
3743
  result
@@ -3777,7 +3765,7 @@ var partialRouteHandler = async (request2, response) => {
3777
3765
  }
3778
3766
  const htmlShell = await createHtmlShellDependingOnRenderContext(
3779
3767
  baseTemplatePath,
3780
- request2.originalUrl,
3768
+ request.originalUrl,
3781
3769
  `Partial: ${partialPath}`,
3782
3770
  renderContext,
3783
3771
  viteServer,
@@ -3827,8 +3815,8 @@ function PartialsList({ webRoot: webRoot2, partialNames }) {
3827
3815
 
3828
3816
  // src/routes/linksToAllPartialsRouteHandler.tsx
3829
3817
  import { jsx as jsx3 } from "react/jsx-runtime";
3830
- var linksToAllPartialRouteHandler = async (request2, response) => {
3831
- const { webRoot: webRoot2 } = request2.app.locals;
3818
+ var linksToAllPartialRouteHandler = async (request, response) => {
3819
+ const { webRoot: webRoot2 } = request.app.locals;
3832
3820
  const { partialNames } = findAllPartialsInRoot(webRoot2);
3833
3821
  const { html: responseHtml } = await renderOnServer(
3834
3822
  /* @__PURE__ */ jsx3(PartialsList, { webRoot: webRoot2, partialNames })
@@ -3865,8 +3853,8 @@ var ModulesList_default = ModulesList;
3865
3853
 
3866
3854
  // src/routes/linksToAllModulesRouteHandler.tsx
3867
3855
  import { jsx as jsx5 } from "react/jsx-runtime";
3868
- var linksToAllModuleRouteHandler = async (request2, response) => {
3869
- const { webRoot: webRoot2 } = request2.app.locals;
3856
+ var linksToAllModuleRouteHandler = async (request, response) => {
3857
+ const { webRoot: webRoot2 } = request.app.locals;
3870
3858
  const { moduleNames } = findAllModulesInRoot(webRoot2);
3871
3859
  const { html: responseHtml } = await renderOnServer(
3872
3860
  /* @__PURE__ */ jsx5(ModulesList_default, { webRoot: webRoot2, moduleNames })
@@ -3879,7 +3867,7 @@ var linksToAllModulesRouteHandler_default = linksToAllModuleRouteHandler;
3879
3867
  import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
3880
3868
  import path9 from "path";
3881
3869
  import { normalizePath as normalizePath6 } from "vite";
3882
- var moduleRouteHandler = async (request2, response) => {
3870
+ var moduleRouteHandler = async (request, response) => {
3883
3871
  sendTrackingRequest("view-module-route");
3884
3872
  const {
3885
3873
  authedPortalId,
@@ -3890,8 +3878,8 @@ var moduleRouteHandler = async (request2, response) => {
3890
3878
  jsRenderingGates,
3891
3879
  projectName,
3892
3880
  projectComponentPath
3893
- } = request2.app.locals;
3894
- const moduleName = request2.params.moduleName;
3881
+ } = request.app.locals;
3882
+ const moduleName = request.params.moduleName;
3895
3883
  const baseTemplatePath = packagePath(
3896
3884
  import.meta.url,
3897
3885
  "html/baseTemplate.html"
@@ -3909,16 +3897,16 @@ var moduleRouteHandler = async (request2, response) => {
3909
3897
  ].join("/")
3910
3898
  );
3911
3899
  let fieldOverrides = null;
3912
- if (request2.query.fields) {
3900
+ if (request.query.fields) {
3913
3901
  try {
3914
- if (typeof request2.query.fields === "string") {
3902
+ if (typeof request.query.fields === "string") {
3915
3903
  fieldOverrides = JSON.parse(
3916
- decodeURIComponent(request2.query.fields.replace(/\+/g, "%20"))
3904
+ decodeURIComponent(request.query.fields.replace(/\+/g, "%20"))
3917
3905
  );
3918
3906
  }
3919
3907
  } catch (e) {
3920
3908
  console.error(
3921
- `Error parsing field param for module ${moduleName}: ${request2.query.fields}`
3909
+ `Error parsing field param for module ${moduleName}: ${request.query.fields}`
3922
3910
  );
3923
3911
  }
3924
3912
  }
@@ -3944,7 +3932,7 @@ var moduleRouteHandler = async (request2, response) => {
3944
3932
  hublParameters: {},
3945
3933
  moduleName: `local-${moduleName}`
3946
3934
  },
3947
- fullOriginalUrlFromRequest(request2),
3935
+ fullOriginalUrlFromRequest(request),
3948
3936
  basePath,
3949
3937
  environmentConfig,
3950
3938
  {
@@ -3953,7 +3941,7 @@ var moduleRouteHandler = async (request2, response) => {
3953
3941
  );
3954
3942
  const htmlShell = await createHtmlShellDependingOnRenderContext(
3955
3943
  baseTemplatePath,
3956
- request2.originalUrl,
3944
+ request.originalUrl,
3957
3945
  `Module: ${modulePath}`,
3958
3946
  renderContext,
3959
3947
  viteServer,
@@ -4026,11 +4014,11 @@ async function renderModuleFieldsJson(viteServer, requestedModulePath) {
4026
4014
  var renderModuleFieldsJson_default = renderModuleFieldsJson;
4027
4015
 
4028
4016
  // src/routes/moduleFieldsJson.ts
4029
- var moduleFieldsJsonRouteHandler = async (request2, response) => {
4017
+ var moduleFieldsJsonRouteHandler = async (request, response) => {
4030
4018
  try {
4031
4019
  sendTrackingRequest("fields-json-route");
4032
- const { webRoot: webRoot2, viteServer } = request2.app.locals;
4033
- const { moduleName } = request2.params;
4020
+ const { webRoot: webRoot2, viteServer } = request.app.locals;
4021
+ const { moduleName } = request.params;
4034
4022
  const modulePath = normalizePath7(
4035
4023
  path10.resolve(webRoot2, "components/modules/", moduleName)
4036
4024
  );
@@ -4141,7 +4129,7 @@ async function fetchContentMetadata(url3, portalId) {
4141
4129
  }
4142
4130
 
4143
4131
  // src/routes/proxyPageRouteHandler.ts
4144
- async function proxyPageRouteHandler(request2, response, next) {
4132
+ async function proxyPageRouteHandler(request, response, next) {
4145
4133
  sendTrackingRequest("view-proxy-page-route");
4146
4134
  const {
4147
4135
  viteServer,
@@ -4149,20 +4137,20 @@ async function proxyPageRouteHandler(request2, response, next) {
4149
4137
  projectName,
4150
4138
  projectComponentPath,
4151
4139
  jsRenderingGates
4152
- } = request2.app.locals;
4153
- if (!request2.accepts().includes("text/html")) {
4140
+ } = request.app.locals;
4141
+ if (!request.accepts().includes("text/html")) {
4154
4142
  return response.sendStatus(404);
4155
4143
  }
4156
- const fullOriginalUrl = fullOriginalUrlFromRequest(request2);
4157
- const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
4158
- const urlToProxy = `http://${domainToProxy}${request2.originalUrl}`;
4144
+ const fullOriginalUrl = fullOriginalUrlFromRequest(request);
4145
+ const domainToProxy = getSubDomainFromValidLocalDomain(request.hostname);
4146
+ const urlToProxy = `http://${domainToProxy}${request.originalUrl}`;
4159
4147
  if (!domainToProxy) {
4160
- if (VALID_PROXY_DOMAIN_SUFFIXES.includes(request2.hostname)) {
4161
- const message = `Can't make a proxy request, you need to prepend the real page's domain to '${request2.hostname}' (i.e. your.page.com.${request2.hostname})`;
4148
+ if (VALID_PROXY_DOMAIN_SUFFIXES.includes(request.hostname)) {
4149
+ const message = `Can't make a proxy request, you need to prepend the real page's domain to '${request.hostname}' (i.e. your.page.com.${request.hostname})`;
4162
4150
  consoleWarn(message);
4163
4151
  return response.status(400).send(message);
4164
4152
  } else {
4165
- const message = `Can't make a proxy request, the domain '${request2.hostname}' is not a valid proxy-able domain`;
4153
+ const message = `Can't make a proxy request, the domain '${request.hostname}' is not a valid proxy-able domain`;
4166
4154
  consoleWarn(message);
4167
4155
  return response.status(400).send(message);
4168
4156
  }
@@ -4170,10 +4158,10 @@ async function proxyPageRouteHandler(request2, response, next) {
4170
4158
  try {
4171
4159
  const { portalId, contentId, hublet } = await fetchContentMetadata(
4172
4160
  urlToProxy,
4173
- request2.app.locals.authedPortalId
4161
+ request.app.locals.authedPortalId
4174
4162
  );
4175
4163
  await proxySpecificPage(
4176
- request2,
4164
+ request,
4177
4165
  response,
4178
4166
  portalId,
4179
4167
  hublet,
@@ -4192,7 +4180,7 @@ async function proxyPageRouteHandler(request2, response, next) {
4192
4180
  }
4193
4181
 
4194
4182
  // src/routes/proxyPageResourceRedirect.ts
4195
- import request from "request";
4183
+ import fetch2 from "node-fetch";
4196
4184
  var HCMS_PATH = "/_hcms/";
4197
4185
  var HS_FS_PATH = "/hs-fs/";
4198
4186
  var HUB_FS_PATH = "/hubfs/";
@@ -4207,7 +4195,7 @@ function proxyPageResourceRedirect(req, res, next) {
4207
4195
  const pathToProxy = req.originalUrl;
4208
4196
  const urlToProxy = `https://${domainToProxy}${pathToProxy}`;
4209
4197
  if (req.method === "GET") {
4210
- request(urlToProxy).pipe(res);
4198
+ fetch2(urlToProxy).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
4211
4199
  } else {
4212
4200
  const contentType = req.headers["content-type"];
4213
4201
  const isSendingJSON = contentType && /\bjson\b/.test(req.headers["content-type"].toString());
@@ -4222,6 +4210,7 @@ function proxyPageResourceRedirect(req, res, next) {
4222
4210
  }
4223
4211
  return true;
4224
4212
  });
4213
+ const headersToPass = Object.fromEntries(headerEntries);
4225
4214
  let body = void 0;
4226
4215
  if (req.body) {
4227
4216
  if (isSendingJSON) {
@@ -4230,12 +4219,11 @@ function proxyPageResourceRedirect(req, res, next) {
4230
4219
  body = req.body.toString();
4231
4220
  }
4232
4221
  }
4233
- request({
4234
- url: urlToProxy,
4222
+ fetch2(urlToProxy, {
4235
4223
  method: req.method,
4236
- headers: Object.fromEntries(headerEntries),
4224
+ headers: headersToPass,
4237
4225
  body
4238
- }).pipe(res);
4226
+ }).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
4239
4227
  }
4240
4228
  }
4241
4229
 
@@ -4288,8 +4276,8 @@ function isCodedFile(filePath) {
4288
4276
 
4289
4277
  // src/routes/legacyRouteHandler.tsx
4290
4278
  import { Fragment, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
4291
- var legacyRouteHandler = async (request2, response, next) => {
4292
- const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
4279
+ var legacyRouteHandler = async (request, response, next) => {
4280
+ const domainToProxy = getSubDomainFromValidLocalDomain(request.hostname);
4293
4281
  if (domainToProxy) {
4294
4282
  next();
4295
4283
  return;
@@ -4300,12 +4288,8 @@ var legacyRouteHandler = async (request2, response, next) => {
4300
4288
  webRoot: webRoot2,
4301
4289
  storybookEnabled,
4302
4290
  devServerPort,
4303
- localPreviewToken,
4304
- jsRenderingGates
4305
- } = request2.app.locals;
4306
- const isUngatedForUnifiedThemePreview = jsRenderingGates.includes(
4307
- "CMS:React:UnifiedThemePreview"
4308
- );
4291
+ localPreviewToken
4292
+ } = request.app.locals;
4309
4293
  const { partialNames } = findAllPartialsInRoot(webRoot2);
4310
4294
  const { moduleNames } = findAllModulesInRoot(webRoot2);
4311
4295
  const hublModuleData = await fetchHubLModules(
@@ -4318,17 +4302,15 @@ var legacyRouteHandler = async (request2, response, next) => {
4318
4302
  );
4319
4303
  const { html: responseHtml } = await renderOnServer(
4320
4304
  /* @__PURE__ */ jsxs4(Fragment, { children: [
4321
- storybookEnabled ? /* @__PURE__ */ jsx8("h2", { children: /* @__PURE__ */ jsx8("a", { href: `//storybook.${request2.hostname}:${devServerPort}`, children: "Storybook" }) }) : null,
4305
+ storybookEnabled ? /* @__PURE__ */ jsx8("h2", { children: /* @__PURE__ */ jsx8("a", { href: `//storybook.${request.hostname}:${devServerPort}`, children: "Storybook" }) }) : null,
4322
4306
  /* @__PURE__ */ jsx8("h2", { children: "Partials" }),
4323
4307
  /* @__PURE__ */ jsx8(PartialsList, { webRoot: webRoot2, partialNames }),
4324
4308
  /* @__PURE__ */ jsx8("h2", { children: "React modules" }),
4325
4309
  /* @__PURE__ */ jsx8(ModulesList_default, { webRoot: webRoot2, moduleNames }),
4326
- isUngatedForUnifiedThemePreview && /* @__PURE__ */ jsxs4(Fragment, { children: [
4327
- /* @__PURE__ */ jsx8("h2", { children: "HubL modules" }),
4328
- /* @__PURE__ */ jsx8(HubLModulesList, { modules: hublModuleData.objects }),
4329
- /* @__PURE__ */ jsx8("h2", { children: "HubL templates" }),
4330
- /* @__PURE__ */ jsx8(HubLTemplatesList, { templates: hublTemplateData.objects })
4331
- ] })
4310
+ /* @__PURE__ */ jsx8("h2", { children: "HubL modules" }),
4311
+ /* @__PURE__ */ jsx8(HubLModulesList, { modules: hublModuleData.objects }),
4312
+ /* @__PURE__ */ jsx8("h2", { children: "HubL templates" }),
4313
+ /* @__PURE__ */ jsx8(HubLTemplatesList, { templates: hublTemplateData.objects })
4332
4314
  ] })
4333
4315
  );
4334
4316
  response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
@@ -4337,7 +4319,7 @@ var legacyRouteHandler_default = legacyRouteHandler;
4337
4319
 
4338
4320
  // src/routes/proxyPathPageRouteHandler.tsx
4339
4321
  import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
4340
- async function proxyPathPageRouteHandler(request2, response, next) {
4322
+ async function proxyPathPageRouteHandler(request, response, next) {
4341
4323
  sendTrackingRequest("view-proxy-path-route");
4342
4324
  const {
4343
4325
  viteServer,
@@ -4345,11 +4327,11 @@ async function proxyPathPageRouteHandler(request2, response, next) {
4345
4327
  projectName,
4346
4328
  projectComponentPath,
4347
4329
  jsRenderingGates
4348
- } = request2.app.locals;
4349
- if (!request2.accepts().includes("text/html")) {
4330
+ } = request.app.locals;
4331
+ if (!request.accepts().includes("text/html")) {
4350
4332
  return response.sendStatus(404);
4351
4333
  }
4352
- if (!request2.query.page) {
4334
+ if (!request.query.page) {
4353
4335
  const { html: responseHtml } = await renderOnServer(
4354
4336
  /* @__PURE__ */ jsxs5("div", { children: [
4355
4337
  /* @__PURE__ */ jsx9("h2", { children: "Local Proxy" }),
@@ -4373,7 +4355,7 @@ async function proxyPathPageRouteHandler(request2, response, next) {
4373
4355
  }
4374
4356
  let proxyPageUrl;
4375
4357
  try {
4376
- proxyPageUrl = new URL(request2.query.page);
4358
+ proxyPageUrl = new URL(request.query.page);
4377
4359
  } catch (e) {
4378
4360
  const message = "Please provide a valid page query parameter, e.g., http://localhost:3000/proxy?page=https://yourdomain.com/path";
4379
4361
  consoleWarn(message);
@@ -4388,10 +4370,10 @@ async function proxyPathPageRouteHandler(request2, response, next) {
4388
4370
  try {
4389
4371
  const { portalId, contentId, hublet } = await fetchContentMetadata(
4390
4372
  proxyPageUrl.href,
4391
- request2.app.locals.authedPortalId
4373
+ request.app.locals.authedPortalId
4392
4374
  );
4393
4375
  await proxySpecificPage(
4394
- request2,
4376
+ request,
4395
4377
  response,
4396
4378
  portalId,
4397
4379
  hublet,
@@ -4410,7 +4392,7 @@ async function proxyPathPageRouteHandler(request2, response, next) {
4410
4392
  }
4411
4393
 
4412
4394
  // src/routes/proxyPathPageResourceRedirect.ts
4413
- import fetch2 from "node-fetch";
4395
+ import fetch3 from "node-fetch";
4414
4396
  var HCMS_PATH2 = "/_hcms/";
4415
4397
  var HS_FS_PATH2 = "/hs-fs/";
4416
4398
  var HUB_FS_PATH2 = "/hubfs/";
@@ -4440,11 +4422,11 @@ function proxyPathPageResourceRedirect(req, res, next) {
4440
4422
  return;
4441
4423
  }
4442
4424
  const urlToProxy = `https://${proxyPageUrl.host}${req.url}`;
4443
- fetch2(urlToProxy).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
4425
+ fetch3(urlToProxy).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
4444
4426
  }
4445
4427
 
4446
4428
  // src/routes/proxyServerlessHandler.ts
4447
- import fetch3 from "node-fetch";
4429
+ import fetch4 from "node-fetch";
4448
4430
  var localDomains = ["localhost", "hslocal.net"];
4449
4431
  function proxyServerlessRequest(req, res, next) {
4450
4432
  const { method, headers } = req;
@@ -4497,14 +4479,14 @@ function proxyServerlessRequest(req, res, next) {
4497
4479
  case "POST":
4498
4480
  case "DELETE":
4499
4481
  case "PUT":
4500
- fetch3(urlToProxy, {
4482
+ fetch4(urlToProxy, {
4501
4483
  method,
4502
4484
  body,
4503
4485
  headers: headersToPass
4504
4486
  }).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
4505
4487
  break;
4506
4488
  default:
4507
- fetch3(urlToProxy, {
4489
+ fetch4(urlToProxy, {
4508
4490
  headers: headersToPass
4509
4491
  }).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
4510
4492
  }
@@ -4513,7 +4495,7 @@ function proxyServerlessRequest(req, res, next) {
4513
4495
  // src/routes/modulePreviewRouteHandler.ts
4514
4496
  import path11 from "path";
4515
4497
  import { normalizePath as normalizePath8 } from "vite";
4516
- async function modulePreviewRouteHandler(request2, response) {
4498
+ async function modulePreviewRouteHandler(request, response) {
4517
4499
  sendTrackingRequest("view-module-preview-route");
4518
4500
  const {
4519
4501
  authedPortalId,
@@ -4524,18 +4506,18 @@ async function modulePreviewRouteHandler(request2, response) {
4524
4506
  jsRenderingGates,
4525
4507
  projectName,
4526
4508
  projectComponentPath
4527
- } = request2.app.locals;
4528
- const moduleName = request2.params.moduleName;
4509
+ } = request.app.locals;
4510
+ const moduleName = request.params.moduleName;
4529
4511
  const modulePath = normalizePath8(
4530
4512
  path11.resolve(webRoot2, "components/modules/", moduleName)
4531
4513
  );
4532
4514
  const PREVIEWER_APP_PARAM = "hsPreviewerApp";
4533
4515
  let fieldOverrides = {};
4534
- if (request2.method === "POST" && request2.body) {
4535
- if (request2.query[PREVIEWER_APP_PARAM] === "module" && request2.body.module_data) {
4536
- fieldOverrides = request2.body.module_data;
4516
+ if (request.method === "POST" && request.body) {
4517
+ if (request.query[PREVIEWER_APP_PARAM] === "module" && request.body.module_data) {
4518
+ fieldOverrides = request.body.module_data;
4537
4519
  } else {
4538
- fieldOverrides = request2.body;
4520
+ fieldOverrides = request.body;
4539
4521
  }
4540
4522
  try {
4541
4523
  if (typeof fieldOverrides === "string") {
@@ -4553,16 +4535,16 @@ async function modulePreviewRouteHandler(request2, response) {
4553
4535
  fieldOverrides
4554
4536
  );
4555
4537
  }
4556
- } else if (request2.query.fields) {
4538
+ } else if (request.query.fields) {
4557
4539
  try {
4558
- if (typeof request2.query.fields === "string") {
4540
+ if (typeof request.query.fields === "string") {
4559
4541
  fieldOverrides = JSON.parse(
4560
- decodeURIComponent(request2.query.fields.replace(/\+/g, "%20"))
4542
+ decodeURIComponent(request.query.fields.replace(/\+/g, "%20"))
4561
4543
  );
4562
4544
  }
4563
4545
  } catch (e) {
4564
4546
  console.error(
4565
- `Error parsing field param for module ${moduleName}: ${request2.query.fields}`
4547
+ `Error parsing field param for module ${moduleName}: ${request.query.fields}`
4566
4548
  );
4567
4549
  }
4568
4550
  }
@@ -4582,8 +4564,8 @@ async function modulePreviewRouteHandler(request2, response) {
4582
4564
  jsRenderingGates,
4583
4565
  projectName,
4584
4566
  projectComponentPath,
4585
- fullOriginalUrlFromRequest(request2),
4586
- request2.get("COOKIE"),
4567
+ fullOriginalUrlFromRequest(request),
4568
+ request.get("COOKIE"),
4587
4569
  fieldOverrides
4588
4570
  );
4589
4571
  const baseTemplatePath = packagePath(
@@ -4592,7 +4574,7 @@ async function modulePreviewRouteHandler(request2, response) {
4592
4574
  );
4593
4575
  const htmlShell = await createHtmlShellDependingOnRenderContext(
4594
4576
  baseTemplatePath,
4595
- request2.originalUrl,
4577
+ request.originalUrl,
4596
4578
  `Module: ${modulePath}`,
4597
4579
  renderContext,
4598
4580
  viteServer,
@@ -4618,10 +4600,10 @@ var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
4618
4600
 
4619
4601
  // src/routes/hublModuleRouteHandler.ts
4620
4602
  import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4621
- var hublModuleRouteHandler = async (request2, response) => {
4603
+ var hublModuleRouteHandler = async (request, response) => {
4622
4604
  sendTrackingRequest("view-hubl-module-route");
4623
- const { authedPortalId, localPreviewToken } = request2.app.locals;
4624
- const { modulePath } = request2.params;
4605
+ const { authedPortalId, localPreviewToken } = request.app.locals;
4606
+ const { modulePath } = request.params;
4625
4607
  if (!modulePath) {
4626
4608
  response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
4627
4609
  return;
@@ -4637,9 +4619,9 @@ var hublModuleRouteHandler = async (request2, response) => {
4637
4619
  module_id: customWidgetInfo.moduleId,
4638
4620
  hs_preview_key: customWidgetInfo.previewKey,
4639
4621
  updated: Date.now(),
4640
- ...request2.query
4622
+ ...request.query
4641
4623
  };
4642
- const previewUrl = new URL(getPreviewUrl(request2, params));
4624
+ const previewUrl = new URL(getPreviewUrl(request, params));
4643
4625
  try {
4644
4626
  const result = (await hsCliHttp9.get(authedPortalId, {
4645
4627
  baseURL: previewUrl.origin,
@@ -4671,7 +4653,7 @@ import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4671
4653
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
4672
4654
  import { getEnv as getEnv2 } from "@hubspot/local-dev-lib/config";
4673
4655
  var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
4674
- var templateRouteHandler = async (request2, response) => {
4656
+ var templateRouteHandler = async (request, response) => {
4675
4657
  sendTrackingRequest("view-template-route");
4676
4658
  const {
4677
4659
  authedPortalId,
@@ -4681,7 +4663,7 @@ var templateRouteHandler = async (request2, response) => {
4681
4663
  webRoot: webRoot2,
4682
4664
  projectComponentPath,
4683
4665
  jsRenderingGates
4684
- } = request2.app.locals;
4666
+ } = request.app.locals;
4685
4667
  const environmentConfig = buildStaticEnvConfig5(
4686
4668
  authedPortalId,
4687
4669
  "na1",
@@ -4689,7 +4671,7 @@ var templateRouteHandler = async (request2, response) => {
4689
4671
  false,
4690
4672
  jsRenderingGates
4691
4673
  );
4692
- const { templatePath } = request2.params;
4674
+ const { templatePath } = request.params;
4693
4675
  if (!templatePath) {
4694
4676
  response.status(200).set({ "Content-Type": "text/html" }).end(buildTemplateIndex());
4695
4677
  return;
@@ -4716,10 +4698,10 @@ var templateRouteHandler = async (request2, response) => {
4716
4698
  localProxySchemaVersion: "2",
4717
4699
  hsLoginVerifyDisabled: `${true}`,
4718
4700
  hsCacheBuster: Date.now().toString(),
4719
- ...request2.query
4701
+ ...request.query
4720
4702
  };
4721
- const previewUrl = new URL(getPreviewUrl(request2, params));
4722
- const fullOriginalUrl = `${request2.protocol}://${request2.get("host")}${request2.originalUrl}`;
4703
+ const previewUrl = new URL(getPreviewUrl(request, params));
4704
+ const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
4723
4705
  try {
4724
4706
  const result = (await hsCliHttp10.get(authedPortalId, {
4725
4707
  baseURL: previewUrl.origin,
@@ -5041,7 +5023,10 @@ Custom origin: ${process.env.VITE_ORIGIN}
5041
5023
  postcss: webRoot2
5042
5024
  },
5043
5025
  envDir: webRoot2,
5044
- envPrefix: "HS_"
5026
+ envPrefix: "HS_",
5027
+ define: {
5028
+ "process.env": {}
5029
+ }
5045
5030
  };
5046
5031
  return createViteServer(viteConfig);
5047
5032
  }
@@ -5243,8 +5228,8 @@ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
5243
5228
  var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
5244
5229
  const devServerApp = Router2();
5245
5230
  const { appViteServer, appWebRoot } = appLocals || {};
5246
- devServerApp.use((request2, response, next) => {
5247
- const { method, url: url3, hostname } = request2;
5231
+ devServerApp.use((request, response, next) => {
5232
+ const { method, url: url3, hostname } = request;
5248
5233
  debug(`${method}:${hostname}${url3}`);
5249
5234
  next();
5250
5235
  });
@@ -5309,8 +5294,8 @@ import { Router as Router3 } from "express";
5309
5294
  import { getAccountId as getAccountId3 } from "@hubspot/local-dev-lib/config";
5310
5295
  import cors from "cors";
5311
5296
  function getShadowDevServerCheckHandler(devServerPort, themePath) {
5312
- return async function shadowDevServerCheckHandler(request2, response) {
5313
- const { query } = request2;
5297
+ return async function shadowDevServerCheckHandler(request, response) {
5298
+ const { query } = request;
5314
5299
  if (query) {
5315
5300
  const {
5316
5301
  hostName,
@@ -6198,12 +6183,9 @@ Local proxy functionality and module preview routes will not work without settin
6198
6183
  if (authedPortalId) {
6199
6184
  await validateHSPlatform(projectConfigPath, authedPortalId);
6200
6185
  }
6201
- const isUngatedForUnifiedThemePreview = jsRenderingGates.includes(
6202
- "CMS:React:UnifiedThemePreview"
6203
- );
6204
6186
  let _localPreviewToken = null;
6205
6187
  let _tokenStatus;
6206
- if (themePreviewOptions2 && isUngatedForUnifiedThemePreview) {
6188
+ if (themePreviewOptions2) {
6207
6189
  const { localPreviewToken, tokenStatus } = await initiatePreviewSession(
6208
6190
  authedPortalId,
6209
6191
  absoluteWebRoot,