@hubspot/cms-dev-server 0.6.7 → 0.7.0

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.
Binary file
@@ -184,14 +184,12 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
184
184
  var GATES = [
185
185
  "CMS:JSRenderer:SharedDeps",
186
186
  "CMS:JSRenderer:GetServerSideProps",
187
- "CMS:JSRenderer:LocalProxySchemaVersion1",
188
187
  "CMS:JSRenderer:GraphQLQueryBuild",
189
188
  "CMS:JSRenderer:SeparateIslandRenderOption"
190
189
  ];
191
190
  var ENABLED_FEATURES_GATE_MAP = {
192
191
  "cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
193
192
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
194
- "cms:jsr:localProxySchemaVersion1": "CMS:JSRenderer:LocalProxySchemaVersion1",
195
193
  "cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
196
194
  "cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
197
195
  };
@@ -326,13 +324,19 @@ var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
326
324
  }
327
325
  const consoleLines = [];
328
326
  for (const message of messagesForBrowser) {
329
- const funcString = message.level === "error" ? "console.error" : "console.warn";
327
+ let funcString = "console.log";
328
+ if (message.level === "error") {
329
+ funcString = "console.error";
330
+ }
331
+ if (message.level === "warn") {
332
+ funcString = "console.warn";
333
+ }
330
334
  const argString = message.parameters.map((arg) => JSON.stringify(arg)).join(", ");
331
335
  consoleLines.push(` ${funcString}(${argString});`);
332
336
  }
333
337
  let groupStart = "";
334
338
  let groupEnd = "";
335
- if (groupLabel !== null) {
339
+ if (groupLabel !== void 0 && groupLabel !== null) {
336
340
  groupStart = `
337
341
  console.group(${JSON.stringify(groupLabel)});`;
338
342
  groupEnd = ` console.groupEnd()
@@ -571,6 +575,7 @@ export {
571
575
  renderOnServer,
572
576
  renderStreamToPromise,
573
577
  resolveIslandPlugin,
578
+ scriptTagToLogServerMessages,
574
579
  serializeIslandDataToJSON,
575
580
  setIn,
576
581
  ungatedAtBuildTimeFor,
package/dist/run.js CHANGED
@@ -180,7 +180,6 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
180
180
  var ENABLED_FEATURES_GATE_MAP = {
181
181
  "cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
182
182
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
183
- "cms:jsr:localProxySchemaVersion1": "CMS:JSRenderer:LocalProxySchemaVersion1",
184
183
  "cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
185
184
  "cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
186
185
  };
@@ -302,13 +301,19 @@ var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
302
301
  }
303
302
  const consoleLines = [];
304
303
  for (const message of messagesForBrowser) {
305
- const funcString = message.level === "error" ? "console.error" : "console.warn";
304
+ let funcString = "console.log";
305
+ if (message.level === "error") {
306
+ funcString = "console.error";
307
+ }
308
+ if (message.level === "warn") {
309
+ funcString = "console.warn";
310
+ }
306
311
  const argString = message.parameters.map((arg) => JSON.stringify(arg)).join(", ");
307
312
  consoleLines.push(` ${funcString}(${argString});`);
308
313
  }
309
314
  let groupStart = "";
310
315
  let groupEnd = "";
311
- if (groupLabel !== null) {
316
+ if (groupLabel !== void 0 && groupLabel !== null) {
312
317
  groupStart = `
313
318
  console.group(${JSON.stringify(groupLabel)});`;
314
319
  groupEnd = ` console.groupEnd()
@@ -1138,7 +1143,30 @@ var module_default = moduleRouteHandler;
1138
1143
  // src/proxyPage/fetchContentMetadata.ts
1139
1144
  import http from "http";
1140
1145
  import https from "https";
1141
- async function fetchContentMetadata(url3, redirects = 0, originalUrl) {
1146
+ import { get as hsGet } from "@hubspot/cli-lib/http.js";
1147
+ import { getAccountId } from "@hubspot/cli-lib/lib/config.js";
1148
+ async function requestContentPreview(url3, portalId) {
1149
+ const urlObject = new URL(url3);
1150
+ const proxiedQueryParams = {};
1151
+ for (const queryKey of urlObject.searchParams.keys()) {
1152
+ const values = urlObject.searchParams.getAll(queryKey);
1153
+ if (values.length > 1) {
1154
+ proxiedQueryParams[queryKey] = values;
1155
+ } else {
1156
+ proxiedQueryParams[queryKey] = values[0];
1157
+ }
1158
+ }
1159
+ const accountId = getAccountId(portalId);
1160
+ const response = await hsGet(accountId, {
1161
+ baseUrl: urlObject.origin,
1162
+ uri: urlObject.pathname,
1163
+ query: proxiedQueryParams,
1164
+ json: false,
1165
+ resolveWithFullResponse: true
1166
+ });
1167
+ return response;
1168
+ }
1169
+ async function requestPage(url3, redirects = 0, originalUrl) {
1142
1170
  if (redirects > 5) {
1143
1171
  throw new Error(
1144
1172
  `Hit too many redirects to HEAD requests for ${originalUrl}`
@@ -1159,45 +1187,14 @@ async function fetchContentMetadata(url3, redirects = 0, originalUrl) {
1159
1187
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
1160
1188
  console.log(`Redirecting to ${res.headers.location} (from ${url3})`);
1161
1189
  return resolve3(
1162
- fetchContentMetadata(
1190
+ requestPage(
1163
1191
  res.headers.location,
1164
1192
  redirects + 1,
1165
1193
  originalUrl ?? url3
1166
1194
  )
1167
1195
  );
1168
1196
  }
1169
- const portalIdHeader = res.headers["x-hs-hub-id"];
1170
- const contentId = res.headers["x-hs-content-id"];
1171
- if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
1172
- return reject(
1173
- new Error(
1174
- `There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
1175
- )
1176
- );
1177
- } else {
1178
- const portalId = parseInt(portalIdHeader, 10);
1179
- if (res.statusCode !== 200) {
1180
- return reject(
1181
- new Error(
1182
- `${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${url3}. ${res.statusCode === 429 && res.headers["retry-after"] ? `Retry after ${res.headers["retry-after"]} seconds.` : ""}`
1183
- )
1184
- );
1185
- } else if (!portalId || !contentId) {
1186
- return reject(
1187
- new Error(
1188
- `Missing hub ID or content ID headers on HEAD request to ${url3}`
1189
- )
1190
- );
1191
- } else if (isNaN(portalId)) {
1192
- return reject(
1193
- new Error(
1194
- `Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
1195
- )
1196
- );
1197
- }
1198
- const hublet = "na1";
1199
- return resolve3({ portalId, contentId, hublet });
1200
- }
1197
+ return resolve3(res);
1201
1198
  }
1202
1199
  ).on("error", (err) => {
1203
1200
  console.error(err);
@@ -1205,11 +1202,49 @@ async function fetchContentMetadata(url3, redirects = 0, originalUrl) {
1205
1202
  }).end();
1206
1203
  });
1207
1204
  }
1205
+ async function fetchContentMetadata(url3, portalId) {
1206
+ let res;
1207
+ if (url3.includes("hs_preview")) {
1208
+ res = await requestContentPreview(url3, portalId);
1209
+ } else {
1210
+ res = await requestPage(url3);
1211
+ }
1212
+ const portalIdHeader = res.headers["x-hs-hub-id"];
1213
+ const contentId = res.headers["x-hs-content-id"];
1214
+ if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
1215
+ throw new Error(
1216
+ `There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
1217
+ );
1218
+ } else {
1219
+ const portalIdFromResponse = parseInt(portalIdHeader, 10);
1220
+ const pageAccount = await getAccountId(portalIdFromResponse);
1221
+ if (!pageAccount) {
1222
+ throw new Error(
1223
+ `No CLI auth for portal ${portalIdFromResponse} found, please run \`hs auth\``
1224
+ );
1225
+ }
1226
+ if (res.statusCode !== 200) {
1227
+ throw new Error(
1228
+ `${res.statusCode} ${res.statusMessage} - Unable to obtain HEAD information from ${url3}. ${res.statusCode === 429 && res.headers["retry-after"] ? `Retry after ${res.headers["retry-after"]} seconds.` : ""}`
1229
+ );
1230
+ } else if (!portalId || !contentId) {
1231
+ throw new Error(
1232
+ `Missing hub ID or content ID headers on HEAD request to ${url3}`
1233
+ );
1234
+ } else if (isNaN(portalId)) {
1235
+ throw new Error(
1236
+ `Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
1237
+ );
1238
+ }
1239
+ const hublet = "na1";
1240
+ return { portalId, contentId, hublet };
1241
+ }
1242
+ }
1208
1243
 
1209
1244
  // src/proxyPage/proxyPage.ts
1210
1245
  import path5 from "path";
1211
- import { getAccountId, getEnv } from "@hubspot/cli-lib/lib/config.js";
1212
- import { get as hsGet2 } from "@hubspot/cli-lib/http.js";
1246
+ import { getAccountId as getAccountId2, getEnv } from "@hubspot/cli-lib/lib/config.js";
1247
+ import { get as hsGet3 } from "@hubspot/cli-lib/http.js";
1213
1248
 
1214
1249
  // src/lib/proxyHelpers.ts
1215
1250
  import fs from "fs";
@@ -1366,7 +1401,7 @@ var renderLocalError_default = (path7, error) => {
1366
1401
  };
1367
1402
 
1368
1403
  // src/proxyPage/fetchPreviewInfo.ts
1369
- import { get as hsGet } from "@hubspot/cli-lib/http.js";
1404
+ import { get as hsGet2 } from "@hubspot/cli-lib/http.js";
1370
1405
  var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
1371
1406
  if (!contentId) {
1372
1407
  throw new Error(
@@ -1374,7 +1409,7 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
1374
1409
  );
1375
1410
  }
1376
1411
  try {
1377
- const content = await hsGet(accountId, {
1412
+ const content = await hsGet2(accountId, {
1378
1413
  uri: `/content/api/v4/contents/${contentId}`,
1379
1414
  query: { portalId },
1380
1415
  json: true
@@ -1422,16 +1457,12 @@ var getEntryPointBasePathFromProxyRequest = (request2) => {
1422
1457
  }
1423
1458
  return requestPath.replace(pathParamDict.dynamic_slug, "");
1424
1459
  };
1425
- var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, jsRenderingGates) => {
1460
+ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, __jsRenderingGates) => {
1426
1461
  const url3 = new URL(urlToProxy);
1427
1462
  console.log(`Proxying request to ${url3.href}`, {
1428
1463
  previewKey,
1429
1464
  contentId
1430
1465
  });
1431
- const proxySchemaVersion = isUngatedFor(
1432
- jsRenderingGates,
1433
- "CMS:JSRenderer:LocalProxySchemaVersion1"
1434
- ) ? 1 : 0;
1435
1466
  let proxiedQueryParams = {};
1436
1467
  for (const queryKey of url3.searchParams.keys()) {
1437
1468
  const values = url3.searchParams.getAll(queryKey);
@@ -1446,9 +1477,9 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1446
1477
  hs_preview: `${previewKey}-${contentId}`,
1447
1478
  hsLocalProxy: true,
1448
1479
  hsLocalProxyProject: `@projects/${projectName}`,
1449
- localProxySchemaVersion: proxySchemaVersion
1480
+ localProxySchemaVersion: 1
1450
1481
  };
1451
- const result = hsGet2(accountId, {
1482
+ const result = hsGet3(accountId, {
1452
1483
  baseUrl: url3.origin,
1453
1484
  uri: url3.pathname,
1454
1485
  query: proxiedQueryParams,
@@ -1464,12 +1495,8 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1464
1495
  });
1465
1496
  };
1466
1497
  var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder, webRoot2, viteServer, pageUrl, basePath, environmentConfig, hsProjectJsonProjectName, webRootProjectComponent) => {
1467
- const proxySchemaVersion = isUngatedFor(
1468
- environmentConfig.getGates(),
1469
- "CMS:JSRenderer:LocalProxySchemaVersion1"
1470
- ) ? 1 : 0;
1471
1498
  const { path: placeholderPath } = localRenderPlaceholder;
1472
- const localRenderPlaceholderProps = proxySchemaVersion === 1 ? localRenderPlaceholder.json.props : localRenderPlaceholder.json;
1499
+ const localRenderPlaceholderProps = localRenderPlaceholder.json.props;
1473
1500
  const [
1474
1501
  __projectIdentifier,
1475
1502
  projectFolder,
@@ -1517,7 +1544,7 @@ var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder,
1517
1544
  return renderModule_default(
1518
1545
  viteServer,
1519
1546
  resolvedPath,
1520
- localRenderPlaceholderProps,
1547
+ localRenderPlaceholderProps.fieldValues,
1521
1548
  pageUrl,
1522
1549
  basePath,
1523
1550
  environmentConfig,
@@ -1536,7 +1563,7 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
1536
1563
  let accountId;
1537
1564
  let proxyEnv;
1538
1565
  try {
1539
- accountId = getAccountId(portalId);
1566
+ accountId = getAccountId2(portalId);
1540
1567
  if (accountId === null) {
1541
1568
  throw new Error();
1542
1569
  }
@@ -1592,10 +1619,7 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
1592
1619
  offsetSoFar,
1593
1620
  localRenderPlaceholder.startOffset
1594
1621
  );
1595
- if (basePath === void 0 && isUngatedFor(
1596
- environmentConfig.getGates(),
1597
- "CMS:JSRenderer:LocalProxySchemaVersion1"
1598
- )) {
1622
+ if (basePath === void 0) {
1599
1623
  basePath = getEntryPointBasePathFromProxyRequest(
1600
1624
  localRenderPlaceholder.json.request
1601
1625
  );
@@ -1705,14 +1729,10 @@ async function proxyPageRouteHandler(request2, response, next) {
1705
1729
  return response.status(400).send(message);
1706
1730
  }
1707
1731
  }
1708
- if (request2.query.hs_preview) {
1709
- const message = `Can't make a proxy request, you cannot proxy URLs that include internal query params like hs_preview`;
1710
- consoleWarn(message);
1711
- return response.status(400).send(message);
1712
- }
1713
1732
  try {
1714
1733
  const { portalId, contentId, hublet } = await fetchContentMetadata(
1715
- urlToProxy
1734
+ urlToProxy,
1735
+ request2.app.locals.authedPortalId
1716
1736
  );
1717
1737
  await proxySpecificPage(
1718
1738
  response,
@@ -1747,7 +1767,37 @@ function proxyPageResourceRedirect(req, res, next) {
1747
1767
  const domainToProxy = getSubDomainFromValidLocalDomain(req.hostname);
1748
1768
  const pathToProxy = req.originalUrl;
1749
1769
  const urlToProxy = `https://${domainToProxy}${pathToProxy}`;
1750
- request(urlToProxy).pipe(res);
1770
+ if (req.method === "GET") {
1771
+ request(urlToProxy).pipe(res);
1772
+ } else {
1773
+ const contentType = req.headers["content-type"];
1774
+ const isSendingJSON = contentType && /\bjson\b/.test(req.headers["content-type"].toString());
1775
+ const headerEntries = Object.entries(req.headers).filter(([header]) => {
1776
+ if (
1777
+ // Need to reset these headers for https (and recompression/encoding?) to work properly
1778
+ ["host", "origin", "connection", "content-length"].includes(
1779
+ header.toLowerCase()
1780
+ ) || header.startsWith("sec-")
1781
+ ) {
1782
+ return false;
1783
+ }
1784
+ return true;
1785
+ });
1786
+ let body = void 0;
1787
+ if (req.body) {
1788
+ if (isSendingJSON) {
1789
+ body = JSON.stringify(req.body);
1790
+ } else {
1791
+ body = req.body.toString();
1792
+ }
1793
+ }
1794
+ request({
1795
+ url: urlToProxy,
1796
+ method: req.method,
1797
+ headers: Object.fromEntries(headerEntries),
1798
+ body
1799
+ }).pipe(res);
1800
+ }
1751
1801
  }
1752
1802
 
1753
1803
  // src/routes/homeRouteHandler.tsx
@@ -1830,7 +1880,8 @@ async function proxyPathPageRouteHandler(request2, response, next) {
1830
1880
  }
1831
1881
  try {
1832
1882
  const { portalId, contentId, hublet } = await fetchContentMetadata(
1833
- proxyPageUrl.href
1883
+ proxyPageUrl.href,
1884
+ request2.app.locals.portalId
1834
1885
  );
1835
1886
  await proxySpecificPage(
1836
1887
  response,
@@ -1917,6 +1968,11 @@ var createDevServerRoutes = async (viteServer, storybookPort) => {
1917
1968
  devServerApp.get("/", homeRouteHandler_default);
1918
1969
  devServerApp.get("/*", proxyPathPageResourceRedirect);
1919
1970
  devServerApp.get("/*", proxyPageResourceRedirect);
1971
+ devServerApp.post("/*", proxyPageResourceRedirect);
1972
+ devServerApp.delete("/*", proxyPageResourceRedirect);
1973
+ devServerApp.head("/*", proxyPageResourceRedirect);
1974
+ devServerApp.put("/*", proxyPageResourceRedirect);
1975
+ devServerApp.options("/*", proxyPageResourceRedirect);
1920
1976
  devServerApp.get("/*", proxyPageRouteHandler);
1921
1977
  return devServerApp;
1922
1978
  };
@@ -1928,7 +1984,7 @@ import express from "express";
1928
1984
 
1929
1985
  // src/shadowDevServer/createShadowDevServerRoutes.ts
1930
1986
  import { Router as Router2 } from "express";
1931
- import { getAccountId as getAccountId2 } from "@hubspot/cli-lib/lib/config.js";
1987
+ import { getAccountId as getAccountId3 } from "@hubspot/cli-lib/lib/config.js";
1932
1988
  import cors from "cors";
1933
1989
  function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
1934
1990
  return async function shadowDevServerCheckHandler(request2, response) {
@@ -1947,7 +2003,7 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
1947
2003
  let hasJSBuildingBlocks = false;
1948
2004
  let localProxyUrl;
1949
2005
  try {
1950
- accountId = getAccountId2(portalId);
2006
+ accountId = getAccountId3(portalId);
1951
2007
  if (accountId === null) {
1952
2008
  throw new Error();
1953
2009
  }
@@ -2169,14 +2225,14 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
2169
2225
  // src/createDevServer.ts
2170
2226
  import {
2171
2227
  getEnv as getEnv2,
2172
- getAccountId as getAccountId3,
2228
+ getAccountId as getAccountId4,
2173
2229
  getAccountConfig,
2174
2230
  loadConfig,
2175
2231
  validateConfig
2176
2232
  } from "@hubspot/cli-lib/lib/config.js";
2177
2233
 
2178
2234
  // src/proxyPage/fetchDomains.ts
2179
- import { get as hsGet3 } from "@hubspot/cli-lib/http.js";
2235
+ import { get as hsGet4 } from "@hubspot/cli-lib/http.js";
2180
2236
 
2181
2237
  // src/lib/errors.ts
2182
2238
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -2205,7 +2261,7 @@ function isMissingScopeError(error) {
2205
2261
  // src/proxyPage/fetchDomains.ts
2206
2262
  async function fetchDomains(portalId) {
2207
2263
  try {
2208
- const result = await hsGet3(portalId, {
2264
+ const result = await hsGet4(portalId, {
2209
2265
  uri: `/cms/v3/domains`,
2210
2266
  query: { portalId },
2211
2267
  json: true
@@ -2272,7 +2328,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
2272
2328
  }
2273
2329
  loadConfig(hubspotCliConfigPathOption2 || null, { useEnv: false });
2274
2330
  if (validateConfig()) {
2275
- authedPortalId = getAccountId3(hubspotCliAccountNameOption2);
2331
+ authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
2276
2332
  authedEnv = getEnv2(hubspotCliAccountNameOption2);
2277
2333
  personalAccessKey = getAccountConfig(authedPortalId) && getAccountConfig(authedPortalId).personalAccessKey;
2278
2334
  if (!authedPortalId && hubspotCliAccountNameOption2) {
@@ -5,6 +5,27 @@ import { renderToStaticMarkup as renderToStaticMarkup2 } from "react-dom/server"
5
5
  // ../cms-js-internal/dist/index.js
6
6
  import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
7
7
  import { cloneElement } from "react";
8
+ function namespaceModulePropsShape(props) {
9
+ const {
10
+ dataQueryResult,
11
+ hublParameters,
12
+ fieldValues: passedFieldValues
13
+ } = props;
14
+ const oldPropsShape = { ...props };
15
+ if (oldPropsShape.dataQueryResult) {
16
+ delete oldPropsShape.dataQueryResult;
17
+ }
18
+ if (oldPropsShape.hublParameters) {
19
+ delete oldPropsShape.hublParameters;
20
+ }
21
+ const fieldValues = passedFieldValues || oldPropsShape;
22
+ return {
23
+ ...fieldValues,
24
+ dataQueryResult,
25
+ fieldValues,
26
+ hublParameters
27
+ };
28
+ }
8
29
  function renderFieldsToJson(fields) {
9
30
  let moduleJson;
10
31
  const outputCallback = (callbackJson) => {
@@ -135,7 +156,8 @@ function moduleStory(ModuleComponent, fields, storyArgs) {
135
156
  return {
136
157
  render: (_args) => {
137
158
  const fieldValues = getNestedFieldObjectForArgs(_args);
138
- return /* @__PURE__ */ jsx(ModuleComponent, { ...fieldValues });
159
+ const props = namespaceModulePropsShape({ fieldValues });
160
+ return /* @__PURE__ */ jsx(ModuleComponent, { ...props });
139
161
  },
140
162
  argTypes,
141
163
  args
@@ -43,6 +43,7 @@ __export(dist_exports, {
43
43
  renderOnServer: () => renderOnServer,
44
44
  renderStreamToPromise: () => renderStreamToPromise,
45
45
  resolveIslandPlugin: () => resolveIslandPlugin,
46
+ scriptTagToLogServerMessages: () => scriptTagToLogServerMessages,
46
47
  serializeIslandDataToJSON: () => serializeIslandDataToJSON,
47
48
  setIn: () => setIn,
48
49
  ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
@@ -457,14 +458,12 @@ ${indentString}`);
457
458
  GATES = [
458
459
  "CMS:JSRenderer:SharedDeps",
459
460
  "CMS:JSRenderer:GetServerSideProps",
460
- "CMS:JSRenderer:LocalProxySchemaVersion1",
461
461
  "CMS:JSRenderer:GraphQLQueryBuild",
462
462
  "CMS:JSRenderer:SeparateIslandRenderOption"
463
463
  ];
464
464
  ENABLED_FEATURES_GATE_MAP = {
465
465
  "cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
466
466
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
467
- "cms:jsr:localProxySchemaVersion1": "CMS:JSRenderer:LocalProxySchemaVersion1",
468
467
  "cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
469
468
  "cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
470
469
  };
@@ -514,13 +513,19 @@ ${indentString}`);
514
513
  }
515
514
  const consoleLines = [];
516
515
  for (const message of messagesForBrowser) {
517
- const funcString = message.level === "error" ? "console.error" : "console.warn";
516
+ let funcString = "console.log";
517
+ if (message.level === "error") {
518
+ funcString = "console.error";
519
+ }
520
+ if (message.level === "warn") {
521
+ funcString = "console.warn";
522
+ }
518
523
  const argString = message.parameters.map((arg) => JSON.stringify(arg)).join(", ");
519
524
  consoleLines.push(` ${funcString}(${argString});`);
520
525
  }
521
526
  let groupStart = "";
522
527
  let groupEnd = "";
523
- if (groupLabel !== null) {
528
+ if (groupLabel !== void 0 && groupLabel !== null) {
524
529
  groupStart = `
525
530
  console.group(${JSON.stringify(groupLabel)});`;
526
531
  groupEnd = ` console.groupEnd()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.6.7",
3
+ "version": "0.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@hubspot/cli-lib": "^3.0.12",
28
- "@hubspot/cms-components": "^0.6.7",
28
+ "@hubspot/cms-components": "^0.7.0",
29
29
  "@storybook/addon-actions": "7.0.7",
30
30
  "@storybook/addon-essentials": "7.0.7",
31
31
  "@storybook/addon-interactions": "7.0.7",
@@ -40,6 +40,7 @@
40
40
  "debug": "^4.3.4",
41
41
  "express": "^4.17.3",
42
42
  "http-proxy-middleware": "^2.0.6",
43
+ "node-fetch": "^3.3.0",
43
44
  "react": "^18.1.0",
44
45
  "react-dom": "^18.1.0",
45
46
  "request": "^2.88.2",
@@ -56,7 +57,6 @@
56
57
  "@types/react-dom": "^18.0.0",
57
58
  "copyfiles": "^2.4.1",
58
59
  "esbuild": "^0.16.17",
59
- "node-fetch": "^3.3.0",
60
60
  "nodemon": "^2.0.15",
61
61
  "ts-node": "^10.7.0",
62
62
  "vitest": "0.30.1"
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "d55b8711066e9d5a5a8eb6218a42c4ba315b1112"
100
+ "gitHead": "2e6ce49ad4fbee93591ea9c0459b46e8211da987"
101
101
  }
@@ -1,8 +1,15 @@
1
1
  import React from 'react';
2
2
  import { Field } from '@hubspot/cms-components/fields';
3
3
  import { Args, ModuleStory } from './types.js';
4
+ declare type ModuleProps = {
5
+ fieldValues: any;
6
+ dataQueryResult?: any;
7
+ hublParameters?: any;
8
+ serverSideProps?: any;
9
+ };
4
10
  export declare function moduleFieldsToJson(fields: JSX.Element): Field[];
5
- export declare function moduleStory(ModuleComponent: React.ComponentType, fields: JSX.Element, storyArgs: Args): ModuleStory;
11
+ export declare function moduleStory(ModuleComponent: (moduleProps: ModuleProps) => React.ReactElement<any, any> | null, fields: JSX.Element, storyArgs: Args): ModuleStory;
6
12
  export declare function moduleStoryWithIsland(fields: JSX.Element, // was module component
7
13
  moduleName: string, // was fields jSX
8
14
  storyArgs: Args): ModuleStory;
15
+ export {};