@hubspot/cms-dev-server 0.10.4 → 0.10.5
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/internalSsr.js +8 -3
- package/dist/run.js +90 -10
- package/dist/storybook/index.js +4 -2
- package/dist/storybook-main/main.js +8 -3
- package/package.json +3 -3
package/dist/internalSsr.js
CHANGED
|
@@ -402,7 +402,10 @@ function getIslandRuntimeConfigUrl() {
|
|
|
402
402
|
const fileVersion = hsEnv === "prod" ? `island-runtime.mjs` : "island-runtime-qa.mjs";
|
|
403
403
|
return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;
|
|
404
404
|
}
|
|
405
|
-
var GATES = [
|
|
405
|
+
var GATES = [
|
|
406
|
+
"CMS:JSRenderer:GetServerSideProps",
|
|
407
|
+
"CMS:JSRenderer:ModuleHubl"
|
|
408
|
+
];
|
|
406
409
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
407
410
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps"
|
|
408
411
|
};
|
|
@@ -497,7 +500,8 @@ function namespaceModulePropsShape(props) {
|
|
|
497
500
|
const {
|
|
498
501
|
dataQueryResult,
|
|
499
502
|
hublParameters,
|
|
500
|
-
fieldValues: passedFieldValues
|
|
503
|
+
fieldValues: passedFieldValues,
|
|
504
|
+
hublData
|
|
501
505
|
} = props;
|
|
502
506
|
const oldPropsShape = { ...props };
|
|
503
507
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -511,7 +515,8 @@ function namespaceModulePropsShape(props) {
|
|
|
511
515
|
...fieldValues,
|
|
512
516
|
dataQueryResult,
|
|
513
517
|
fieldValues,
|
|
514
|
-
hublParameters
|
|
518
|
+
hublParameters,
|
|
519
|
+
hublData
|
|
515
520
|
};
|
|
516
521
|
}
|
|
517
522
|
function setIn(object, nestedKeysArray, value) {
|
package/dist/run.js
CHANGED
|
@@ -526,7 +526,8 @@ function namespaceModulePropsShape(props) {
|
|
|
526
526
|
const {
|
|
527
527
|
dataQueryResult,
|
|
528
528
|
hublParameters,
|
|
529
|
-
fieldValues: passedFieldValues
|
|
529
|
+
fieldValues: passedFieldValues,
|
|
530
|
+
hublData
|
|
530
531
|
} = props;
|
|
531
532
|
const oldPropsShape = { ...props };
|
|
532
533
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -540,7 +541,8 @@ function namespaceModulePropsShape(props) {
|
|
|
540
541
|
...fieldValues,
|
|
541
542
|
dataQueryResult,
|
|
542
543
|
fieldValues,
|
|
543
|
-
hublParameters
|
|
544
|
+
hublParameters,
|
|
545
|
+
hublData
|
|
544
546
|
};
|
|
545
547
|
}
|
|
546
548
|
function setIn(object, nestedKeysArray, value) {
|
|
@@ -831,7 +833,82 @@ var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerReque
|
|
|
831
833
|
|
|
832
834
|
// src/routes/partial.ts
|
|
833
835
|
import { buildStaticEnvConfig } from "@hubspot/cms-components";
|
|
836
|
+
|
|
837
|
+
// src/lib/trackUsage.ts
|
|
838
|
+
import cliHttp from "@hubspot/cli-lib/http.js";
|
|
839
|
+
import { getAccountConfig } from "@hubspot/cli-lib/lib/config.js";
|
|
840
|
+
|
|
841
|
+
// src/lib/debug.ts
|
|
842
|
+
import { default as debugFactory } from "debug";
|
|
843
|
+
var debug = debugFactory("cms-dev-server");
|
|
844
|
+
|
|
845
|
+
// src/lib/trackUsage.ts
|
|
846
|
+
var DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED = "/cms-dev-server-usage/v1/authenticated";
|
|
847
|
+
var DEV_SERVER_USAGE_ENDPOINT = "/cms-dev-server-usage/v1";
|
|
848
|
+
var EVENT_NAME = "dev-server-interaction";
|
|
849
|
+
var trackingAccountId = null;
|
|
850
|
+
var trackingEnv = null;
|
|
851
|
+
var getPlatform = () => {
|
|
852
|
+
switch (process.platform) {
|
|
853
|
+
case "darwin":
|
|
854
|
+
return "macos";
|
|
855
|
+
case "win32":
|
|
856
|
+
return "windows";
|
|
857
|
+
default:
|
|
858
|
+
return process.platform;
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
var getNodeVersionData = () => process.version;
|
|
862
|
+
function trackUsage(action) {
|
|
863
|
+
const accountConfig = trackingAccountId && getAccountConfig(trackingAccountId);
|
|
864
|
+
const isAuthedWithPersonalAccessKey = accountConfig && accountConfig.authType === "personalaccesskey";
|
|
865
|
+
const usageEvent = {
|
|
866
|
+
portalId: trackingAccountId,
|
|
867
|
+
eventClass: "INTERACTION" /* INTERACTION */,
|
|
868
|
+
eventName: EVENT_NAME,
|
|
869
|
+
action,
|
|
870
|
+
nodeVersion: getNodeVersionData(),
|
|
871
|
+
version: "0.10.5",
|
|
872
|
+
os: getPlatform()
|
|
873
|
+
};
|
|
874
|
+
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
875
|
+
const baseRequestOptions = {
|
|
876
|
+
uri,
|
|
877
|
+
body: usageEvent,
|
|
878
|
+
resolveWithFullResponse: true
|
|
879
|
+
};
|
|
880
|
+
if (isAuthedWithPersonalAccessKey) {
|
|
881
|
+
return cliHttp.post(trackingAccountId, baseRequestOptions);
|
|
882
|
+
}
|
|
883
|
+
const requestOptions = cliHttp.getRequestOptions(
|
|
884
|
+
{ env: trackingEnv },
|
|
885
|
+
baseRequestOptions
|
|
886
|
+
);
|
|
887
|
+
return cliHttp.request.post(requestOptions);
|
|
888
|
+
}
|
|
889
|
+
var setTrackingInfo = (accountId, env) => {
|
|
890
|
+
trackingAccountId = accountId;
|
|
891
|
+
trackingEnv = env;
|
|
892
|
+
};
|
|
893
|
+
function sendTrackingRequest(action) {
|
|
894
|
+
setImmediate(async () => {
|
|
895
|
+
try {
|
|
896
|
+
await trackUsage(action);
|
|
897
|
+
debug(
|
|
898
|
+
wrapMessageInColor(
|
|
899
|
+
"white",
|
|
900
|
+
`Sent usage tracking action event: ${action}`
|
|
901
|
+
)
|
|
902
|
+
);
|
|
903
|
+
} catch (e) {
|
|
904
|
+
debug(wrapMessageInColor("red", `Usage tracking failed: ${e.message}`));
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// src/routes/partial.ts
|
|
834
910
|
var partialRouteHandler = async (request2, response) => {
|
|
911
|
+
sendTrackingRequest("view-partial-route");
|
|
835
912
|
const {
|
|
836
913
|
authedPortalId,
|
|
837
914
|
authedEnv,
|
|
@@ -992,7 +1069,7 @@ import { join as joinPosix2 } from "path/posix";
|
|
|
992
1069
|
import { traverseFieldsJSON } from "@hubspot/cms-components/fields";
|
|
993
1070
|
|
|
994
1071
|
// src/lib/fetchModuleGraphQLData.ts
|
|
995
|
-
import
|
|
1072
|
+
import cliHttp2 from "@hubspot/cli-lib/http.js";
|
|
996
1073
|
var graphQLCache = /* @__PURE__ */ new Map();
|
|
997
1074
|
async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pageUrl) {
|
|
998
1075
|
const { searchParams } = new URL(pageUrl);
|
|
@@ -1004,7 +1081,7 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
|
|
|
1004
1081
|
return Promise.resolve(graphQLCache.get(compositeQueryKey));
|
|
1005
1082
|
}
|
|
1006
1083
|
try {
|
|
1007
|
-
dataQueryResult = await
|
|
1084
|
+
dataQueryResult = await cliHttp2.post(accountId, {
|
|
1008
1085
|
uri: "/collector/v3/graphql",
|
|
1009
1086
|
body: {
|
|
1010
1087
|
query
|
|
@@ -1133,6 +1210,7 @@ var renderModule_default = renderModule;
|
|
|
1133
1210
|
|
|
1134
1211
|
// src/routes/module.ts
|
|
1135
1212
|
var moduleRouteHandler = async (request2, response) => {
|
|
1213
|
+
sendTrackingRequest("view-module-route");
|
|
1136
1214
|
const {
|
|
1137
1215
|
authedPortalId,
|
|
1138
1216
|
authedEnv,
|
|
@@ -1811,6 +1889,7 @@ ${error.stack}`
|
|
|
1811
1889
|
|
|
1812
1890
|
// src/routes/proxyPageRouteHandler.ts
|
|
1813
1891
|
async function proxyPageRouteHandler(request2, response, next) {
|
|
1892
|
+
sendTrackingRequest("view-proxy-page-route");
|
|
1814
1893
|
const {
|
|
1815
1894
|
viteServer,
|
|
1816
1895
|
webRoot: webRoot2,
|
|
@@ -1909,6 +1988,7 @@ function proxyPageResourceRedirect(req, res, next) {
|
|
|
1909
1988
|
// src/routes/homeRouteHandler.tsx
|
|
1910
1989
|
import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1911
1990
|
var homeRouteHandler = async (request2, response) => {
|
|
1991
|
+
sendTrackingRequest("view-home-route");
|
|
1912
1992
|
const { webRoot: webRoot2, storybookEnabled, devServerPort } = request2.app.locals;
|
|
1913
1993
|
const { partialNames } = findAllPartialsInRoot(webRoot2);
|
|
1914
1994
|
const { moduleNames } = findAllModulesInRoot(webRoot2);
|
|
@@ -1928,13 +2008,10 @@ var homeRouteHandler = async (request2, response) => {
|
|
|
1928
2008
|
};
|
|
1929
2009
|
var homeRouteHandler_default = homeRouteHandler;
|
|
1930
2010
|
|
|
1931
|
-
// src/lib/debug.ts
|
|
1932
|
-
import { default as debugFactory } from "debug";
|
|
1933
|
-
var debug = debugFactory("cms-dev-server");
|
|
1934
|
-
|
|
1935
2011
|
// src/routes/proxyPathPageRouteHandler.tsx
|
|
1936
2012
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1937
2013
|
async function proxyPathPageRouteHandler(request2, response, next) {
|
|
2014
|
+
sendTrackingRequest("view-proxy-path-route");
|
|
1938
2015
|
const {
|
|
1939
2016
|
viteServer,
|
|
1940
2017
|
webRoot: webRoot2,
|
|
@@ -2341,7 +2418,7 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
|
|
|
2341
2418
|
import {
|
|
2342
2419
|
getEnv as getEnv2,
|
|
2343
2420
|
getAccountId as getAccountId4,
|
|
2344
|
-
getAccountConfig,
|
|
2421
|
+
getAccountConfig as getAccountConfig2,
|
|
2345
2422
|
loadConfig,
|
|
2346
2423
|
validateConfig
|
|
2347
2424
|
} from "@hubspot/cli-lib/lib/config.js";
|
|
@@ -2425,7 +2502,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2425
2502
|
if (validateConfig()) {
|
|
2426
2503
|
authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
|
|
2427
2504
|
authedEnv = getEnv2(hubspotCliAccountNameOption2);
|
|
2428
|
-
personalAccessKey =
|
|
2505
|
+
personalAccessKey = getAccountConfig2(authedPortalId) && getAccountConfig2(authedPortalId).personalAccessKey;
|
|
2429
2506
|
if (!authedPortalId && hubspotCliAccountNameOption2) {
|
|
2430
2507
|
console.error(
|
|
2431
2508
|
`Couldn't find ${hubspotCliAccountNameOption2} in your hubspot.config.yaml`
|
|
@@ -2453,6 +2530,8 @@ If needed you can refer to another config file with --config.
|
|
|
2453
2530
|
Local proxy functionality will not work without setting up authentication.`
|
|
2454
2531
|
);
|
|
2455
2532
|
}
|
|
2533
|
+
setTrackingInfo(authedPortalId, authedEnv);
|
|
2534
|
+
sendTrackingRequest("start-dev-server");
|
|
2456
2535
|
let domainsToProxy = [];
|
|
2457
2536
|
if (sslEnabledOption2 && authedPortalId) {
|
|
2458
2537
|
try {
|
|
@@ -2542,6 +2621,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2542
2621
|
if (storybook2) {
|
|
2543
2622
|
const packageRoot = path6.dirname(url2.fileURLToPath(import.meta.url));
|
|
2544
2623
|
const configPath = path6.resolve(packageRoot, "./storybook-main");
|
|
2624
|
+
sendTrackingRequest("start-storybook");
|
|
2545
2625
|
const storybookProcess = spawn(
|
|
2546
2626
|
"sb",
|
|
2547
2627
|
[
|
package/dist/storybook/index.js
CHANGED
|
@@ -8,7 +8,8 @@ function namespaceModulePropsShape(props) {
|
|
|
8
8
|
const {
|
|
9
9
|
dataQueryResult,
|
|
10
10
|
hublParameters,
|
|
11
|
-
fieldValues: passedFieldValues
|
|
11
|
+
fieldValues: passedFieldValues,
|
|
12
|
+
hublData
|
|
12
13
|
} = props;
|
|
13
14
|
const oldPropsShape = { ...props };
|
|
14
15
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -22,7 +23,8 @@ function namespaceModulePropsShape(props) {
|
|
|
22
23
|
...fieldValues,
|
|
23
24
|
dataQueryResult,
|
|
24
25
|
fieldValues,
|
|
25
|
-
hublParameters
|
|
26
|
+
hublParameters,
|
|
27
|
+
hublData
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
function renderFieldsJSX(fieldsJSX) {
|
|
@@ -294,7 +294,8 @@ function namespaceModulePropsShape(props) {
|
|
|
294
294
|
const {
|
|
295
295
|
dataQueryResult,
|
|
296
296
|
hublParameters,
|
|
297
|
-
fieldValues: passedFieldValues
|
|
297
|
+
fieldValues: passedFieldValues,
|
|
298
|
+
hublData
|
|
298
299
|
} = props;
|
|
299
300
|
const oldPropsShape = { ...props };
|
|
300
301
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -308,7 +309,8 @@ function namespaceModulePropsShape(props) {
|
|
|
308
309
|
...fieldValues,
|
|
309
310
|
dataQueryResult,
|
|
310
311
|
fieldValues,
|
|
311
|
-
hublParameters
|
|
312
|
+
hublParameters,
|
|
313
|
+
hublData
|
|
312
314
|
};
|
|
313
315
|
}
|
|
314
316
|
function setIn(object, nestedKeysArray, value) {
|
|
@@ -584,7 +586,10 @@ ${groupEnd}</script>
|
|
|
584
586
|
};
|
|
585
587
|
COMBINED_REACT_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/react/v18";
|
|
586
588
|
ISLAND_RUNTIME_CONFIG_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/island-runtime/v1";
|
|
587
|
-
GATES = [
|
|
589
|
+
GATES = [
|
|
590
|
+
"CMS:JSRenderer:GetServerSideProps",
|
|
591
|
+
"CMS:JSRenderer:ModuleHubl"
|
|
592
|
+
];
|
|
588
593
|
ENABLED_FEATURES_GATE_MAP = {
|
|
589
594
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps"
|
|
590
595
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
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.10.
|
|
28
|
+
"@hubspot/cms-components": "^0.10.5",
|
|
29
29
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
30
30
|
"@storybook/addon-actions": "7.0.7",
|
|
31
31
|
"@storybook/addon-essentials": "7.0.7",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "7ed5dcd825985df14b15d6bd94f614e8b4187178"
|
|
105
105
|
}
|