@hubspot/cms-dev-server 0.18.10 → 0.18.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.
@@ -9,7 +9,7 @@ import { normalizePath as normalizePath2 } from "vite";
9
9
  import { createServer as createViteServer } from "vite";
10
10
  import { default as react } from "@vitejs/plugin-react";
11
11
 
12
- // ../cms-js-internal/dist/types-BXr0V0Zd.js
12
+ // ../cms-js-internal/dist/types-CGxfMR-y.js
13
13
  import path from "path";
14
14
  var viteRoot;
15
15
  var viteCommand;
@@ -211,7 +211,7 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
211
211
  return Object.fromEntries(relativeEntries);
212
212
  }
213
213
  function toRelativePath(config, path4) {
214
- return path4.replace(config.root, "");
214
+ return path4.replace(`${config.root}/`, "");
215
215
  }
216
216
  function shouldSkipModule(config, moduleInfo, code) {
217
217
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -427,7 +427,7 @@ function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__
427
427
  function filterEntryPointsToModules(entryPointCmsModuleMap) {
428
428
  return Object.fromEntries(
429
429
  Object.entries(entryPointCmsModuleMap).filter(
430
- ([entryPoint]) => entryPoint.startsWith("/components/modules/")
430
+ ([entryPoint]) => entryPoint.startsWith("components/modules/")
431
431
  )
432
432
  );
433
433
  }
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createServer as createViteServer } from "vite";
3
3
  import { default as react } from "@vitejs/plugin-react";
4
4
 
5
- // ../cms-js-internal/dist/types-BXr0V0Zd.js
5
+ // ../cms-js-internal/dist/types-CGxfMR-y.js
6
6
  import path from "path";
7
7
  import { createHash } from "crypto";
8
8
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -223,7 +223,13 @@ function findAllModulesInRoot(webRoot) {
223
223
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
224
224
  );
225
225
  const moduleSubpaths = Object.keys(allModuleComponents);
226
- return { moduleNames, moduleSubpaths };
226
+ const moduleNamesWithExtension = Object.values(allModuleComponents).map(
227
+ (path22) => {
228
+ const file = path22.replace("components/modules/", "");
229
+ return file.includes("/index.") ? file.split("/index.")[0] : file;
230
+ }
231
+ );
232
+ return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
227
233
  }
228
234
  function findAllPartialsInRoot(webRoot) {
229
235
  const allPartialComponents = findAllComponentsIn(
@@ -579,7 +585,7 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
579
585
  return Object.fromEntries(relativeEntries);
580
586
  }
581
587
  function toRelativePath(config, path13) {
582
- return path13.replace(config.root, "");
588
+ return path13.replace(`${config.root}/`, "");
583
589
  }
584
590
  function shouldSkipModule(config, moduleInfo, code) {
585
591
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -795,7 +801,7 @@ function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__
795
801
  function filterEntryPointsToModules(entryPointCmsModuleMap) {
796
802
  return Object.fromEntries(
797
803
  Object.entries(entryPointCmsModuleMap).filter(
798
- ([entryPoint]) => entryPoint.startsWith("/components/modules/")
804
+ ([entryPoint]) => entryPoint.startsWith("components/modules/")
799
805
  )
800
806
  );
801
807
  }
@@ -1449,7 +1455,7 @@ function trackUsage(action) {
1449
1455
  eventName: EVENT_NAME,
1450
1456
  action,
1451
1457
  nodeVersion: getNodeVersionData(),
1452
- version: "0.18.10",
1458
+ version: "0.18.11",
1453
1459
  os: getPlatform()
1454
1460
  };
1455
1461
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -3973,7 +3979,9 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
3973
3979
  environmentConfig,
3974
3980
  gates
3975
3981
  );
3976
- const localRenderPlaceholders = findLocalRenderPlaceholders(pageHtml);
3982
+ const localRenderPlaceholders = findLocalRenderPlaceholders(
3983
+ pageHtml.data
3984
+ );
3977
3985
  if (localRenderPlaceholders.length) {
3978
3986
  hasJSBuildingBlocks = true;
3979
3987
  localProxyUrl = `http://${hostName}.hslocal.net:${devServerPort}${pathName}`;
@@ -4050,8 +4058,14 @@ import { default as react2 } from "@vitejs/plugin-react";
4050
4058
 
4051
4059
  // src/lib/getDevServerUIData.ts
4052
4060
  async function getDevServerUIData(reqLocals) {
4053
- const { themeWebRoot, authedPortalId, projectName, localPreviewToken } = reqLocals;
4054
- const { moduleNames } = findAllModulesInRoot(themeWebRoot);
4061
+ const {
4062
+ themeWebRoot,
4063
+ authedPortalId,
4064
+ projectName,
4065
+ localPreviewToken,
4066
+ webRootProjectComponentFolder
4067
+ } = reqLocals;
4068
+ const { moduleNames, moduleNamesWithExtension } = findAllModulesInRoot(themeWebRoot);
4055
4069
  const { partialNames } = findAllPartialsInRoot(themeWebRoot);
4056
4070
  const hubLModuleData = await fetchHubLModules(
4057
4071
  authedPortalId,
@@ -4067,7 +4081,9 @@ async function getDevServerUIData(reqLocals) {
4067
4081
  moduleNames,
4068
4082
  partialNames,
4069
4083
  hubLModules: (hubLModuleData == null ? void 0 : hubLModuleData.objects) || [],
4070
- hubLTemplates: (hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || []
4084
+ hubLTemplates: (hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || [],
4085
+ webRootProjectComponentFolder,
4086
+ moduleNamesWithExtension
4071
4087
  };
4072
4088
  }
4073
4089
  var getDevServerUIData_default = getDevServerUIData;
@@ -4120,18 +4136,18 @@ async function createAppServer(webRoot, reqLocals, port) {
4120
4136
  app.use(viteServer.middlewares);
4121
4137
  app.use("*", async (req, res) => {
4122
4138
  try {
4123
- const inititialProps = await getDevServerUIData_default(reqLocals);
4139
+ const initialProps = await getDevServerUIData_default(reqLocals);
4124
4140
  const url3 = req.originalUrl.replace("/", "");
4125
4141
  let template = await fs3.readFile("./app/index.html", "utf-8");
4126
4142
  template = await viteServer.transformIndexHtml(url3, template);
4127
4143
  const { render } = await viteServer.ssrLoadModule(
4128
4144
  "./app/serverEntry.tsx"
4129
4145
  );
4130
- const rendered = await render(inititialProps);
4146
+ const rendered = await render(initialProps);
4131
4147
  const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
4132
4148
  `<!--app-script-->`,
4133
4149
  `<script>window.__hsInitialProps = ${JSON.stringify(
4134
- inititialProps
4150
+ initialProps
4135
4151
  )}</script>` ?? ""
4136
4152
  );
4137
4153
  res.status(200).set({ "Content-Type": "text/html" }).send(html);
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-BXr0V0Zd.js
1
+ // ../cms-js-internal/dist/types-CGxfMR-y.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -383,7 +383,13 @@ function findAllModulesInRoot(webRoot) {
383
383
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
384
384
  );
385
385
  const moduleSubpaths = Object.keys(allModuleComponents);
386
- return { moduleNames, moduleSubpaths };
386
+ const moduleNamesWithExtension = Object.values(allModuleComponents).map(
387
+ (path2) => {
388
+ const file = path2.replace("components/modules/", "");
389
+ return file.includes("/index.") ? file.split("/index.")[0] : file;
390
+ }
391
+ );
392
+ return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
387
393
  }
388
394
  function findAllPartialsInRoot(webRoot) {
389
395
  const allPartialComponents = findAllComponentsIn(
@@ -743,7 +749,7 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
743
749
  return Object.fromEntries(relativeEntries);
744
750
  }
745
751
  function toRelativePath(config, path2) {
746
- return path2.replace(config.root, "");
752
+ return path2.replace(`${config.root}/`, "");
747
753
  }
748
754
  function shouldSkipModule(config, moduleInfo, code) {
749
755
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -959,7 +965,7 @@ function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__
959
965
  function filterEntryPointsToModules(entryPointCmsModuleMap) {
960
966
  return Object.fromEntries(
961
967
  Object.entries(entryPointCmsModuleMap).filter(
962
- ([entryPoint]) => entryPoint.startsWith("/components/modules/")
968
+ ([entryPoint]) => entryPoint.startsWith("components/modules/")
963
969
  )
964
970
  );
965
971
  }
package/dist/run.js CHANGED
@@ -790,7 +790,7 @@ function packagePath(metaUrl, projectPath) {
790
790
  );
791
791
  }
792
792
 
793
- // ../cms-js-internal/dist/types-BXr0V0Zd.js
793
+ // ../cms-js-internal/dist/types-CGxfMR-y.js
794
794
  import path3 from "path";
795
795
  import { createHash } from "crypto";
796
796
  import fs2, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1011,7 +1011,13 @@ function findAllModulesInRoot(webRoot2) {
1011
1011
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
1012
1012
  );
1013
1013
  const moduleSubpaths = Object.keys(allModuleComponents);
1014
- return { moduleNames, moduleSubpaths };
1014
+ const moduleNamesWithExtension = Object.values(allModuleComponents).map(
1015
+ (path22) => {
1016
+ const file = path22.replace("components/modules/", "");
1017
+ return file.includes("/index.") ? file.split("/index.")[0] : file;
1018
+ }
1019
+ );
1020
+ return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
1015
1021
  }
1016
1022
  function findAllPartialsInRoot(webRoot2) {
1017
1023
  const allPartialComponents = findAllComponentsIn(
@@ -1367,7 +1373,7 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
1367
1373
  return Object.fromEntries(relativeEntries);
1368
1374
  }
1369
1375
  function toRelativePath(config, path14) {
1370
- return path14.replace(config.root, "");
1376
+ return path14.replace(`${config.root}/`, "");
1371
1377
  }
1372
1378
  function shouldSkipModule(config, moduleInfo, code) {
1373
1379
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -1583,7 +1589,7 @@ function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__
1583
1589
  function filterEntryPointsToModules(entryPointCmsModuleMap) {
1584
1590
  return Object.fromEntries(
1585
1591
  Object.entries(entryPointCmsModuleMap).filter(
1586
- ([entryPoint]) => entryPoint.startsWith("/components/modules/")
1592
+ ([entryPoint]) => entryPoint.startsWith("components/modules/")
1587
1593
  )
1588
1594
  );
1589
1595
  }
@@ -2053,7 +2059,7 @@ function trackUsage(action) {
2053
2059
  eventName: EVENT_NAME,
2054
2060
  action,
2055
2061
  nodeVersion: getNodeVersionData(),
2056
- version: "0.18.10",
2062
+ version: "0.18.11",
2057
2063
  os: getPlatform()
2058
2064
  };
2059
2065
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -4577,7 +4583,9 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
4577
4583
  environmentConfig,
4578
4584
  gates
4579
4585
  );
4580
- const localRenderPlaceholders = findLocalRenderPlaceholders(pageHtml);
4586
+ const localRenderPlaceholders = findLocalRenderPlaceholders(
4587
+ pageHtml.data
4588
+ );
4581
4589
  if (localRenderPlaceholders.length) {
4582
4590
  hasJSBuildingBlocks = true;
4583
4591
  localProxyUrl = `http://${hostName}.hslocal.net:${devServerPort}${pathName}`;
@@ -4773,8 +4781,14 @@ import { default as react2 } from "@vitejs/plugin-react";
4773
4781
 
4774
4782
  // src/lib/getDevServerUIData.ts
4775
4783
  async function getDevServerUIData(reqLocals) {
4776
- const { themeWebRoot, authedPortalId, projectName, localPreviewToken } = reqLocals;
4777
- const { moduleNames } = findAllModulesInRoot(themeWebRoot);
4784
+ const {
4785
+ themeWebRoot,
4786
+ authedPortalId,
4787
+ projectName,
4788
+ localPreviewToken,
4789
+ webRootProjectComponentFolder
4790
+ } = reqLocals;
4791
+ const { moduleNames, moduleNamesWithExtension } = findAllModulesInRoot(themeWebRoot);
4778
4792
  const { partialNames } = findAllPartialsInRoot(themeWebRoot);
4779
4793
  const hubLModuleData = await fetchHubLModules(
4780
4794
  authedPortalId,
@@ -4790,7 +4804,9 @@ async function getDevServerUIData(reqLocals) {
4790
4804
  moduleNames,
4791
4805
  partialNames,
4792
4806
  hubLModules: (hubLModuleData == null ? void 0 : hubLModuleData.objects) || [],
4793
- hubLTemplates: (hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || []
4807
+ hubLTemplates: (hubLTemplateData == null ? void 0 : hubLTemplateData.objects) || [],
4808
+ webRootProjectComponentFolder,
4809
+ moduleNamesWithExtension
4794
4810
  };
4795
4811
  }
4796
4812
  var getDevServerUIData_default = getDevServerUIData;
@@ -4843,18 +4859,18 @@ async function createAppServer(webRoot2, reqLocals, port) {
4843
4859
  app.use(viteServer.middlewares);
4844
4860
  app.use("*", async (req, res) => {
4845
4861
  try {
4846
- const inititialProps = await getDevServerUIData_default(reqLocals);
4862
+ const initialProps = await getDevServerUIData_default(reqLocals);
4847
4863
  const url3 = req.originalUrl.replace("/", "");
4848
4864
  let template = await fs4.readFile("./app/index.html", "utf-8");
4849
4865
  template = await viteServer.transformIndexHtml(url3, template);
4850
4866
  const { render } = await viteServer.ssrLoadModule(
4851
4867
  "./app/serverEntry.tsx"
4852
4868
  );
4853
- const rendered = await render(inititialProps);
4869
+ const rendered = await render(initialProps);
4854
4870
  const html = template.replace(`<!--app-head-->`, rendered.head ?? "").replace(`<!--app-html-->`, rendered.html ?? "").replace(
4855
4871
  `<!--app-script-->`,
4856
4872
  `<script>window.__hsInitialProps = ${JSON.stringify(
4857
- inititialProps
4873
+ initialProps
4858
4874
  )}</script>` ?? ""
4859
4875
  );
4860
4876
  res.status(200).set({ "Content-Type": "text/html" }).send(html);
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-BXr0V0Zd.js
4
+ // ../cms-js-internal/dist/types-CGxfMR-y.js
5
5
  function namespaceModulePropsShape(props) {
6
6
  const {
7
7
  dataQueryResult,
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // ../cms-js-internal/dist/types-BXr0V0Zd.js
11
+ // ../cms-js-internal/dist/types-CGxfMR-y.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -228,7 +228,13 @@ function findAllModulesInRoot(webRoot2) {
228
228
  (moduleSubpath) => moduleSubpath.replace("components/modules/", "").replace("/index", "")
229
229
  );
230
230
  const moduleSubpaths = Object.keys(allModuleComponents);
231
- return { moduleNames, moduleSubpaths };
231
+ const moduleNamesWithExtension = Object.values(allModuleComponents).map(
232
+ (path22) => {
233
+ const file = path22.replace("components/modules/", "");
234
+ return file.includes("/index.") ? file.split("/index.")[0] : file;
235
+ }
236
+ );
237
+ return { moduleNames, moduleSubpaths, moduleNamesWithExtension };
232
238
  }
233
239
  function findAllPartialsInRoot(webRoot2) {
234
240
  const allPartialComponents = findAllComponentsIn(
@@ -294,8 +300,8 @@ function isStylesheetAsset(staticAsset) {
294
300
  return staticAsset.type === "stylesheet";
295
301
  }
296
302
  var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, badInlineJsChars, inlineJsEscapeChars, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, removeIndexFromPath, removeIndexOrTrailingJsFromPath, HEALTHCHECKS_ENABLED_DEFAULT, HEALTHCHECKS_STRICT_DEFAULT, BUILD_INFO_PATH, GATES, ENABLED_FEATURES_GATE_MAP, findAllComponentsIn;
297
- var init_types_BXr0V0Zd = __esm({
298
- "../cms-js-internal/dist/types-BXr0V0Zd.js"() {
303
+ var init_types_CGxfMR_y = __esm({
304
+ "../cms-js-internal/dist/types-CGxfMR-y.js"() {
299
305
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
300
306
  ENTRY_POINTS_PATH = "components/partials/";
301
307
  MODULE_FOLDER_PATH = "components/modules/";
@@ -709,7 +715,7 @@ function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap)
709
715
  return Object.fromEntries(relativeEntries);
710
716
  }
711
717
  function toRelativePath(config, path3) {
712
- return path3.replace(config.root, "");
718
+ return path3.replace(`${config.root}/`, "");
713
719
  }
714
720
  function shouldSkipModule(config, moduleInfo, code) {
715
721
  const isExternal = config.command !== "serve" && moduleInfo.isExternal;
@@ -925,7 +931,7 @@ function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__
925
931
  function filterEntryPointsToModules(entryPointCmsModuleMap) {
926
932
  return Object.fromEntries(
927
933
  Object.entries(entryPointCmsModuleMap).filter(
928
- ([entryPoint]) => entryPoint.startsWith("/components/modules/")
934
+ ([entryPoint]) => entryPoint.startsWith("components/modules/")
929
935
  )
930
936
  );
931
937
  }
@@ -1048,8 +1054,8 @@ function renderFieldsToJson(fields, moduleName) {
1048
1054
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1049
1055
  var init_dist = __esm({
1050
1056
  "../cms-js-internal/dist/index.js"() {
1051
- init_types_BXr0V0Zd();
1052
- init_types_BXr0V0Zd();
1057
+ init_types_CGxfMR_y();
1058
+ init_types_CGxfMR_y();
1053
1059
  ({ setProperty, getProperty, hasProperty } = dotProp);
1054
1060
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
1055
1061
  const islandsArrayToSerialize = tweakedIslandsArray.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.18.10",
3
+ "version": "0.18.11",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,10 +29,11 @@
29
29
  "@babel/parser": "^7.25.3",
30
30
  "@babel/traverse": "^7.25.3",
31
31
  "@babel/types": "^7.25.2",
32
- "@hubspot/cms-components": "^0.18.10",
32
+ "@hubspot/cms-components": "^0.18.11",
33
33
  "@hubspot/local-dev-lib": "2.0.1",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
36
+ "@radix-ui/react-dialog": "^1.1.2",
36
37
  "@radix-ui/react-separator": "^1.1.0",
37
38
  "@radix-ui/react-slot": "^1.1.0",
38
39
  "@radix-ui/react-tooltip": "^1.1.4",
@@ -130,5 +131,5 @@
130
131
  "publishConfig": {
131
132
  "access": "public"
132
133
  },
133
- "gitHead": "8a28e311b6ff9484f2a72052341c10d7d1b7f7ff"
134
+ "gitHead": "fccc2d6d1d47978c5cebc58878ea78bd9f44daee"
134
135
  }
@@ -6,6 +6,7 @@ export interface DevServerUIData {
6
6
  partialNames: string[];
7
7
  hubLModules: HubLModule[];
8
8
  hubLTemplates: HubLTemplate[];
9
+ moduleNamesWithExtension: string[];
9
10
  [key: string]: any;
10
11
  }
11
12
  export interface RequestLocals {
@@ -0,0 +1,2 @@
1
+ export declare const metaRouteHandler: (req: any, res: any) => void;
2
+ export declare const markRemoteFsDirty: () => void;