@hubspot/cms-dev-server 0.14.0 → 0.14.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.
@@ -53,6 +53,7 @@ __export(dist_exports, {
53
53
  ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
54
54
  virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
55
55
  });
56
+ import { hasProperty, setProperty, getProperty } from "dot-prop";
56
57
  import path from "path";
57
58
  import * as jsxRuntime from "react/jsx-runtime";
58
59
  import stream from "stream";
@@ -100,6 +101,25 @@ function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent =
100
101
  ${indentString}`
101
102
  );
102
103
  }
104
+ function filterOutUnreadSupplementalFieldValues(supplementalFieldValues, supplementalFieldValuesRead) {
105
+ if (!supplementalFieldValues) {
106
+ return supplementalFieldValues;
107
+ }
108
+ if (!supplementalFieldValuesRead) {
109
+ return supplementalFieldValues;
110
+ }
111
+ const result = {};
112
+ Array.from(supplementalFieldValuesRead).forEach((fieldPath) => {
113
+ if (hasProperty(supplementalFieldValues, fieldPath)) {
114
+ setProperty(
115
+ result,
116
+ fieldPath,
117
+ getProperty(supplementalFieldValues, fieldPath)
118
+ );
119
+ }
120
+ });
121
+ return result;
122
+ }
103
123
  function getIslandUrls(roots, viteDevServer) {
104
124
  return roots.map((island) => {
105
125
  const islandModule = viteDevServer.moduleGraph.getModuleById(
@@ -210,21 +230,24 @@ function clientIslandEntryPlugin() {
210
230
  }
211
231
  };
212
232
  }
213
- async function renderComponentOnServer(Component, props, pageUrl, environmentConfig, entryPointBasePath, renderOptions) {
233
+ async function renderComponentOnServer(Component, props, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions) {
214
234
  const componentDebugName = Component.displayName || Component.name;
215
235
  return renderOnServer(
216
236
  /* @__PURE__ */ jsx2(Component, { ...props }),
217
237
  pageUrl,
218
238
  environmentConfig,
219
239
  entryPointBasePath,
240
+ contextOptions,
220
241
  componentDebugName,
221
242
  renderOptions
222
243
  );
223
244
  }
224
- async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, debugName, renderOptions) {
245
+ async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
246
+ const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
225
247
  const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
226
248
  environmentConfig,
227
- entryPointBasePath
249
+ entryPointBasePath,
250
+ supplementalFieldValues
228
251
  }) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
229
252
  let html = await renderStreamToPromise(
230
253
  /* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
@@ -473,7 +496,7 @@ var init_dist = __esm({
473
496
  ">": "\\u003E",
474
497
  "/": "\\u002F"
475
498
  };
476
- serializeIslandDataForInlineScript = (tweakedIslandsArray, baseIndent = 0, prettyPrint) => {
499
+ serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
477
500
  const islandsArrayToSerialize = tweakedIslandsArray.map(
478
501
  ({
479
502
  id,
@@ -485,6 +508,7 @@ var init_dist = __esm({
485
508
  priority,
486
509
  url,
487
510
  sharedStateID,
511
+ supplementalFieldValues,
488
512
  wrapperModuleId,
489
513
  wrapperUrl
490
514
  }) => {
@@ -507,6 +531,13 @@ var init_dist = __esm({
507
531
  if (wrapperUrl) {
508
532
  output.wrapperUrl = wrapperUrl;
509
533
  }
534
+ const filteredSupplementalFieldValues = filterOutUnreadSupplementalFieldValues(
535
+ supplementalFieldValues,
536
+ perServerRequestData.get("supplementalFieldValuesRead")
537
+ );
538
+ if (filteredSupplementalFieldValues) {
539
+ output.supplementalFieldValues = filteredSupplementalFieldValues;
540
+ }
510
541
  return output;
511
542
  }
512
543
  );
@@ -550,6 +581,7 @@ ${indentString}`);
550
581
  indent
551
582
  )}window.__islands = ${serializeIslandDataForInlineScript(
552
583
  islands,
584
+ perServerRequestData,
553
585
  indent,
554
586
  prettyPrint
555
587
  )}${writeSharedStateToJsGlobal(
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=16.x"
8
8
  },
9
9
  "scripts": {
10
- "build": "tsc -noEmit && yarn run copy-html && yarn build-types && node scripts/build.mjs",
10
+ "build": "tsc -noEmit && yarn run copy-html && yarn build-types && node scripts/build.mjs; npm run publint",
11
11
  "build:watch": "nodemon --exec 'yarn build'",
12
12
  "copy-html": "copyfiles -u 1 'src/html/**' 'dist'",
13
13
  "build-types": "tsc --project tsconfig.types.json",
@@ -21,11 +21,12 @@
21
21
  "start": "ts-node-esm --transpileOnly runWhenDeveloping.ts",
22
22
  "start-inspect": "node --loader ts-node/esm --inspect runWhenDeveloping.ts",
23
23
  "test": "PORT=30042 NODE_ENV=test vitest run",
24
- "test:watch": "PORT=30042 NODE_ENV=test vitest watch"
24
+ "test:watch": "PORT=30042 NODE_ENV=test vitest watch",
25
+ "publint": "publint --level warning --prod"
25
26
  },
26
27
  "dependencies": {
27
28
  "@hubspot/cli-lib": "^3.0.12",
28
- "@hubspot/cms-components": "^0.14.0",
29
+ "@hubspot/cms-components": "^0.14.1",
29
30
  "@originjs/vite-plugin-commonjs": "^1.0.3",
30
31
  "@storybook/addon-actions": "7.0.7",
31
32
  "@storybook/addon-essentials": "7.0.7",
@@ -62,12 +63,16 @@
62
63
  "copyfiles": "^2.4.1",
63
64
  "esbuild": "^0.16.17",
64
65
  "nodemon": "^2.0.15",
66
+ "publint": "^0.2.7",
65
67
  "ts-node": "^10.7.0",
66
68
  "vitest": "0.30.1"
67
69
  },
68
70
  "main": "./dist/index.js",
69
71
  "exports": {
70
- ".": "./dist/index.js",
72
+ ".": {
73
+ "types": "./types/index.d.ts",
74
+ "default": "./dist/index.js"
75
+ },
71
76
  "./storybook": {
72
77
  "types": "./types/storybook/index.d.ts",
73
78
  "default": "./dist/storybook/index.js"
@@ -101,5 +106,5 @@
101
106
  "publishConfig": {
102
107
  "access": "public"
103
108
  },
104
- "gitHead": "b2ea8a21fc6ed990dd17737d9920abc497bfc65e"
109
+ "gitHead": "ce75267044864a6d877ee25ca4cc76c4e041708b"
105
110
  }
@@ -0,0 +1,2 @@
1
+ import { setupIslandHydration } from '@hubspot/cms-js-internal/island-runtime';
2
+ export { setupIslandHydration };