@hubspot/cms-dev-server 0.6.8 → 0.7.1
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
|
package/dist/internalSsr.js
CHANGED
|
@@ -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
|
};
|
|
@@ -338,7 +336,7 @@ var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
|
338
336
|
}
|
|
339
337
|
let groupStart = "";
|
|
340
338
|
let groupEnd = "";
|
|
341
|
-
if (groupLabel !== null) {
|
|
339
|
+
if (groupLabel !== void 0 && groupLabel !== null) {
|
|
342
340
|
groupStart = `
|
|
343
341
|
console.group(${JSON.stringify(groupLabel)});`;
|
|
344
342
|
groupEnd = ` console.groupEnd()
|
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
|
};
|
|
@@ -314,7 +313,7 @@ var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
|
314
313
|
}
|
|
315
314
|
let groupStart = "";
|
|
316
315
|
let groupEnd = "";
|
|
317
|
-
if (groupLabel !== null) {
|
|
316
|
+
if (groupLabel !== void 0 && groupLabel !== null) {
|
|
318
317
|
groupStart = `
|
|
319
318
|
console.group(${JSON.stringify(groupLabel)});`;
|
|
320
319
|
groupEnd = ` console.groupEnd()
|
|
@@ -504,7 +503,9 @@ import url from "url";
|
|
|
504
503
|
import { normalizePath } from "vite";
|
|
505
504
|
function packagePath(metaUrl, projectPath) {
|
|
506
505
|
if (true) {
|
|
507
|
-
return
|
|
506
|
+
return normalizePath(
|
|
507
|
+
path2.resolve(path2.dirname(url.fileURLToPath(metaUrl)), projectPath)
|
|
508
|
+
);
|
|
508
509
|
}
|
|
509
510
|
const parentDirPath = normalizePath(path2.dirname(url.fileURLToPath(metaUrl)));
|
|
510
511
|
const subPath = parentDirPath.replace(/^.+cms-dev-server\/src\//, "");
|
|
@@ -1144,7 +1145,30 @@ var module_default = moduleRouteHandler;
|
|
|
1144
1145
|
// src/proxyPage/fetchContentMetadata.ts
|
|
1145
1146
|
import http from "http";
|
|
1146
1147
|
import https from "https";
|
|
1147
|
-
|
|
1148
|
+
import { get as hsGet } from "@hubspot/cli-lib/http.js";
|
|
1149
|
+
import { getAccountId } from "@hubspot/cli-lib/lib/config.js";
|
|
1150
|
+
async function requestContentPreview(url3, portalId) {
|
|
1151
|
+
const urlObject = new URL(url3);
|
|
1152
|
+
const proxiedQueryParams = {};
|
|
1153
|
+
for (const queryKey of urlObject.searchParams.keys()) {
|
|
1154
|
+
const values = urlObject.searchParams.getAll(queryKey);
|
|
1155
|
+
if (values.length > 1) {
|
|
1156
|
+
proxiedQueryParams[queryKey] = values;
|
|
1157
|
+
} else {
|
|
1158
|
+
proxiedQueryParams[queryKey] = values[0];
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
const accountId = getAccountId(portalId);
|
|
1162
|
+
const response = await hsGet(accountId, {
|
|
1163
|
+
baseUrl: urlObject.origin,
|
|
1164
|
+
uri: urlObject.pathname,
|
|
1165
|
+
query: proxiedQueryParams,
|
|
1166
|
+
json: false,
|
|
1167
|
+
resolveWithFullResponse: true
|
|
1168
|
+
});
|
|
1169
|
+
return response;
|
|
1170
|
+
}
|
|
1171
|
+
async function requestPage(url3, redirects = 0, originalUrl) {
|
|
1148
1172
|
if (redirects > 5) {
|
|
1149
1173
|
throw new Error(
|
|
1150
1174
|
`Hit too many redirects to HEAD requests for ${originalUrl}`
|
|
@@ -1165,45 +1189,14 @@ async function fetchContentMetadata(url3, redirects = 0, originalUrl) {
|
|
|
1165
1189
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
1166
1190
|
console.log(`Redirecting to ${res.headers.location} (from ${url3})`);
|
|
1167
1191
|
return resolve3(
|
|
1168
|
-
|
|
1192
|
+
requestPage(
|
|
1169
1193
|
res.headers.location,
|
|
1170
1194
|
redirects + 1,
|
|
1171
1195
|
originalUrl ?? url3
|
|
1172
1196
|
)
|
|
1173
1197
|
);
|
|
1174
1198
|
}
|
|
1175
|
-
|
|
1176
|
-
const contentId = res.headers["x-hs-content-id"];
|
|
1177
|
-
if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
|
|
1178
|
-
return reject(
|
|
1179
|
-
new Error(
|
|
1180
|
-
`There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
|
|
1181
|
-
)
|
|
1182
|
-
);
|
|
1183
|
-
} else {
|
|
1184
|
-
const portalId = parseInt(portalIdHeader, 10);
|
|
1185
|
-
if (res.statusCode !== 200) {
|
|
1186
|
-
return reject(
|
|
1187
|
-
new Error(
|
|
1188
|
-
`${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.` : ""}`
|
|
1189
|
-
)
|
|
1190
|
-
);
|
|
1191
|
-
} else if (!portalId || !contentId) {
|
|
1192
|
-
return reject(
|
|
1193
|
-
new Error(
|
|
1194
|
-
`Missing hub ID or content ID headers on HEAD request to ${url3}`
|
|
1195
|
-
)
|
|
1196
|
-
);
|
|
1197
|
-
} else if (isNaN(portalId)) {
|
|
1198
|
-
return reject(
|
|
1199
|
-
new Error(
|
|
1200
|
-
`Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
|
|
1201
|
-
)
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
const hublet = "na1";
|
|
1205
|
-
return resolve3({ portalId, contentId, hublet });
|
|
1206
|
-
}
|
|
1199
|
+
return resolve3(res);
|
|
1207
1200
|
}
|
|
1208
1201
|
).on("error", (err) => {
|
|
1209
1202
|
console.error(err);
|
|
@@ -1211,11 +1204,49 @@ async function fetchContentMetadata(url3, redirects = 0, originalUrl) {
|
|
|
1211
1204
|
}).end();
|
|
1212
1205
|
});
|
|
1213
1206
|
}
|
|
1207
|
+
async function fetchContentMetadata(url3, portalId) {
|
|
1208
|
+
let res;
|
|
1209
|
+
if (url3.includes("hs_preview")) {
|
|
1210
|
+
res = await requestContentPreview(url3, portalId);
|
|
1211
|
+
} else {
|
|
1212
|
+
res = await requestPage(url3);
|
|
1213
|
+
}
|
|
1214
|
+
const portalIdHeader = res.headers["x-hs-hub-id"];
|
|
1215
|
+
const contentId = res.headers["x-hs-content-id"];
|
|
1216
|
+
if (Array.isArray(portalIdHeader) || Array.isArray(contentId)) {
|
|
1217
|
+
throw new Error(
|
|
1218
|
+
`There were multiple hub ID or content ID headers in the HEAD request to ${url3}`
|
|
1219
|
+
);
|
|
1220
|
+
} else {
|
|
1221
|
+
const portalIdFromResponse = parseInt(portalIdHeader, 10);
|
|
1222
|
+
const pageAccount = await getAccountId(portalIdFromResponse);
|
|
1223
|
+
if (!pageAccount) {
|
|
1224
|
+
throw new Error(
|
|
1225
|
+
`No CLI auth for portal ${portalIdFromResponse} found, please run \`hs auth\``
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
if (res.statusCode !== 200) {
|
|
1229
|
+
throw new Error(
|
|
1230
|
+
`${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.` : ""}`
|
|
1231
|
+
);
|
|
1232
|
+
} else if (!portalId || !contentId) {
|
|
1233
|
+
throw new Error(
|
|
1234
|
+
`Missing hub ID or content ID headers on HEAD request to ${url3}`
|
|
1235
|
+
);
|
|
1236
|
+
} else if (isNaN(portalId)) {
|
|
1237
|
+
throw new Error(
|
|
1238
|
+
`Hub ID from the HEAD request is not a number: '${portalId}' (${url3})`
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
const hublet = "na1";
|
|
1242
|
+
return { portalId, contentId, hublet };
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1214
1245
|
|
|
1215
1246
|
// src/proxyPage/proxyPage.ts
|
|
1216
1247
|
import path5 from "path";
|
|
1217
|
-
import { getAccountId, getEnv } from "@hubspot/cli-lib/lib/config.js";
|
|
1218
|
-
import { get as
|
|
1248
|
+
import { getAccountId as getAccountId2, getEnv } from "@hubspot/cli-lib/lib/config.js";
|
|
1249
|
+
import { get as hsGet3 } from "@hubspot/cli-lib/http.js";
|
|
1219
1250
|
|
|
1220
1251
|
// src/lib/proxyHelpers.ts
|
|
1221
1252
|
import fs from "fs";
|
|
@@ -1372,7 +1403,7 @@ var renderLocalError_default = (path7, error) => {
|
|
|
1372
1403
|
};
|
|
1373
1404
|
|
|
1374
1405
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
1375
|
-
import { get as
|
|
1406
|
+
import { get as hsGet2 } from "@hubspot/cli-lib/http.js";
|
|
1376
1407
|
var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
1377
1408
|
if (!contentId) {
|
|
1378
1409
|
throw new Error(
|
|
@@ -1380,7 +1411,7 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
|
|
|
1380
1411
|
);
|
|
1381
1412
|
}
|
|
1382
1413
|
try {
|
|
1383
|
-
const content = await
|
|
1414
|
+
const content = await hsGet2(accountId, {
|
|
1384
1415
|
uri: `/content/api/v4/contents/${contentId}`,
|
|
1385
1416
|
query: { portalId },
|
|
1386
1417
|
json: true
|
|
@@ -1428,16 +1459,12 @@ var getEntryPointBasePathFromProxyRequest = (request2) => {
|
|
|
1428
1459
|
}
|
|
1429
1460
|
return requestPath.replace(pathParamDict.dynamic_slug, "");
|
|
1430
1461
|
};
|
|
1431
|
-
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName,
|
|
1462
|
+
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, __jsRenderingGates) => {
|
|
1432
1463
|
const url3 = new URL(urlToProxy);
|
|
1433
1464
|
console.log(`Proxying request to ${url3.href}`, {
|
|
1434
1465
|
previewKey,
|
|
1435
1466
|
contentId
|
|
1436
1467
|
});
|
|
1437
|
-
const proxySchemaVersion = isUngatedFor(
|
|
1438
|
-
jsRenderingGates,
|
|
1439
|
-
"CMS:JSRenderer:LocalProxySchemaVersion1"
|
|
1440
|
-
) ? 1 : 0;
|
|
1441
1468
|
let proxiedQueryParams = {};
|
|
1442
1469
|
for (const queryKey of url3.searchParams.keys()) {
|
|
1443
1470
|
const values = url3.searchParams.getAll(queryKey);
|
|
@@ -1452,9 +1479,9 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
1452
1479
|
hs_preview: `${previewKey}-${contentId}`,
|
|
1453
1480
|
hsLocalProxy: true,
|
|
1454
1481
|
hsLocalProxyProject: `@projects/${projectName}`,
|
|
1455
|
-
localProxySchemaVersion:
|
|
1482
|
+
localProxySchemaVersion: 1
|
|
1456
1483
|
};
|
|
1457
|
-
const result =
|
|
1484
|
+
const result = hsGet3(accountId, {
|
|
1458
1485
|
baseUrl: url3.origin,
|
|
1459
1486
|
uri: url3.pathname,
|
|
1460
1487
|
query: proxiedQueryParams,
|
|
@@ -1470,12 +1497,8 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
1470
1497
|
});
|
|
1471
1498
|
};
|
|
1472
1499
|
var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder, webRoot2, viteServer, pageUrl, basePath, environmentConfig, hsProjectJsonProjectName, webRootProjectComponent) => {
|
|
1473
|
-
const proxySchemaVersion = isUngatedFor(
|
|
1474
|
-
environmentConfig.getGates(),
|
|
1475
|
-
"CMS:JSRenderer:LocalProxySchemaVersion1"
|
|
1476
|
-
) ? 1 : 0;
|
|
1477
1500
|
const { path: placeholderPath } = localRenderPlaceholder;
|
|
1478
|
-
const localRenderPlaceholderProps =
|
|
1501
|
+
const localRenderPlaceholderProps = localRenderPlaceholder.json.props;
|
|
1479
1502
|
const [
|
|
1480
1503
|
__projectIdentifier,
|
|
1481
1504
|
projectFolder,
|
|
@@ -1523,7 +1546,7 @@ var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder,
|
|
|
1523
1546
|
return renderModule_default(
|
|
1524
1547
|
viteServer,
|
|
1525
1548
|
resolvedPath,
|
|
1526
|
-
localRenderPlaceholderProps,
|
|
1549
|
+
localRenderPlaceholderProps.fieldValues,
|
|
1527
1550
|
pageUrl,
|
|
1528
1551
|
basePath,
|
|
1529
1552
|
environmentConfig,
|
|
@@ -1542,7 +1565,7 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
|
|
|
1542
1565
|
let accountId;
|
|
1543
1566
|
let proxyEnv;
|
|
1544
1567
|
try {
|
|
1545
|
-
accountId =
|
|
1568
|
+
accountId = getAccountId2(portalId);
|
|
1546
1569
|
if (accountId === null) {
|
|
1547
1570
|
throw new Error();
|
|
1548
1571
|
}
|
|
@@ -1598,10 +1621,7 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
|
|
|
1598
1621
|
offsetSoFar,
|
|
1599
1622
|
localRenderPlaceholder.startOffset
|
|
1600
1623
|
);
|
|
1601
|
-
if (basePath === void 0
|
|
1602
|
-
environmentConfig.getGates(),
|
|
1603
|
-
"CMS:JSRenderer:LocalProxySchemaVersion1"
|
|
1604
|
-
)) {
|
|
1624
|
+
if (basePath === void 0) {
|
|
1605
1625
|
basePath = getEntryPointBasePathFromProxyRequest(
|
|
1606
1626
|
localRenderPlaceholder.json.request
|
|
1607
1627
|
);
|
|
@@ -1711,14 +1731,10 @@ async function proxyPageRouteHandler(request2, response, next) {
|
|
|
1711
1731
|
return response.status(400).send(message);
|
|
1712
1732
|
}
|
|
1713
1733
|
}
|
|
1714
|
-
if (request2.query.hs_preview) {
|
|
1715
|
-
const message = `Can't make a proxy request, you cannot proxy URLs that include internal query params like hs_preview`;
|
|
1716
|
-
consoleWarn(message);
|
|
1717
|
-
return response.status(400).send(message);
|
|
1718
|
-
}
|
|
1719
1734
|
try {
|
|
1720
1735
|
const { portalId, contentId, hublet } = await fetchContentMetadata(
|
|
1721
|
-
urlToProxy
|
|
1736
|
+
urlToProxy,
|
|
1737
|
+
request2.app.locals.authedPortalId
|
|
1722
1738
|
);
|
|
1723
1739
|
await proxySpecificPage(
|
|
1724
1740
|
response,
|
|
@@ -1866,7 +1882,8 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
1866
1882
|
}
|
|
1867
1883
|
try {
|
|
1868
1884
|
const { portalId, contentId, hublet } = await fetchContentMetadata(
|
|
1869
|
-
proxyPageUrl.href
|
|
1885
|
+
proxyPageUrl.href,
|
|
1886
|
+
request2.app.locals.portalId
|
|
1870
1887
|
);
|
|
1871
1888
|
await proxySpecificPage(
|
|
1872
1889
|
response,
|
|
@@ -1969,7 +1986,7 @@ import express from "express";
|
|
|
1969
1986
|
|
|
1970
1987
|
// src/shadowDevServer/createShadowDevServerRoutes.ts
|
|
1971
1988
|
import { Router as Router2 } from "express";
|
|
1972
|
-
import { getAccountId as
|
|
1989
|
+
import { getAccountId as getAccountId3 } from "@hubspot/cli-lib/lib/config.js";
|
|
1973
1990
|
import cors from "cors";
|
|
1974
1991
|
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
1975
1992
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
@@ -1988,7 +2005,7 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
|
1988
2005
|
let hasJSBuildingBlocks = false;
|
|
1989
2006
|
let localProxyUrl;
|
|
1990
2007
|
try {
|
|
1991
|
-
accountId =
|
|
2008
|
+
accountId = getAccountId3(portalId);
|
|
1992
2009
|
if (accountId === null) {
|
|
1993
2010
|
throw new Error();
|
|
1994
2011
|
}
|
|
@@ -2210,14 +2227,14 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
|
|
|
2210
2227
|
// src/createDevServer.ts
|
|
2211
2228
|
import {
|
|
2212
2229
|
getEnv as getEnv2,
|
|
2213
|
-
getAccountId as
|
|
2230
|
+
getAccountId as getAccountId4,
|
|
2214
2231
|
getAccountConfig,
|
|
2215
2232
|
loadConfig,
|
|
2216
2233
|
validateConfig
|
|
2217
2234
|
} from "@hubspot/cli-lib/lib/config.js";
|
|
2218
2235
|
|
|
2219
2236
|
// src/proxyPage/fetchDomains.ts
|
|
2220
|
-
import { get as
|
|
2237
|
+
import { get as hsGet4 } from "@hubspot/cli-lib/http.js";
|
|
2221
2238
|
|
|
2222
2239
|
// src/lib/errors.ts
|
|
2223
2240
|
var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
|
|
@@ -2246,7 +2263,7 @@ function isMissingScopeError(error) {
|
|
|
2246
2263
|
// src/proxyPage/fetchDomains.ts
|
|
2247
2264
|
async function fetchDomains(portalId) {
|
|
2248
2265
|
try {
|
|
2249
|
-
const result = await
|
|
2266
|
+
const result = await hsGet4(portalId, {
|
|
2250
2267
|
uri: `/cms/v3/domains`,
|
|
2251
2268
|
query: { portalId },
|
|
2252
2269
|
json: true
|
|
@@ -2313,7 +2330,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2313
2330
|
}
|
|
2314
2331
|
loadConfig(hubspotCliConfigPathOption2 || null, { useEnv: false });
|
|
2315
2332
|
if (validateConfig()) {
|
|
2316
|
-
authedPortalId =
|
|
2333
|
+
authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
|
|
2317
2334
|
authedEnv = getEnv2(hubspotCliAccountNameOption2);
|
|
2318
2335
|
personalAccessKey = getAccountConfig(authedPortalId) && getAccountConfig(authedPortalId).personalAccessKey;
|
|
2319
2336
|
if (!authedPortalId && hubspotCliAccountNameOption2) {
|
package/dist/storybook/index.js
CHANGED
|
@@ -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
|
-
|
|
159
|
+
const props = namespaceModulePropsShape({ fieldValues });
|
|
160
|
+
return /* @__PURE__ */ jsx(ModuleComponent, { ...props });
|
|
139
161
|
},
|
|
140
162
|
argTypes,
|
|
141
163
|
args
|
|
@@ -458,14 +458,12 @@ ${indentString}`);
|
|
|
458
458
|
GATES = [
|
|
459
459
|
"CMS:JSRenderer:SharedDeps",
|
|
460
460
|
"CMS:JSRenderer:GetServerSideProps",
|
|
461
|
-
"CMS:JSRenderer:LocalProxySchemaVersion1",
|
|
462
461
|
"CMS:JSRenderer:GraphQLQueryBuild",
|
|
463
462
|
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
464
463
|
];
|
|
465
464
|
ENABLED_FEATURES_GATE_MAP = {
|
|
466
465
|
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
467
466
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
468
|
-
"cms:jsr:localProxySchemaVersion1": "CMS:JSRenderer:LocalProxySchemaVersion1",
|
|
469
467
|
"cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
|
|
470
468
|
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
471
469
|
};
|
|
@@ -527,7 +525,7 @@ ${indentString}`);
|
|
|
527
525
|
}
|
|
528
526
|
let groupStart = "";
|
|
529
527
|
let groupEnd = "";
|
|
530
|
-
if (groupLabel !== null) {
|
|
528
|
+
if (groupLabel !== void 0 && groupLabel !== null) {
|
|
531
529
|
groupStart = `
|
|
532
530
|
console.group(${JSON.stringify(groupLabel)});`;
|
|
533
531
|
groupEnd = ` console.groupEnd()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
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.
|
|
28
|
+
"@hubspot/cms-components": "^0.7.1",
|
|
29
29
|
"@storybook/addon-actions": "7.0.7",
|
|
30
30
|
"@storybook/addon-essentials": "7.0.7",
|
|
31
31
|
"@storybook/addon-interactions": "7.0.7",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "ff3c2fb59eb0dc1db91a928cd5140ce76aae8c1a"
|
|
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.
|
|
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 {};
|