@hubspot/cms-dev-server 0.5.0 → 0.6.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.
- package/dist/index.js +2 -1
- package/dist/internalSsr.js +8 -7
- package/dist/run.js +25 -22
- package/dist/storybook/main.js +8 -7
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function resolveIslandPlugin(gates) {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
59
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {\n ClientRenderContextProvider,\n buildIslandIdentifierPrefix,\n} from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
60
60
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
61
61
|
function clientIslandEntryPlugin() {
|
|
62
62
|
return {
|
|
@@ -120,6 +120,7 @@ async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [
|
|
|
120
120
|
noExternal: "@hubspot/cms-components"
|
|
121
121
|
},
|
|
122
122
|
resolve: {
|
|
123
|
+
conditions: ["server"],
|
|
123
124
|
dedupe: ["react", "react-dom", "@hubspot/cms-components"]
|
|
124
125
|
},
|
|
125
126
|
optimizeDeps: {
|
package/dist/internalSsr.js
CHANGED
|
@@ -157,7 +157,8 @@ var GATES = [
|
|
|
157
157
|
"CMS:JSRenderer:SharedDeps",
|
|
158
158
|
"CMS:JSRenderer:GetServerSideProps",
|
|
159
159
|
"CMS:JSRenderer:LocalProxySchemaVersion1",
|
|
160
|
-
"CMS:JSRenderer:GraphQLQueryBuild"
|
|
160
|
+
"CMS:JSRenderer:GraphQLQueryBuild",
|
|
161
|
+
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
161
162
|
];
|
|
162
163
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
163
164
|
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
@@ -221,7 +222,7 @@ function resolveIslandPlugin(gates) {
|
|
|
221
222
|
}
|
|
222
223
|
};
|
|
223
224
|
}
|
|
224
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
225
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {\n ClientRenderContextProvider,\n buildIslandIdentifierPrefix,\n} from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
225
226
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
226
227
|
function clientIslandEntryPlugin() {
|
|
227
228
|
return {
|
|
@@ -273,21 +274,21 @@ var promiseForNewWritableStream = () => {
|
|
|
273
274
|
});
|
|
274
275
|
return { streamDonePromise, writableStream };
|
|
275
276
|
};
|
|
276
|
-
var renderStreamToPromise = async (reactElements,
|
|
277
|
+
var renderStreamToPromise = async (reactElements, options) => {
|
|
277
278
|
const { streamDonePromise, writableStream } = promiseForNewWritableStream();
|
|
278
279
|
const {
|
|
279
280
|
pipe
|
|
280
281
|
/* abort */
|
|
281
282
|
} = renderToPipeableStream(reactElements, {
|
|
282
|
-
...
|
|
283
|
+
...options || {},
|
|
283
284
|
onShellReady() {
|
|
284
285
|
},
|
|
285
286
|
onAllReady() {
|
|
286
287
|
pipe(writableStream);
|
|
288
|
+
if (options == null ? void 0 : options.onAllReady) {
|
|
289
|
+
options.onAllReady();
|
|
290
|
+
}
|
|
287
291
|
}
|
|
288
|
-
// We will log the error sent to the writable, any need to do something in these callbacks?
|
|
289
|
-
// onShellError(error) {},
|
|
290
|
-
// onError(error) {},
|
|
291
292
|
});
|
|
292
293
|
return streamDonePromise;
|
|
293
294
|
};
|
package/dist/run.js
CHANGED
|
@@ -196,7 +196,7 @@ function resolveIslandPlugin(gates) {
|
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
199
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {\n ClientRenderContextProvider,\n buildIslandIdentifierPrefix,\n} from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
200
200
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
201
201
|
function clientIslandEntryPlugin() {
|
|
202
202
|
return {
|
|
@@ -248,21 +248,21 @@ var promiseForNewWritableStream = () => {
|
|
|
248
248
|
});
|
|
249
249
|
return { streamDonePromise, writableStream };
|
|
250
250
|
};
|
|
251
|
-
var renderStreamToPromise = async (reactElements,
|
|
251
|
+
var renderStreamToPromise = async (reactElements, options) => {
|
|
252
252
|
const { streamDonePromise, writableStream } = promiseForNewWritableStream();
|
|
253
253
|
const {
|
|
254
254
|
pipe
|
|
255
255
|
/* abort */
|
|
256
256
|
} = renderToPipeableStream(reactElements, {
|
|
257
|
-
...
|
|
257
|
+
...options || {},
|
|
258
258
|
onShellReady() {
|
|
259
259
|
},
|
|
260
260
|
onAllReady() {
|
|
261
261
|
pipe(writableStream);
|
|
262
|
+
if (options == null ? void 0 : options.onAllReady) {
|
|
263
|
+
options.onAllReady();
|
|
264
|
+
}
|
|
262
265
|
}
|
|
263
|
-
// We will log the error sent to the writable, any need to do something in these callbacks?
|
|
264
|
-
// onShellError(error) {},
|
|
265
|
-
// onError(error) {},
|
|
266
266
|
});
|
|
267
267
|
return streamDonePromise;
|
|
268
268
|
};
|
|
@@ -709,7 +709,7 @@ var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerReque
|
|
|
709
709
|
};
|
|
710
710
|
|
|
711
711
|
// src/routes/partial.ts
|
|
712
|
-
import { buildStaticEnvConfig } from "@hubspot/cms-components
|
|
712
|
+
import { buildStaticEnvConfig } from "@hubspot/cms-components";
|
|
713
713
|
var partialRouteHandler = async (request2, response) => {
|
|
714
714
|
const {
|
|
715
715
|
authedPortalId,
|
|
@@ -856,7 +856,7 @@ var linksToAllModuleRouteHandler = async (request2, response) => {
|
|
|
856
856
|
var linksToAllModulesRouteHandler_default = linksToAllModuleRouteHandler;
|
|
857
857
|
|
|
858
858
|
// src/routes/module.ts
|
|
859
|
-
import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components
|
|
859
|
+
import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components";
|
|
860
860
|
import path4 from "path";
|
|
861
861
|
import { normalizePath as normalizePath3 } from "vite";
|
|
862
862
|
|
|
@@ -1301,9 +1301,7 @@ ${error.error.message}`);
|
|
|
1301
1301
|
|
|
1302
1302
|
// src/proxyPage/proxyPage.ts
|
|
1303
1303
|
import {
|
|
1304
|
-
buildStaticEnvConfig as buildStaticEnvConfig3
|
|
1305
|
-
} from "@hubspot/cms-components/config";
|
|
1306
|
-
import {
|
|
1304
|
+
buildStaticEnvConfig as buildStaticEnvConfig3,
|
|
1307
1305
|
mergeServerRequestData_internal
|
|
1308
1306
|
} from "@hubspot/cms-components";
|
|
1309
1307
|
var getEntryPointBasePathFromProxyRequest = (request2) => {
|
|
@@ -1967,6 +1965,7 @@ async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy =
|
|
|
1967
1965
|
noExternal: "@hubspot/cms-components"
|
|
1968
1966
|
},
|
|
1969
1967
|
resolve: {
|
|
1968
|
+
conditions: ["server"],
|
|
1970
1969
|
dedupe: ["react", "react-dom", "@hubspot/cms-components"]
|
|
1971
1970
|
},
|
|
1972
1971
|
optimizeDeps: {
|
|
@@ -2128,6 +2127,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2128
2127
|
let authedPortalId = null;
|
|
2129
2128
|
let authedEnv = null;
|
|
2130
2129
|
let jsRenderingGates = [];
|
|
2130
|
+
let personalAccessKey = null;
|
|
2131
2131
|
if (hubspotCliConfigPathOption2 && hubspotCliAccountNameOption2) {
|
|
2132
2132
|
console.log(
|
|
2133
2133
|
`Loading HS auth (account = ${hubspotCliAccountNameOption2}) configuration at: ${hubspotCliConfigPathOption2}`
|
|
@@ -2145,12 +2145,26 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2145
2145
|
if (validateConfig()) {
|
|
2146
2146
|
authedPortalId = getAccountId3(hubspotCliAccountNameOption2);
|
|
2147
2147
|
authedEnv = getEnv2(hubspotCliAccountNameOption2);
|
|
2148
|
+
personalAccessKey = getAccountConfig(authedPortalId) && getAccountConfig(authedPortalId).personalAccessKey;
|
|
2148
2149
|
if (!authedPortalId && hubspotCliAccountNameOption2) {
|
|
2149
2150
|
console.error(
|
|
2150
2151
|
`Couldn't find ${hubspotCliAccountNameOption2} in your hubspot.config.yaml`
|
|
2151
2152
|
);
|
|
2152
2153
|
process.exit(1);
|
|
2153
2154
|
}
|
|
2155
|
+
if (personalAccessKey) {
|
|
2156
|
+
try {
|
|
2157
|
+
jsRenderingGates = await getJsRenderingGates(
|
|
2158
|
+
authedPortalId,
|
|
2159
|
+
authedEnv,
|
|
2160
|
+
personalAccessKey
|
|
2161
|
+
);
|
|
2162
|
+
} catch (e) {
|
|
2163
|
+
console.warn(
|
|
2164
|
+
`Unable to get gating information. gated features will not be availalbe in the local dev server`
|
|
2165
|
+
);
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2154
2168
|
} else {
|
|
2155
2169
|
console.warn(
|
|
2156
2170
|
`Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
|
|
@@ -2159,17 +2173,6 @@ If needed you can refer to another config file with --config.
|
|
|
2159
2173
|
Local proxy functionality will not work without setting up authentication.`
|
|
2160
2174
|
);
|
|
2161
2175
|
}
|
|
2162
|
-
try {
|
|
2163
|
-
const { personalAccessKey } = getAccountConfig(authedPortalId);
|
|
2164
|
-
jsRenderingGates = await getJsRenderingGates(
|
|
2165
|
-
authedPortalId,
|
|
2166
|
-
authedEnv,
|
|
2167
|
-
personalAccessKey
|
|
2168
|
-
);
|
|
2169
|
-
} catch (e) {
|
|
2170
|
-
console.error(e);
|
|
2171
|
-
console.warn("Unable to fetch gating information");
|
|
2172
|
-
}
|
|
2173
2176
|
let domainsToProxy = [];
|
|
2174
2177
|
if (sslEnabledOption2 && authedPortalId) {
|
|
2175
2178
|
try {
|
package/dist/storybook/main.js
CHANGED
|
@@ -409,7 +409,8 @@ ${indentString}`);
|
|
|
409
409
|
"CMS:JSRenderer:SharedDeps",
|
|
410
410
|
"CMS:JSRenderer:GetServerSideProps",
|
|
411
411
|
"CMS:JSRenderer:LocalProxySchemaVersion1",
|
|
412
|
-
"CMS:JSRenderer:GraphQLQueryBuild"
|
|
412
|
+
"CMS:JSRenderer:GraphQLQueryBuild",
|
|
413
|
+
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
413
414
|
];
|
|
414
415
|
ENABLED_FEATURES_GATE_MAP = {
|
|
415
416
|
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
@@ -418,7 +419,7 @@ ${indentString}`);
|
|
|
418
419
|
"cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild"
|
|
419
420
|
};
|
|
420
421
|
BUILD_INFO_PATH = "/build-info.json";
|
|
421
|
-
clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
422
|
+
clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {\n ClientRenderContextProvider,\n buildIslandIdentifierPrefix,\n} from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
422
423
|
virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
423
424
|
jsx2 = jsxRuntime.jsx;
|
|
424
425
|
promiseForNewWritableStream = () => {
|
|
@@ -439,21 +440,21 @@ ${indentString}`);
|
|
|
439
440
|
});
|
|
440
441
|
return { streamDonePromise, writableStream };
|
|
441
442
|
};
|
|
442
|
-
renderStreamToPromise = async (reactElements,
|
|
443
|
+
renderStreamToPromise = async (reactElements, options) => {
|
|
443
444
|
const { streamDonePromise, writableStream } = promiseForNewWritableStream();
|
|
444
445
|
const {
|
|
445
446
|
pipe
|
|
446
447
|
/* abort */
|
|
447
448
|
} = renderToPipeableStream(reactElements, {
|
|
448
|
-
...
|
|
449
|
+
...options || {},
|
|
449
450
|
onShellReady() {
|
|
450
451
|
},
|
|
451
452
|
onAllReady() {
|
|
452
453
|
pipe(writableStream);
|
|
454
|
+
if (options == null ? void 0 : options.onAllReady) {
|
|
455
|
+
options.onAllReady();
|
|
456
|
+
}
|
|
453
457
|
}
|
|
454
|
-
// We will log the error sent to the writable, any need to do something in these callbacks?
|
|
455
|
-
// onShellError(error) {},
|
|
456
|
-
// onError(error) {},
|
|
457
458
|
});
|
|
458
459
|
return streamDonePromise;
|
|
459
460
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@hubspot/cli-lib": "^3.0.12",
|
|
27
|
-
"@hubspot/cms-components": "^0.
|
|
27
|
+
"@hubspot/cms-components": "^0.6.0",
|
|
28
28
|
"@storybook/addon-actions": "^7.0.0-beta.19",
|
|
29
29
|
"@storybook/addon-essentials": "^7.0.0-beta.19",
|
|
30
30
|
"@storybook/addon-interactions": "^7.0.0-beta.19",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-dom": "^18.1.0",
|
|
44
44
|
"request": "^2.88.2",
|
|
45
45
|
"typescript": "~4.7.0",
|
|
46
|
-
"vite": "
|
|
46
|
+
"vite": "4.2.2",
|
|
47
47
|
"vite-plugin-inspect": "^0.4.3",
|
|
48
48
|
"vite-plugin-mkcert": "^1.10.1"
|
|
49
49
|
},
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"node-fetch": "^3.3.0",
|
|
58
58
|
"nodemon": "^2.0.15",
|
|
59
59
|
"ts-node": "^10.7.0",
|
|
60
|
-
"vitest": "0.
|
|
60
|
+
"vitest": "0.30.1"
|
|
61
61
|
},
|
|
62
62
|
"main": "./dist/index.js",
|
|
63
63
|
"exports": {
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"publishConfig": {
|
|
96
96
|
"access": "public"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "37158ed08c4679713bd4f651505d463a4ae2e70e"
|
|
99
99
|
}
|