@hubspot/cms-dev-server 1.2.69 → 1.2.75

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.
@@ -10,7 +10,7 @@ import { createServer as createViteServer } from "vite";
10
10
  import { createRequire } from "module";
11
11
  import { default as react } from "@vitejs/plugin-react";
12
12
 
13
- // ../cms-js-internal/dist/types-CBGC9bBc.js
13
+ // ../cms-js-internal/dist/types-B-d4FeeE.js
14
14
  import path from "path";
15
15
  var viteRoot;
16
16
  var viteCommand;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { createServer as createViteServer } from "vite";
3
3
  import { createRequire } from "module";
4
4
  import { default as react } from "@vitejs/plugin-react";
5
5
 
6
- // ../cms-js-internal/dist/types-CBGC9bBc.js
6
+ // ../cms-js-internal/dist/types-B-d4FeeE.js
7
7
  import path from "path";
8
8
  import { createHash } from "crypto";
9
9
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -255,7 +255,6 @@ function isFullHeightPreviewEnabled(config) {
255
255
  return false;
256
256
  }
257
257
  var ENABLED_FEATURES_GATE_MAP = {
258
- "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
259
258
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
260
259
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
261
260
  };
@@ -1651,7 +1650,7 @@ function trackUsage(action) {
1651
1650
  eventName: EVENT_NAME,
1652
1651
  action,
1653
1652
  nodeVersion: getNodeVersionData(),
1654
- version: "1.2.69",
1653
+ version: "1.2.75",
1655
1654
  os: getPlatform()
1656
1655
  };
1657
1656
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1915,17 +1914,41 @@ var getApplyValidationToRenderContext = (portalId, fieldsJSON, metaJSON, request
1915
1914
  return renderResult;
1916
1915
  };
1917
1916
  };
1917
+ var REQUIRED_MODULE_EXPORTS = ["Component", "fields", "meta"];
1918
+ var MAX_MODULE_LOAD_ATTEMPTS = 3;
1919
+ var MODULE_RELOAD_BACKOFF_MS = 50;
1920
+ var MODULE_NOT_FOUND_ERROR = "Failed to load url";
1921
+ var isUnpopulatedModuleNamespace = (mod) => !!mod && REQUIRED_MODULE_EXPORTS.every((name) => mod[name] === void 0);
1922
+ var invalidateSsrModule = async (viteServer, moduleUrl) => {
1923
+ try {
1924
+ const mod = await viteServer.moduleGraph.getModuleByUrl(moduleUrl, true);
1925
+ if (mod)
1926
+ viteServer.moduleGraph.invalidateModule(mod);
1927
+ } catch {
1928
+ }
1929
+ };
1930
+ var delay = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
1918
1931
  var lookForModuleInFolder2 = async (modulePath, viteServer) => {
1919
- let componentModule;
1920
1932
  const insideFolderPath = joinPosix2(modulePath, "index");
1921
- try {
1922
- componentModule = await viteServer.ssrLoadModule(insideFolderPath);
1923
- } catch (e) {
1924
- if (!e.message.includes("Failed to load url")) {
1925
- throw e;
1933
+ for (let attempt = 1; attempt <= MAX_MODULE_LOAD_ATTEMPTS; attempt++) {
1934
+ let componentModule;
1935
+ try {
1936
+ componentModule = await viteServer.ssrLoadModule(insideFolderPath);
1937
+ } catch (e) {
1938
+ if (!e.message.includes(MODULE_NOT_FOUND_ERROR)) {
1939
+ throw e;
1940
+ }
1941
+ return [void 0, insideFolderPath];
1942
+ }
1943
+ const racedMidInstantiate = isUnpopulatedModuleNamespace(componentModule);
1944
+ const hasAttemptsLeft = attempt < MAX_MODULE_LOAD_ATTEMPTS;
1945
+ if (!racedMidInstantiate || !hasAttemptsLeft) {
1946
+ return [componentModule, insideFolderPath];
1926
1947
  }
1948
+ await invalidateSsrModule(viteServer, insideFolderPath);
1949
+ await delay(MODULE_RELOAD_BACKOFF_MS);
1927
1950
  }
1928
- return [componentModule, insideFolderPath];
1951
+ return [void 0, insideFolderPath];
1929
1952
  };
1930
1953
  async function renderModule(viteServer, requestedModulePath, moduleProps, pageUrl, basePath, environmentConfig, renderOptions) {
1931
1954
  console.log("Rendering module", requestedModulePath);
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-CBGC9bBc.js
1
+ // ../cms-js-internal/dist/types-B-d4FeeE.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -388,15 +388,12 @@ function getBaseAssetUrlFromBuild(buildDir) {
388
388
  return getBuildInfo(buildDir).baseAssetUrl;
389
389
  }
390
390
  var GATES = [
391
- "CMS:JSRenderer:GetServerSideProps",
392
- "CMS:JSRenderer:ModuleHubl",
393
391
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
394
392
  "CMS:JSRenderer:AnalyzeCmsModules",
395
393
  "CMS:JSRenderer:StripNullBytes",
396
394
  "PortalsAccessIdentity:DesignManager:UrlSigning"
397
395
  ];
398
396
  var ENABLED_FEATURES_GATE_MAP = {
399
- "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
400
397
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
401
398
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
402
399
  };
package/dist/run.js CHANGED
@@ -896,7 +896,7 @@ function packagePath(metaUrl, projectPath) {
896
896
  );
897
897
  }
898
898
 
899
- // ../cms-js-internal/dist/types-CBGC9bBc.js
899
+ // ../cms-js-internal/dist/types-B-d4FeeE.js
900
900
  import path4 from "path";
901
901
  import { createHash } from "crypto";
902
902
  import fs3, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1148,7 +1148,6 @@ function isFullHeightPreviewEnabled(config) {
1148
1148
  return false;
1149
1149
  }
1150
1150
  var ENABLED_FEATURES_GATE_MAP = {
1151
- "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
1152
1151
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
1153
1152
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
1154
1153
  };
@@ -2256,7 +2255,7 @@ function trackUsage(action) {
2256
2255
  eventName: EVENT_NAME,
2257
2256
  action,
2258
2257
  nodeVersion: getNodeVersionData(),
2259
- version: "1.2.69",
2258
+ version: "1.2.75",
2260
2259
  os: getPlatform()
2261
2260
  };
2262
2261
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2520,17 +2519,41 @@ var getApplyValidationToRenderContext = (portalId, fieldsJSON, metaJSON, request
2520
2519
  return renderResult;
2521
2520
  };
2522
2521
  };
2522
+ var REQUIRED_MODULE_EXPORTS = ["Component", "fields", "meta"];
2523
+ var MAX_MODULE_LOAD_ATTEMPTS = 3;
2524
+ var MODULE_RELOAD_BACKOFF_MS = 50;
2525
+ var MODULE_NOT_FOUND_ERROR = "Failed to load url";
2526
+ var isUnpopulatedModuleNamespace = (mod) => !!mod && REQUIRED_MODULE_EXPORTS.every((name) => mod[name] === void 0);
2527
+ var invalidateSsrModule = async (viteServer, moduleUrl) => {
2528
+ try {
2529
+ const mod = await viteServer.moduleGraph.getModuleByUrl(moduleUrl, true);
2530
+ if (mod)
2531
+ viteServer.moduleGraph.invalidateModule(mod);
2532
+ } catch {
2533
+ }
2534
+ };
2535
+ var delay = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
2523
2536
  var lookForModuleInFolder2 = async (modulePath, viteServer) => {
2524
- let componentModule;
2525
2537
  const insideFolderPath = joinPosix2(modulePath, "index");
2526
- try {
2527
- componentModule = await viteServer.ssrLoadModule(insideFolderPath);
2528
- } catch (e) {
2529
- if (!e.message.includes("Failed to load url")) {
2530
- throw e;
2538
+ for (let attempt = 1; attempt <= MAX_MODULE_LOAD_ATTEMPTS; attempt++) {
2539
+ let componentModule;
2540
+ try {
2541
+ componentModule = await viteServer.ssrLoadModule(insideFolderPath);
2542
+ } catch (e) {
2543
+ if (!e.message.includes(MODULE_NOT_FOUND_ERROR)) {
2544
+ throw e;
2545
+ }
2546
+ return [void 0, insideFolderPath];
2547
+ }
2548
+ const racedMidInstantiate = isUnpopulatedModuleNamespace(componentModule);
2549
+ const hasAttemptsLeft = attempt < MAX_MODULE_LOAD_ATTEMPTS;
2550
+ if (!racedMidInstantiate || !hasAttemptsLeft) {
2551
+ return [componentModule, insideFolderPath];
2531
2552
  }
2553
+ await invalidateSsrModule(viteServer, insideFolderPath);
2554
+ await delay(MODULE_RELOAD_BACKOFF_MS);
2532
2555
  }
2533
- return [componentModule, insideFolderPath];
2556
+ return [void 0, insideFolderPath];
2534
2557
  };
2535
2558
  async function renderModule(viteServer, requestedModulePath, moduleProps, pageUrl, basePath, environmentConfig, renderOptions) {
2536
2559
  console.log("Rendering module", requestedModulePath);
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-CBGC9bBc.js
4
+ // ../cms-js-internal/dist/types-B-d4FeeE.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-CBGC9bBc.js
11
+ // ../cms-js-internal/dist/types-B-d4FeeE.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -385,8 +385,8 @@ function isStylesheetAsset(staticAsset) {
385
385
  return staticAsset.type === "stylesheet";
386
386
  }
387
387
  var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, TEMPLATE_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;
388
- var init_types_CBGC9bBc = __esm({
389
- "../cms-js-internal/dist/types-CBGC9bBc.js"() {
388
+ var init_types_B_d4FeeE = __esm({
389
+ "../cms-js-internal/dist/types-B-d4FeeE.js"() {
390
390
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
391
391
  ENTRY_POINTS_PATH = "components/partials/";
392
392
  MODULE_FOLDER_PATH = "components/modules/";
@@ -503,15 +503,12 @@ ${groupEnd}</script>
503
503
  HEALTHCHECKS_STRICT_DEFAULT = false;
504
504
  BUILD_INFO_PATH = "/build-info.json";
505
505
  GATES = [
506
- "CMS:JSRenderer:GetServerSideProps",
507
- "CMS:JSRenderer:ModuleHubl",
508
506
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
509
507
  "CMS:JSRenderer:AnalyzeCmsModules",
510
508
  "CMS:JSRenderer:StripNullBytes",
511
509
  "PortalsAccessIdentity:DesignManager:UrlSigning"
512
510
  ];
513
511
  ENABLED_FEATURES_GATE_MAP = {
514
- "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
515
512
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
516
513
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
517
514
  };
@@ -1179,8 +1176,8 @@ function GlobalPartialSlot(props) {
1179
1176
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1180
1177
  var init_dist = __esm({
1181
1178
  "../cms-js-internal/dist/index.js"() {
1182
- init_types_CBGC9bBc();
1183
- init_types_CBGC9bBc();
1179
+ init_types_B_d4FeeE();
1180
+ init_types_B_d4FeeE();
1184
1181
  ({ setProperty, getProperty, hasProperty } = dotProp);
1185
1182
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1186
1183
  const islandsArrayToSerialize = tweakedIslandsArray.map(
@@ -7,7 +7,7 @@ import { createServer as createViteServer, normalizePath as normalizePath2 } fro
7
7
  import { createRequire } from "module";
8
8
  import { default as react } from "@vitejs/plugin-react";
9
9
 
10
- // ../cms-js-internal/dist/types-CBGC9bBc.js
10
+ // ../cms-js-internal/dist/types-B-d4FeeE.js
11
11
  import path from "path";
12
12
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
13
13
  import { join } from "path/posix";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "1.2.69",
3
+ "version": "1.2.75",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,7 +29,7 @@
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": "^1.2.69",
32
+ "@hubspot/cms-components": "^1.2.75",
33
33
  "@hubspot/local-dev-lib": "5.10.1",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -0,0 +1,8 @@
1
+ export declare function debugAuthContext(
2
+ authedPortalId: number,
3
+ cookieValue: string
4
+ ): Promise<void>;
5
+ export declare function compareUrls(
6
+ originalUrl: string,
7
+ signedUrl: string
8
+ ): void;
@@ -0,0 +1,2 @@
1
+ export declare function getLocalComponentsPath(): string;
2
+ export declare function shouldUseLocalComponents(): boolean;
@@ -0,0 +1,18 @@
1
+ import { ViteDevServer } from 'vite';
2
+ /**
3
+ * Processes HTML to find remote assets and replace with Vite-managed URLs
4
+ */
5
+ export declare function processRemoteAssets(
6
+ html: string,
7
+ viteServer: ViteDevServer
8
+ ): Promise<string>;
9
+ /**
10
+ * Vite plugin to handle remote assets
11
+ */
12
+ export declare function remoteAssetsPlugin(): {
13
+ name: string;
14
+ apply: 'serve';
15
+ configResolved(config: any): void;
16
+ resolveId(id: string): string;
17
+ load(id: string): Promise<string>;
18
+ };
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function hubspotStaticAssetsPlugin(): Plugin;
@@ -0,0 +1,10 @@
1
+ import { ViteDevServer, Plugin } from 'vite';
2
+ /**
3
+ * Create a self-contained plugin with proper caching
4
+ */
5
+ export declare function remoteAssetsPlugin(): Plugin & {
6
+ processRemoteAssets: (
7
+ html: string,
8
+ viteServer: ViteDevServer
9
+ ) => Promise<string>;
10
+ };
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Plugin that provides URL signing capabilities
4
+ * Uses internal signing mechanisms when available, with fallback for public environments
5
+ */
6
+ export default function requestSigningPlugin(): Plugin;
@@ -0,0 +1,13 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare function handleGetModulePages(
3
+ req: Request,
4
+ res: Response,
5
+ next: NextFunction
6
+ ): Promise<Response<any, Record<string, any>>>;
7
+ export declare function handleOpenFile(
8
+ req: Request,
9
+ res: Response,
10
+ next: NextFunction
11
+ ): Response<any, Record<string, any>>;
12
+ export declare function createAppServerRoutes(): import('express-serve-static-core').Router;
13
+ export default createAppServerRoutes;
@@ -0,0 +1,7 @@
1
+ import { Request, Response } from 'express';
2
+ declare const homeRouteHandler: (
3
+ request: Request,
4
+ response: Response,
5
+ next: Function
6
+ ) => Promise<void>;
7
+ export default homeRouteHandler;