@hubspot/cms-dev-server 1.0.35 → 1.0.36
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/generateJsonFromJsx.js +5 -3
- package/dist/index.js +31 -21
- package/dist/island-runtime.js +55 -4
- package/dist/run.js +31 -21
- package/dist/storybook-main/main.js +53 -11
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ import { normalizePath as normalizePath2 } from "vite";
|
|
|
7
7
|
|
|
8
8
|
// src/createViteDevServer.ts
|
|
9
9
|
import { createServer as createViteServer } from "vite";
|
|
10
|
+
import { createRequire } from "module";
|
|
10
11
|
import { default as react } from "@vitejs/plugin-react";
|
|
11
12
|
|
|
12
13
|
// ../cms-js-internal/dist/types-BxnmA6nH.js
|
|
@@ -606,13 +607,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
606
607
|
include: ["react", "react-dom", "react-dom/client"]
|
|
607
608
|
}
|
|
608
609
|
} : {};
|
|
610
|
+
const require2 = createRequire(import.meta.url);
|
|
609
611
|
const reactAndIslandsPlugins = isProjectWithReact || process.env.VITEST ? [
|
|
610
612
|
react({
|
|
611
613
|
babel: {
|
|
612
614
|
plugins: [
|
|
613
|
-
"babel-plugin-styled-components",
|
|
614
|
-
"styled-jsx/babel",
|
|
615
|
-
"macros"
|
|
615
|
+
require2.resolve("babel-plugin-styled-components"),
|
|
616
|
+
require2.resolve("styled-jsx/babel"),
|
|
617
|
+
require2.resolve("babel-plugin-macros")
|
|
616
618
|
]
|
|
617
619
|
}
|
|
618
620
|
}),
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/createViteDevServer.ts
|
|
2
2
|
import { createServer as createViteServer } from "vite";
|
|
3
|
+
import { createRequire } from "module";
|
|
3
4
|
import { default as react } from "@vitejs/plugin-react";
|
|
4
5
|
|
|
5
6
|
// ../cms-js-internal/dist/types-BxnmA6nH.js
|
|
@@ -1162,13 +1163,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1162
1163
|
include: ["react", "react-dom", "react-dom/client"]
|
|
1163
1164
|
}
|
|
1164
1165
|
} : {};
|
|
1166
|
+
const require2 = createRequire(import.meta.url);
|
|
1165
1167
|
const reactAndIslandsPlugins = isProjectWithReact || process.env.VITEST ? [
|
|
1166
1168
|
react({
|
|
1167
1169
|
babel: {
|
|
1168
1170
|
plugins: [
|
|
1169
|
-
"babel-plugin-styled-components",
|
|
1170
|
-
"styled-jsx/babel",
|
|
1171
|
-
"macros"
|
|
1171
|
+
require2.resolve("babel-plugin-styled-components"),
|
|
1172
|
+
require2.resolve("styled-jsx/babel"),
|
|
1173
|
+
require2.resolve("babel-plugin-macros")
|
|
1172
1174
|
]
|
|
1173
1175
|
}
|
|
1174
1176
|
}),
|
|
@@ -1638,7 +1640,7 @@ function trackUsage(action) {
|
|
|
1638
1640
|
eventName: EVENT_NAME,
|
|
1639
1641
|
action,
|
|
1640
1642
|
nodeVersion: getNodeVersionData(),
|
|
1641
|
-
version: "1.0.
|
|
1643
|
+
version: "1.0.36",
|
|
1642
1644
|
os: getPlatform()
|
|
1643
1645
|
};
|
|
1644
1646
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -4668,6 +4670,7 @@ async function startShadowDevServer(devServerPort, shadowPort, themePath) {
|
|
|
4668
4670
|
import {
|
|
4669
4671
|
createServer as createViteServer2
|
|
4670
4672
|
} from "vite";
|
|
4673
|
+
import { createRequire as createRequire2 } from "module";
|
|
4671
4674
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
4672
4675
|
import { default as mkcert2 } from "vite-plugin-mkcert";
|
|
4673
4676
|
var isProd3 = true;
|
|
@@ -4700,15 +4703,18 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
4700
4703
|
include: ["react", "react-dom", "react-dom/client"]
|
|
4701
4704
|
},
|
|
4702
4705
|
plugins: [
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4706
|
+
(() => {
|
|
4707
|
+
const require2 = createRequire2(import.meta.url);
|
|
4708
|
+
return react2({
|
|
4709
|
+
babel: {
|
|
4710
|
+
plugins: [
|
|
4711
|
+
require2.resolve("babel-plugin-styled-components"),
|
|
4712
|
+
require2.resolve("styled-jsx/babel"),
|
|
4713
|
+
require2.resolve("babel-plugin-macros")
|
|
4714
|
+
]
|
|
4715
|
+
}
|
|
4716
|
+
});
|
|
4717
|
+
})(),
|
|
4712
4718
|
clientIslandEntryPlugin(),
|
|
4713
4719
|
resolveIslandPlugin(),
|
|
4714
4720
|
sslEnabled ? mkcert2() : null
|
|
@@ -5575,14 +5581,18 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
|
|
|
5575
5581
|
const packageRoot = path16.dirname(url2.fileURLToPath(import.meta.url));
|
|
5576
5582
|
const configPath = path16.resolve(packageRoot, "./storybook-main");
|
|
5577
5583
|
sendTrackingRequest("start-storybook");
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5584
|
+
let storybookBin;
|
|
5585
|
+
try {
|
|
5586
|
+
const sbPackagePath = await import.meta.resolve("storybook/package.json");
|
|
5587
|
+
const sbPackageDir = path16.dirname(url2.fileURLToPath(sbPackagePath));
|
|
5588
|
+
const packageJson = JSON.parse(
|
|
5589
|
+
fs7.readFileSync(path16.join(sbPackageDir, "package.json"), "utf-8")
|
|
5590
|
+
);
|
|
5591
|
+
storybookBin = path16.join(
|
|
5592
|
+
sbPackageDir,
|
|
5593
|
+
packageJson.bin.storybook || packageJson.bin
|
|
5594
|
+
);
|
|
5595
|
+
} catch (e) {
|
|
5586
5596
|
console.error(
|
|
5587
5597
|
wrapMessageInColor(
|
|
5588
5598
|
"red",
|
package/dist/island-runtime.js
CHANGED
|
@@ -12,6 +12,60 @@ var onVisible = (islandEl, callback) => {
|
|
|
12
12
|
observer.observe(child);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
var MAX_HOSTNAME_LENGTH = 255;
|
|
16
|
+
var VALID_HOSTNAME_PATTERN = /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
17
|
+
var FORBIDDEN_HOSTNAME_CHARS = /[/?#@:&=+$,[\]<>%\s"'`\\]/;
|
|
18
|
+
var INVALID_SUBSTRINGS = [
|
|
19
|
+
"://",
|
|
20
|
+
"?",
|
|
21
|
+
"#",
|
|
22
|
+
";",
|
|
23
|
+
"\\",
|
|
24
|
+
"..",
|
|
25
|
+
"//",
|
|
26
|
+
// eslint-disable-next-line no-script-url
|
|
27
|
+
"javascript:",
|
|
28
|
+
"data:",
|
|
29
|
+
"vbscript:",
|
|
30
|
+
"<script",
|
|
31
|
+
"base64",
|
|
32
|
+
"alert(",
|
|
33
|
+
"eval(",
|
|
34
|
+
"Function("
|
|
35
|
+
];
|
|
36
|
+
function isValidHostname(hostname) {
|
|
37
|
+
const isLengthOutOfRange = hostname.length < 1 || hostname.length > MAX_HOSTNAME_LENGTH;
|
|
38
|
+
if (!hostname || typeof hostname !== "string" || isLengthOutOfRange || !hostname.includes(".") || FORBIDDEN_HOSTNAME_CHARS.test(hostname) || !VALID_HOSTNAME_PATTERN.test(hostname) || INVALID_SUBSTRINGS.some(
|
|
39
|
+
(sub) => hostname.toLowerCase().includes(sub.toLowerCase())
|
|
40
|
+
) || /^[0-9.]+$/.test(hostname)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return hostname.split(".").every(
|
|
44
|
+
(label) => label.length >= 1 && label.length <= 63 && !label.startsWith("-") && !label.endsWith("-")
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function getSecureOverrideUrl(path) {
|
|
48
|
+
const currentUrl = new URL(window.location.toString());
|
|
49
|
+
const overrideHost = currentUrl.searchParams.get("hsDebugOverridePublicHost");
|
|
50
|
+
try {
|
|
51
|
+
if (!overrideHost) {
|
|
52
|
+
throw new Error("No override host provided");
|
|
53
|
+
}
|
|
54
|
+
if (!isValidHostname(overrideHost)) {
|
|
55
|
+
throw new Error("Invalid hostname format");
|
|
56
|
+
}
|
|
57
|
+
const overriddenUrl = new URL(
|
|
58
|
+
`${currentUrl.protocol}//${overrideHost}${path}`
|
|
59
|
+
);
|
|
60
|
+
if (!["http:", "https:"].includes(overriddenUrl.protocol)) {
|
|
61
|
+
throw new Error("Invalid protocol");
|
|
62
|
+
}
|
|
63
|
+
return overriddenUrl.toString();
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.warn(`Invalid debug override host: ${overrideHost}`, e);
|
|
66
|
+
return `${window.location.origin}${path}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
15
69
|
var rootsToProcess;
|
|
16
70
|
var hydrationQueue = [];
|
|
17
71
|
var hydrationTypesToAccept = /* @__PURE__ */ new Set(["load", "visible"]);
|
|
@@ -137,10 +191,7 @@ function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrap
|
|
|
137
191
|
function getLoadableModuleFor(root) {
|
|
138
192
|
let url = root.url;
|
|
139
193
|
if (root.url.startsWith("/") && !root.url.startsWith("//") && window.location.search.includes("hsDebugOverridePublicHost=")) {
|
|
140
|
-
|
|
141
|
-
url = `${currentUrl.protocol}//${currentUrl.searchParams.get(
|
|
142
|
-
"hsDebugOverridePublicHost"
|
|
143
|
-
)}${root.url}`;
|
|
194
|
+
url = getSecureOverrideUrl(root.url);
|
|
144
195
|
} else if (!root.url.startsWith("https://") && !root.url.startsWith("http://") && !root.url.startsWith("//")) {
|
|
145
196
|
url = `${window.location.origin}${root.url}`;
|
|
146
197
|
}
|
package/dist/run.js
CHANGED
|
@@ -2166,7 +2166,7 @@ function trackUsage(action) {
|
|
|
2166
2166
|
eventName: EVENT_NAME,
|
|
2167
2167
|
action,
|
|
2168
2168
|
nodeVersion: getNodeVersionData(),
|
|
2169
|
-
version: "1.0.
|
|
2169
|
+
version: "1.0.36",
|
|
2170
2170
|
os: getPlatform()
|
|
2171
2171
|
};
|
|
2172
2172
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -4835,6 +4835,7 @@ async function fetchProjectByName(accountId, projectName) {
|
|
|
4835
4835
|
|
|
4836
4836
|
// src/createViteDevServer.ts
|
|
4837
4837
|
import { createServer as createViteServer } from "vite";
|
|
4838
|
+
import { createRequire } from "module";
|
|
4838
4839
|
import { default as react } from "@vitejs/plugin-react";
|
|
4839
4840
|
import { default as mkcert } from "vite-plugin-mkcert";
|
|
4840
4841
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
@@ -5000,13 +5001,14 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
5000
5001
|
include: ["react", "react-dom", "react-dom/client"]
|
|
5001
5002
|
}
|
|
5002
5003
|
} : {};
|
|
5004
|
+
const require2 = createRequire(import.meta.url);
|
|
5003
5005
|
const reactAndIslandsPlugins = isProjectWithReact || process.env.VITEST ? [
|
|
5004
5006
|
react({
|
|
5005
5007
|
babel: {
|
|
5006
5008
|
plugins: [
|
|
5007
|
-
"babel-plugin-styled-components",
|
|
5008
|
-
"styled-jsx/babel",
|
|
5009
|
-
"macros"
|
|
5009
|
+
require2.resolve("babel-plugin-styled-components"),
|
|
5010
|
+
require2.resolve("styled-jsx/babel"),
|
|
5011
|
+
require2.resolve("babel-plugin-macros")
|
|
5010
5012
|
]
|
|
5011
5013
|
}
|
|
5012
5014
|
}),
|
|
@@ -5408,6 +5410,7 @@ async function startShadowDevServer(devServerPort, shadowPort, themePath) {
|
|
|
5408
5410
|
import {
|
|
5409
5411
|
createServer as createViteServer2
|
|
5410
5412
|
} from "vite";
|
|
5413
|
+
import { createRequire as createRequire2 } from "module";
|
|
5411
5414
|
import { default as react2 } from "@vitejs/plugin-react";
|
|
5412
5415
|
import { default as mkcert2 } from "vite-plugin-mkcert";
|
|
5413
5416
|
var isProd3 = true;
|
|
@@ -5440,15 +5443,18 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
5440
5443
|
include: ["react", "react-dom", "react-dom/client"]
|
|
5441
5444
|
},
|
|
5442
5445
|
plugins: [
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5446
|
+
(() => {
|
|
5447
|
+
const require2 = createRequire2(import.meta.url);
|
|
5448
|
+
return react2({
|
|
5449
|
+
babel: {
|
|
5450
|
+
plugins: [
|
|
5451
|
+
require2.resolve("babel-plugin-styled-components"),
|
|
5452
|
+
require2.resolve("styled-jsx/babel"),
|
|
5453
|
+
require2.resolve("babel-plugin-macros")
|
|
5454
|
+
]
|
|
5455
|
+
}
|
|
5456
|
+
});
|
|
5457
|
+
})(),
|
|
5452
5458
|
clientIslandEntryPlugin(),
|
|
5453
5459
|
resolveIslandPlugin(),
|
|
5454
5460
|
sslEnabled ? mkcert2() : null
|
|
@@ -6315,14 +6321,18 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
|
|
|
6315
6321
|
const packageRoot = path17.dirname(url2.fileURLToPath(import.meta.url));
|
|
6316
6322
|
const configPath = path17.resolve(packageRoot, "./storybook-main");
|
|
6317
6323
|
sendTrackingRequest("start-storybook");
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6324
|
+
let storybookBin;
|
|
6325
|
+
try {
|
|
6326
|
+
const sbPackagePath = await import.meta.resolve("storybook/package.json");
|
|
6327
|
+
const sbPackageDir = path17.dirname(url2.fileURLToPath(sbPackagePath));
|
|
6328
|
+
const packageJson = JSON.parse(
|
|
6329
|
+
fs8.readFileSync(path17.join(sbPackageDir, "package.json"), "utf-8")
|
|
6330
|
+
);
|
|
6331
|
+
storybookBin = path17.join(
|
|
6332
|
+
sbPackageDir,
|
|
6333
|
+
packageJson.bin.storybook || packageJson.bin
|
|
6334
|
+
);
|
|
6335
|
+
} catch (e) {
|
|
6326
6336
|
console.error(
|
|
6327
6337
|
wrapMessageInColor(
|
|
6328
6338
|
"red",
|
|
@@ -1341,6 +1341,7 @@ ${indentString}`);
|
|
|
1341
1341
|
// src/storybook-main/main.ts
|
|
1342
1342
|
init_dist();
|
|
1343
1343
|
import path2 from "path";
|
|
1344
|
+
import { createRequire } from "module";
|
|
1344
1345
|
import { mergeConfig } from "vite";
|
|
1345
1346
|
import { withoutVitePlugins } from "@storybook/builder-vite";
|
|
1346
1347
|
import { default as react } from "@vitejs/plugin-react";
|
|
@@ -1375,32 +1376,73 @@ var main_default = {
|
|
|
1375
1376
|
viteFinal: async (config) => {
|
|
1376
1377
|
const { resolveIslandPlugin: resolveIslandPlugin2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
1377
1378
|
const viteConfig = {
|
|
1379
|
+
define: {
|
|
1380
|
+
global: "globalThis",
|
|
1381
|
+
"process.env": "{}",
|
|
1382
|
+
"process.platform": '"browser"',
|
|
1383
|
+
"process.version": '"v18.0.0"',
|
|
1384
|
+
"process.versions": "{}",
|
|
1385
|
+
"process.browser": "true",
|
|
1386
|
+
"process.nextTick": "((fn, ...args) => setTimeout(() => fn(...args), 0))"
|
|
1387
|
+
},
|
|
1378
1388
|
resolve: {
|
|
1379
1389
|
dedupe: [
|
|
1380
1390
|
"react",
|
|
1381
1391
|
"react-dom",
|
|
1382
1392
|
"@hubspot/cms-components",
|
|
1383
1393
|
"@hubspot/cms-dev-server"
|
|
1384
|
-
]
|
|
1394
|
+
],
|
|
1395
|
+
alias: {
|
|
1396
|
+
process: "process/browser",
|
|
1397
|
+
buffer: "buffer"
|
|
1398
|
+
}
|
|
1385
1399
|
},
|
|
1386
1400
|
optimizeDeps: {
|
|
1387
|
-
include: ["react", "react-dom", "react-dom/client"],
|
|
1401
|
+
include: ["react", "react-dom", "react-dom/client", "buffer"],
|
|
1388
1402
|
exclude: ["fsevents"]
|
|
1389
1403
|
},
|
|
1390
1404
|
css: {
|
|
1391
1405
|
postcss: webRoot
|
|
1392
1406
|
},
|
|
1393
1407
|
plugins: [
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
"
|
|
1401
|
-
|
|
1408
|
+
// Provide Node.js globals for browser environment
|
|
1409
|
+
{
|
|
1410
|
+
name: "provide-nodejs-globals",
|
|
1411
|
+
config(__config, { command }) {
|
|
1412
|
+
if (command === "serve") {
|
|
1413
|
+
config.define = config.define || {};
|
|
1414
|
+
config.define.global = "globalThis";
|
|
1415
|
+
config.define.Buffer = "Buffer";
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
transformIndexHtml: {
|
|
1419
|
+
order: "pre",
|
|
1420
|
+
handler(html) {
|
|
1421
|
+
return html.replace(
|
|
1422
|
+
"<head>",
|
|
1423
|
+
`<head>
|
|
1424
|
+
<script type="module">
|
|
1425
|
+
import { Buffer } from 'buffer';
|
|
1426
|
+
window.Buffer = Buffer;
|
|
1427
|
+
globalThis.Buffer = Buffer;
|
|
1428
|
+
</script>`
|
|
1429
|
+
);
|
|
1430
|
+
}
|
|
1402
1431
|
}
|
|
1403
|
-
}
|
|
1432
|
+
},
|
|
1433
|
+
resolveIslandPlugin2(),
|
|
1434
|
+
(() => {
|
|
1435
|
+
const require2 = createRequire(import.meta.url);
|
|
1436
|
+
return react({
|
|
1437
|
+
babel: {
|
|
1438
|
+
plugins: [
|
|
1439
|
+
require2.resolve("babel-plugin-styled-components"),
|
|
1440
|
+
require2.resolve("styled-jsx/babel"),
|
|
1441
|
+
require2.resolve("babel-plugin-macros")
|
|
1442
|
+
]
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
})()
|
|
1404
1446
|
]
|
|
1405
1447
|
};
|
|
1406
1448
|
const configNoReact = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
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.0.
|
|
32
|
+
"@hubspot/cms-components": "^1.0.36",
|
|
33
33
|
"@hubspot/local-dev-lib": "2.0.1",
|
|
34
34
|
"@inquirer/select": "^2.0.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -134,5 +134,5 @@
|
|
|
134
134
|
"publishConfig": {
|
|
135
135
|
"access": "public"
|
|
136
136
|
},
|
|
137
|
-
"gitHead": "
|
|
137
|
+
"gitHead": "a73d9576dca18ecca3b3a192144804ec436ce75c"
|
|
138
138
|
}
|