@hubspot/cms-dev-server 0.6.0 → 0.6.2
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/index.js +0 -10
- package/dist/internalSsr.js +4 -7
- package/dist/run.js +43 -9
- package/dist/storybook/index.js +61 -46
- package/dist/{storybook → storybook-main}/main.js +24 -9
- package/dist/storybook-main/preview.js +20 -0
- package/package.json +11 -10
- package/types/storybook/getFieldsArgTypes.d.ts +1 -7
- package/types/storybook/moduleStory.d.ts +5 -2
- package/types/storybook/types.d.ts +11 -0
- package/dist/components/ModulesList.js +0 -14
- package/dist/components/PartialsList.js +0 -13
- package/dist/createDevServer.js +0 -162
- package/dist/createViteDevServer.js +0 -51
- package/dist/lib/cli.js +0 -27
- package/dist/lib/debug.js +0 -2
- package/dist/lib/errors.js +0 -22
- package/dist/lib/fullOriginalUrlFromRequest.js +0 -3
- package/dist/lib/httpsRedirectingServer.js +0 -48
- package/dist/lib/moduleGraph.js +0 -11
- package/dist/lib/proxyHelpers.js +0 -70
- package/dist/lib/proxyHelpers.test.js +0 -136
- package/dist/lib/renderComponentWithCSS.js +0 -26
- package/dist/lib/renderHelpers.js +0 -45
- package/dist/lib/renderModule.js +0 -56
- package/dist/lib/renderPartial.js +0 -15
- package/dist/lib/templates.js +0 -55
- package/dist/proxyPage/constants.js +0 -1
- package/dist/proxyPage/fetchContentMetadata.js +0 -59
- package/dist/proxyPage/fetchDomains.js +0 -29
- package/dist/proxyPage/fetchPreviewInfo.js +0 -37
- package/dist/proxyPage/proxyPage.js +0 -174
- package/dist/proxyPage/renderLocalError.js +0 -27
- package/dist/proxyPage/utils.js +0 -38
- package/dist/routes/createDevServerRoutes.js +0 -43
- package/dist/routes/homeRouteHandler.js +0 -12
- package/dist/routes/linksToAllModulesRouteHandler.js +0 -10
- package/dist/routes/linksToAllPartialsRouteHandler.js +0 -10
- package/dist/routes/module.js +0 -41
- package/dist/routes/partial.js +0 -30
- package/dist/routes/proxyPageResourceRedirect.js +0 -22
- package/dist/routes/proxyPageRouteHandler.js +0 -40
- package/dist/routes/proxyPathPageResourceRedirect.js +0 -36
- package/dist/routes/proxyPathPageRouteHandler.js +0 -43
- package/dist/shadowDevServer/createShadowDevServerRoutes.js +0 -63
- package/dist/shadowDevServer/startShadowDevServer.js +0 -31
- package/dist/storybook/getFieldsArgTypes.js +0 -54
- package/dist/storybook/getFieldsArgTypes.test.js +0 -91
- package/dist/storybook/getNestedFieldObjectForArgs.js +0 -22
- package/dist/storybook/getNestedFieldObjectForArgs.test.js +0 -40
- package/dist/storybook/moduleStory.js +0 -61
- package/dist/storybook/preview.js +0 -9
- package/dist/storybook/types.js +0 -1
package/dist/index.js
CHANGED
|
@@ -4,16 +4,6 @@ import { default as react } from "@vitejs/plugin-react";
|
|
|
4
4
|
|
|
5
5
|
// ../cms-js-internal/dist/index.js
|
|
6
6
|
import path, { basename } from "path";
|
|
7
|
-
import { createRequire } from "module";
|
|
8
|
-
import * as jsxRuntime from "react/jsx-runtime";
|
|
9
|
-
import stream from "stream";
|
|
10
|
-
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
11
|
-
import { createServerRenderContextV2, ServerRenderContext } from "@hubspot/cms-components";
|
|
12
|
-
import { createHash } from "crypto";
|
|
13
|
-
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
14
|
-
import { join } from "path/posix";
|
|
15
|
-
import { cloneElement } from "react";
|
|
16
|
-
var require2 = createRequire(import.meta.url);
|
|
17
7
|
function isUngatedFor(gates, gate) {
|
|
18
8
|
return gates.includes(gate);
|
|
19
9
|
}
|
package/dist/internalSsr.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// ../cms-js-internal/dist/index.js
|
|
2
2
|
import path, { basename } from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
4
4
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
5
5
|
import stream from "stream";
|
|
6
6
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
7
7
|
import { createServerRenderContextV2, ServerRenderContext } from "@hubspot/cms-components";
|
|
8
8
|
import { createHash } from "crypto";
|
|
9
|
-
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
10
9
|
import { join } from "path/posix";
|
|
11
10
|
import { cloneElement } from "react";
|
|
12
11
|
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -152,7 +151,6 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
152
151
|
indent
|
|
153
152
|
)}${writeSharedStateToJsGlobal(islands, perServerRequestData, indent)}`;
|
|
154
153
|
};
|
|
155
|
-
var require2 = createRequire(import.meta.url);
|
|
156
154
|
var GATES = [
|
|
157
155
|
"CMS:JSRenderer:SharedDeps",
|
|
158
156
|
"CMS:JSRenderer:GetServerSideProps",
|
|
@@ -173,10 +171,9 @@ var BUILD_INFO_PATH = "/build-info.json";
|
|
|
173
171
|
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
174
172
|
try {
|
|
175
173
|
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
176
|
-
const buildInfo =
|
|
177
|
-
buildDir,
|
|
178
|
-
|
|
179
|
-
));
|
|
174
|
+
const buildInfo = JSON.parse(
|
|
175
|
+
readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()
|
|
176
|
+
);
|
|
180
177
|
return isUngatedFor(buildInfo.gates, gate);
|
|
181
178
|
} catch (e) {
|
|
182
179
|
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
package/dist/run.js
CHANGED
|
@@ -40,6 +40,7 @@ import http3 from "http";
|
|
|
40
40
|
import bodyParser from "body-parser";
|
|
41
41
|
import { spawn } from "child_process";
|
|
42
42
|
import { normalizePath as normalizePath4 } from "vite";
|
|
43
|
+
import { Transform } from "stream";
|
|
43
44
|
|
|
44
45
|
// src/routes/createDevServerRoutes.ts
|
|
45
46
|
import { Router } from "express";
|
|
@@ -56,13 +57,12 @@ function fullOriginalUrlFromRequest(request2) {
|
|
|
56
57
|
|
|
57
58
|
// ../cms-js-internal/dist/index.js
|
|
58
59
|
import path, { basename } from "path";
|
|
59
|
-
import {
|
|
60
|
+
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
60
61
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
61
62
|
import stream from "stream";
|
|
62
63
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
63
64
|
import { createServerRenderContextV2, ServerRenderContext } from "@hubspot/cms-components";
|
|
64
65
|
import { createHash } from "crypto";
|
|
65
|
-
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
66
66
|
import { join } from "path/posix";
|
|
67
67
|
import { cloneElement } from "react";
|
|
68
68
|
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -147,7 +147,6 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
147
147
|
indent
|
|
148
148
|
)}${writeSharedStateToJsGlobal(islands, perServerRequestData, indent)}`;
|
|
149
149
|
};
|
|
150
|
-
var require2 = createRequire(import.meta.url);
|
|
151
150
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
152
151
|
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
153
152
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
@@ -2115,6 +2114,23 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
2115
2114
|
return domainNames;
|
|
2116
2115
|
}
|
|
2117
2116
|
|
|
2117
|
+
// src/lib/logColors.ts
|
|
2118
|
+
var CONTROL_CHARACTER = "\x1B";
|
|
2119
|
+
var DEFAULT_SCHEME = "[0m";
|
|
2120
|
+
var ForeGroudANSIColorMap = {
|
|
2121
|
+
black: 30,
|
|
2122
|
+
red: 31,
|
|
2123
|
+
green: 32,
|
|
2124
|
+
yellow: 33,
|
|
2125
|
+
blue: 34,
|
|
2126
|
+
megenta: 35,
|
|
2127
|
+
cyan: 36,
|
|
2128
|
+
white: 37
|
|
2129
|
+
};
|
|
2130
|
+
function wrapMessageInColor(color, message) {
|
|
2131
|
+
return `${CONTROL_CHARACTER}[${ForeGroudANSIColorMap[color]}m${message}${CONTROL_CHARACTER}${DEFAULT_SCHEME}`;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2118
2134
|
// src/createDevServer.ts
|
|
2119
2135
|
var BASE_PATH = "/";
|
|
2120
2136
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
@@ -2259,7 +2275,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2259
2275
|
);
|
|
2260
2276
|
if (storybook2) {
|
|
2261
2277
|
const packageRoot = path6.dirname(url2.fileURLToPath(import.meta.url));
|
|
2262
|
-
const configPath = path6.resolve(packageRoot, "./storybook");
|
|
2278
|
+
const configPath = path6.resolve(packageRoot, "./storybook-main");
|
|
2263
2279
|
const storybookProcess = spawn(
|
|
2264
2280
|
"npx",
|
|
2265
2281
|
[
|
|
@@ -2276,15 +2292,33 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2276
2292
|
cwd: process.cwd(),
|
|
2277
2293
|
env: {
|
|
2278
2294
|
...process.env,
|
|
2295
|
+
portalId: authedPortalId.toString(),
|
|
2296
|
+
hsEnv: authedEnv,
|
|
2297
|
+
hublet: authedHublet,
|
|
2279
2298
|
WEB_ROOT: path6.join(webRoot2, "components")
|
|
2280
2299
|
}
|
|
2281
2300
|
}
|
|
2282
2301
|
);
|
|
2283
|
-
console.log(
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2302
|
+
console.log(
|
|
2303
|
+
wrapMessageInColor(
|
|
2304
|
+
"yellow",
|
|
2305
|
+
`Starting storybook server on port ${STORYBOOK_PORT}`
|
|
2306
|
+
)
|
|
2307
|
+
);
|
|
2308
|
+
storybookProcess.stdout.pipe(
|
|
2309
|
+
new Transform({
|
|
2310
|
+
transform(chunk, _encoding, callback) {
|
|
2311
|
+
callback(null, wrapMessageInColor("yellow", chunk.toString()));
|
|
2312
|
+
}
|
|
2313
|
+
})
|
|
2314
|
+
).pipe(process.stdout);
|
|
2315
|
+
storybookProcess.stderr.pipe(
|
|
2316
|
+
new Transform({
|
|
2317
|
+
transform(chunk, _encoding, callback) {
|
|
2318
|
+
callback(null, wrapMessageInColor("red", chunk.toString()));
|
|
2319
|
+
}
|
|
2320
|
+
})
|
|
2321
|
+
).pipe(process.stderr);
|
|
2288
2322
|
}
|
|
2289
2323
|
return {
|
|
2290
2324
|
close: () => {
|
package/dist/storybook/index.js
CHANGED
|
@@ -3,17 +3,8 @@ import React, { useEffect } from "react";
|
|
|
3
3
|
import { renderToStaticMarkup as renderToStaticMarkup2 } from "react-dom/server";
|
|
4
4
|
|
|
5
5
|
// ../cms-js-internal/dist/index.js
|
|
6
|
-
import path, { basename } from "path";
|
|
7
|
-
import { createRequire } from "module";
|
|
8
|
-
import * as jsxRuntime from "react/jsx-runtime";
|
|
9
|
-
import stream from "stream";
|
|
10
6
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
11
|
-
import { createServerRenderContextV2, ServerRenderContext } from "@hubspot/cms-components";
|
|
12
|
-
import { createHash } from "crypto";
|
|
13
|
-
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
14
|
-
import { join } from "path/posix";
|
|
15
7
|
import { cloneElement } from "react";
|
|
16
|
-
var require2 = createRequire(import.meta.url);
|
|
17
8
|
function renderFieldsToJson(fields) {
|
|
18
9
|
let moduleJson;
|
|
19
10
|
const outputCallback = (callbackJson) => {
|
|
@@ -103,7 +94,7 @@ function getNestedFieldObjectForArgs(_args) {
|
|
|
103
94
|
}
|
|
104
95
|
|
|
105
96
|
// src/storybook/moduleStory.tsx
|
|
106
|
-
import { jsx
|
|
97
|
+
import { jsx } from "react/jsx-runtime";
|
|
107
98
|
function moduleFieldsToJson(fields) {
|
|
108
99
|
let moduleJson;
|
|
109
100
|
const outputCallback = (callbackJson) => {
|
|
@@ -119,50 +110,74 @@ function moduleFieldsToJson(fields) {
|
|
|
119
110
|
}
|
|
120
111
|
return moduleJson;
|
|
121
112
|
}
|
|
122
|
-
function
|
|
113
|
+
function moduleArgs(argTypes) {
|
|
114
|
+
const args = {};
|
|
115
|
+
for (const argKey in argTypes) {
|
|
116
|
+
if (Object.hasOwnProperty.call(argTypes, argKey)) {
|
|
117
|
+
args[argKey] = argTypes[argKey].defaultValue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return args;
|
|
121
|
+
}
|
|
122
|
+
function moduleStory(ModuleComponent, fields, storyArgs) {
|
|
123
123
|
const moduleJson = renderFieldsToJson(fields);
|
|
124
124
|
const argTypes = getFieldsArgTypes(moduleJson);
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
const args = { ...moduleArgs(argTypes), ...storyArgs };
|
|
126
|
+
return {
|
|
127
|
+
render: (_args) => {
|
|
128
|
+
const fieldValues = getNestedFieldObjectForArgs(_args);
|
|
129
|
+
return /* @__PURE__ */ jsx(ModuleComponent, { ...fieldValues });
|
|
130
|
+
},
|
|
131
|
+
argTypes,
|
|
132
|
+
args
|
|
133
|
+
};
|
|
130
134
|
}
|
|
131
|
-
function moduleStoryWithIsland(moduleName,
|
|
135
|
+
function moduleStoryWithIsland(fields, moduleName, storyArgs) {
|
|
136
|
+
if (typeof moduleName !== "string") {
|
|
137
|
+
throw new Error(
|
|
138
|
+
"moduleStoryWithIsland takes Fields JSX as the first argument, and the moduleName that matches the file or folder name for the module as a string for the second parameter"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
if (!moduleName) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"moduleStoryWithIsland requires a second moduleName parameter that matches the file or folder name for the module"
|
|
144
|
+
);
|
|
145
|
+
}
|
|
132
146
|
const moduleJson = moduleFieldsToJson(fields);
|
|
133
147
|
const argTypes = getFieldsArgTypes(moduleJson);
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
const args = { ...moduleArgs(argTypes), ...storyArgs };
|
|
149
|
+
return {
|
|
150
|
+
argTypes,
|
|
151
|
+
args,
|
|
152
|
+
render: (_args) => {
|
|
153
|
+
const fieldValues = getNestedFieldObjectForArgs(_args);
|
|
154
|
+
const fieldValuesString = JSON.stringify(fieldValues);
|
|
155
|
+
const domain = `${window.location.protocol}//${window.location.hostname.replace("storybook.", "")}:3000`;
|
|
156
|
+
const fieldValuesJson = encodeURIComponent(fieldValuesString);
|
|
157
|
+
const iframeSrc = `${domain}/module/${moduleName}?fields=${fieldValuesJson}`;
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
const existingElement = document.querySelector("#hs-module-iframe");
|
|
160
|
+
if (existingElement) {
|
|
161
|
+
existingElement.setAttribute("src", iframeSrc);
|
|
162
|
+
return () => {
|
|
163
|
+
existingElement.remove();
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const iframeElement = document.createElement("iframe");
|
|
167
|
+
iframeElement.setAttribute("src", iframeSrc);
|
|
168
|
+
iframeElement.setAttribute("id", "hs-module-iframe");
|
|
169
|
+
iframeElement.setAttribute(
|
|
170
|
+
"style",
|
|
171
|
+
`border: none;width: 100%;height: 100%;overflow: auto;`
|
|
172
|
+
);
|
|
173
|
+
document.querySelector("#storybook-root").appendChild(iframeElement);
|
|
144
174
|
return () => {
|
|
145
|
-
|
|
175
|
+
iframeElement.remove();
|
|
146
176
|
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
iframeElement.setAttribute("id", "hs-module-iframe");
|
|
151
|
-
iframeElement.setAttribute(
|
|
152
|
-
"style",
|
|
153
|
-
`border: none;width: 100%;height: 100%;overflow: auto;`
|
|
154
|
-
);
|
|
155
|
-
document.body.appendChild(iframeElement);
|
|
156
|
-
return () => {
|
|
157
|
-
iframeElement.remove();
|
|
158
|
-
};
|
|
159
|
-
}, [iframeSrc]);
|
|
160
|
-
return /* @__PURE__ */ jsx2("div", {});
|
|
177
|
+
}, [iframeSrc]);
|
|
178
|
+
return /* @__PURE__ */ jsx("div", {});
|
|
179
|
+
}
|
|
161
180
|
};
|
|
162
|
-
const storyWithArgs = story.bind({});
|
|
163
|
-
storyWithArgs.argTypes = argTypes;
|
|
164
|
-
storyWithArgs.args = {};
|
|
165
|
-
return storyWithArgs;
|
|
166
181
|
}
|
|
167
182
|
export {
|
|
168
183
|
moduleFieldsToJson,
|
|
@@ -48,13 +48,12 @@ __export(dist_exports, {
|
|
|
48
48
|
virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
|
|
49
49
|
});
|
|
50
50
|
import path, { basename } from "path";
|
|
51
|
-
import {
|
|
51
|
+
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
52
52
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
53
53
|
import stream from "stream";
|
|
54
54
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
55
55
|
import { createServerRenderContextV2, ServerRenderContext } from "@hubspot/cms-components";
|
|
56
56
|
import { createHash } from "crypto";
|
|
57
|
-
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
58
57
|
import { join } from "path/posix";
|
|
59
58
|
import { cloneElement } from "react";
|
|
60
59
|
function createPreloadLink(assetPath, basePath = "") {
|
|
@@ -100,10 +99,9 @@ function isUngatedFor(gates, gate) {
|
|
|
100
99
|
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
101
100
|
try {
|
|
102
101
|
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
103
|
-
const buildInfo =
|
|
104
|
-
buildDir,
|
|
105
|
-
|
|
106
|
-
));
|
|
102
|
+
const buildInfo = JSON.parse(
|
|
103
|
+
readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()
|
|
104
|
+
);
|
|
107
105
|
return isUngatedFor(buildInfo.gates, gate);
|
|
108
106
|
} catch (e) {
|
|
109
107
|
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
|
@@ -295,7 +293,7 @@ function renderFieldsToJson(fields) {
|
|
|
295
293
|
);
|
|
296
294
|
return moduleJson;
|
|
297
295
|
}
|
|
298
|
-
var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, serializeIslandDataToJSON, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev,
|
|
296
|
+
var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, serializeIslandDataToJSON, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, GATES, ENABLED_FEATURES_GATE_MAP, BUILD_INFO_PATH, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, jsx2, promiseForNewWritableStream, renderStreamToPromise, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, findAllComponentsIn;
|
|
299
297
|
var init_dist = __esm({
|
|
300
298
|
"../cms-js-internal/dist/index.js"() {
|
|
301
299
|
COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -404,7 +402,6 @@ ${indentString}`);
|
|
|
404
402
|
indent
|
|
405
403
|
)}${writeSharedStateToJsGlobal(islands, perServerRequestData, indent)}`;
|
|
406
404
|
};
|
|
407
|
-
require2 = createRequire(import.meta.url);
|
|
408
405
|
GATES = [
|
|
409
406
|
"CMS:JSRenderer:SharedDeps",
|
|
410
407
|
"CMS:JSRenderer:GetServerSideProps",
|
|
@@ -541,7 +538,7 @@ ${groupEnd}</script>
|
|
|
541
538
|
}
|
|
542
539
|
});
|
|
543
540
|
|
|
544
|
-
// src/storybook/main.ts
|
|
541
|
+
// src/storybook-main/main.ts
|
|
545
542
|
import path2 from "path";
|
|
546
543
|
import { mergeConfig } from "vite";
|
|
547
544
|
var webRoot = process.env.WEB_ROOT;
|
|
@@ -551,6 +548,24 @@ var main_default = {
|
|
|
551
548
|
addons: ["@storybook/addon-essentials"],
|
|
552
549
|
framework: "@storybook/react-vite",
|
|
553
550
|
stories: [storyPath],
|
|
551
|
+
previewHead: (head) => {
|
|
552
|
+
return `
|
|
553
|
+
${head}
|
|
554
|
+
|
|
555
|
+
<script type="module">
|
|
556
|
+
import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
|
|
557
|
+
|
|
558
|
+
initConfigSingletonFromJSON(${JSON.stringify({
|
|
559
|
+
portalId: process.env.portalId,
|
|
560
|
+
hublet: process.env.hublet,
|
|
561
|
+
hsEnv: process.env.hsEnv,
|
|
562
|
+
hsDeployed: false,
|
|
563
|
+
hsJSRGates: jsRenderingGates
|
|
564
|
+
})})
|
|
565
|
+
</script>
|
|
566
|
+
|
|
567
|
+
`;
|
|
568
|
+
},
|
|
554
569
|
viteFinal: async (config) => {
|
|
555
570
|
const { resolveIslandPlugin: resolveIslandPlugin2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
556
571
|
const viteConfig = {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/storybook-main/preview.jsx
|
|
2
|
+
import {
|
|
3
|
+
ServerRenderContext,
|
|
4
|
+
createServerRenderContextV2,
|
|
5
|
+
ClientRenderContextProvider
|
|
6
|
+
} from "@hubspot/cms-components";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var parameters = {
|
|
9
|
+
actions: { argTypesRegex: "^on[A-Z].*" }
|
|
10
|
+
};
|
|
11
|
+
var contextValue = createServerRenderContextV2("http://testUrl.com", {
|
|
12
|
+
environmentConfig: null
|
|
13
|
+
});
|
|
14
|
+
var decorators = [
|
|
15
|
+
(Story) => /* @__PURE__ */ jsx(ClientRenderContextProvider, { pageUrl: "http://test.com", islands: [], children: /* @__PURE__ */ jsx(ServerRenderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(Story, {}) }) })
|
|
16
|
+
];
|
|
17
|
+
export {
|
|
18
|
+
decorators,
|
|
19
|
+
parameters
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@hubspot/cli-lib": "^3.0.12",
|
|
27
|
-
"@hubspot/cms-components": "^0.6.
|
|
28
|
-
"@storybook/addon-actions": "
|
|
29
|
-
"@storybook/addon-essentials": "
|
|
30
|
-
"@storybook/addon-interactions": "
|
|
31
|
-
"@storybook/addon-links": "
|
|
32
|
-
"@storybook/cli": "
|
|
33
|
-
"@storybook/react": "
|
|
34
|
-
"@storybook/react-vite": "
|
|
27
|
+
"@hubspot/cms-components": "^0.6.2",
|
|
28
|
+
"@storybook/addon-actions": "7.0.7",
|
|
29
|
+
"@storybook/addon-essentials": "7.0.7",
|
|
30
|
+
"@storybook/addon-interactions": "7.0.7",
|
|
31
|
+
"@storybook/addon-links": "7.0.7",
|
|
32
|
+
"@storybook/cli": "7.0.7",
|
|
33
|
+
"@storybook/react": "7.0.7",
|
|
34
|
+
"@storybook/react-vite": "7.0.7",
|
|
35
35
|
"@storybook/testing-library": "^0.0.13",
|
|
36
36
|
"@vitejs/plugin-react": "^3.0.0",
|
|
37
37
|
"ansi-to-html": "0.7.x",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@types/react": "^18.0.0",
|
|
55
55
|
"@types/react-dom": "^18.0.0",
|
|
56
56
|
"copyfiles": "^2.4.1",
|
|
57
|
+
"esbuild": "^0.16.17",
|
|
57
58
|
"node-fetch": "^3.3.0",
|
|
58
59
|
"nodemon": "^2.0.15",
|
|
59
60
|
"ts-node": "^10.7.0",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
"publishConfig": {
|
|
96
97
|
"access": "public"
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "2722fa4ace6c761a57ecaf7110add08b5e6b930e"
|
|
99
100
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { Field } from '@hubspot/cms-components/fields';
|
|
2
|
-
|
|
3
|
-
[fieldPath: string]: {
|
|
4
|
-
control: string;
|
|
5
|
-
defaultValue: any;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
2
|
+
import { ArgTypes } from './types.js';
|
|
8
3
|
export default function getFieldsArgTypes(fieldsJson: Field[], currentPathSegments?: string[]): ArgTypes;
|
|
9
|
-
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Field } from '@hubspot/cms-components/fields';
|
|
3
|
+
import { Args, ModuleStory } from './types.js';
|
|
3
4
|
export declare function moduleFieldsToJson(fields: JSX.Element): Field[];
|
|
4
|
-
export declare function moduleStory(ModuleComponent: React.ComponentType, fields: JSX.Element):
|
|
5
|
-
export declare function moduleStoryWithIsland(
|
|
5
|
+
export declare function moduleStory(ModuleComponent: React.ComponentType, fields: JSX.Element, storyArgs: Args): ModuleStory;
|
|
6
|
+
export declare function moduleStoryWithIsland(fields: JSX.Element, // was module component
|
|
7
|
+
moduleName: string, // was fields jSX
|
|
8
|
+
storyArgs: Args): ModuleStory;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
export declare type Args = {
|
|
2
2
|
[fieldPath: string]: any;
|
|
3
3
|
};
|
|
4
|
+
export declare type ArgTypes = {
|
|
5
|
+
[fieldPath: string]: {
|
|
6
|
+
control: string;
|
|
7
|
+
defaultValue: any;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare type ModuleStory = {
|
|
11
|
+
render: React.ComponentType;
|
|
12
|
+
argTypes: ArgTypes;
|
|
13
|
+
args: Args;
|
|
14
|
+
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
function EmptyModulesList({ webRoot }) {
|
|
3
|
-
return (_jsxs("p", { children: ["No modules in ", _jsxs("code", { children: [webRoot, "components/modules"] })] }));
|
|
4
|
-
}
|
|
5
|
-
function ModuleLinkInLI({ moduleName }) {
|
|
6
|
-
return (_jsx("li", { children: _jsx("a", { href: `/module/${moduleName}`, children: moduleName }) }));
|
|
7
|
-
}
|
|
8
|
-
function ModulesList({ webRoot, moduleNames }) {
|
|
9
|
-
if (moduleNames.length === 0) {
|
|
10
|
-
return _jsx(EmptyModulesList, { webRoot: webRoot });
|
|
11
|
-
}
|
|
12
|
-
return (_jsx("ul", { children: moduleNames.map(moduleName => (_jsx(ModuleLinkInLI, { moduleName: moduleName }, moduleName))) }));
|
|
13
|
-
}
|
|
14
|
-
export default ModulesList;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
function EmptyPartialsList({ webRoot }) {
|
|
3
|
-
return (_jsxs("p", { children: ["No partials in ", _jsxs("code", { children: [webRoot, "components/partials"] })] }));
|
|
4
|
-
}
|
|
5
|
-
function PartialLinkInLI({ partialName }) {
|
|
6
|
-
return (_jsx("li", { children: _jsx("a", { href: `/partial/${partialName}`, children: partialName }) }));
|
|
7
|
-
}
|
|
8
|
-
export default function PartialsList({ webRoot, partialNames }) {
|
|
9
|
-
if (partialNames.length === 0) {
|
|
10
|
-
return _jsx(EmptyPartialsList, { webRoot: webRoot });
|
|
11
|
-
}
|
|
12
|
-
return (_jsx("ul", { children: partialNames.map(partialName => (_jsx(PartialLinkInLI, { partialName: partialName }, partialName))) }));
|
|
13
|
-
}
|