@hubspot/cms-dev-server 0.7.7 → 0.7.9

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.
Binary file
@@ -532,6 +532,9 @@ function renderFieldsToJson(fields) {
532
532
  outputCallback
533
533
  })
534
534
  );
535
+ if (!moduleJson) {
536
+ throw new Error("couldn't render module fields definition to fields.json");
537
+ }
535
538
  return moduleJson;
536
539
  }
537
540
  export {
package/dist/run.js CHANGED
@@ -507,6 +507,9 @@ function renderFieldsToJson(fields) {
507
507
  outputCallback
508
508
  })
509
509
  );
510
+ if (!moduleJson) {
511
+ throw new Error("couldn't render module fields definition to fields.json");
512
+ }
510
513
  return moduleJson;
511
514
  }
512
515
 
@@ -1435,6 +1438,17 @@ var getEntryPointBasePathFromProxyRequest = (request2) => {
1435
1438
  }
1436
1439
  return requestPath.replace(pathParamDict.dynamic_slug, "");
1437
1440
  };
1441
+ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent) {
1442
+ if (!process.env.DEFAULT_MODULE_PATH_REWRITE) {
1443
+ return placeholderPath;
1444
+ }
1445
+ const expectedDefaultModulePath = `@default-modules/${projectName}/${process.env.DEFAULT_MODULE_PATH_REWRITE.split(":")[0]}`;
1446
+ const mappedPlaceholderPath = `@projects/${projectName}/${projectComponent}/components/modules/${process.env.DEFAULT_MODULE_PATH_REWRITE.split(":")[1]}`;
1447
+ if (placeholderPath === expectedDefaultModulePath) {
1448
+ return mappedPlaceholderPath;
1449
+ }
1450
+ return placeholderPath;
1451
+ }
1438
1452
  var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, __jsRenderingGates) => {
1439
1453
  const url3 = new URL(urlToProxy);
1440
1454
  console.log(`Proxying request to ${url3.href}`, {
@@ -1450,10 +1464,11 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1450
1464
  proxiedQueryParams[queryKey] = values[0];
1451
1465
  }
1452
1466
  }
1467
+ const localProxyProject = process.env.DEFAULT_MODULE_PATH_REWRITE ? `@default-modules/${projectName}` : `@projects/${projectName}`;
1453
1468
  proxiedQueryParams = {
1454
1469
  ...proxiedQueryParams,
1455
1470
  hs_preview: `${previewKey}-${contentId}`,
1456
- hsLocalProxyProject: `@projects/${projectName}`,
1471
+ hsLocalProxyProject: localProxyProject,
1457
1472
  localProxySchemaVersion: 1
1458
1473
  };
1459
1474
  const result = hsGet3(accountId, {
@@ -1472,7 +1487,11 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1472
1487
  });
1473
1488
  };
1474
1489
  var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder, webRoot2, viteServer, pageUrl, basePath, environmentConfig, hsProjectJsonProjectName, webRootProjectComponent) => {
1475
- const { path: placeholderPath } = localRenderPlaceholder;
1490
+ const placeholderPath = resolvePlaceholderPath(
1491
+ localRenderPlaceholder.path,
1492
+ hsProjectJsonProjectName,
1493
+ webRootProjectComponent
1494
+ );
1476
1495
  const localRenderPlaceholderProps = localRenderPlaceholder.json.props;
1477
1496
  const [
1478
1497
  __projectIdentifier,
@@ -1,6 +1,5 @@
1
1
  // src/storybook/moduleStory.tsx
2
- import React, { useEffect } from "react";
3
- import { renderToStaticMarkup as renderToStaticMarkup2 } from "react-dom/server";
2
+ import { useEffect } from "react";
4
3
 
5
4
  // ../cms-js-internal/dist/index.js
6
5
  import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
@@ -36,6 +35,9 @@ function renderFieldsToJson(fields) {
36
35
  outputCallback
37
36
  })
38
37
  );
38
+ if (!moduleJson) {
39
+ throw new Error("couldn't render module fields definition to fields.json");
40
+ }
39
41
  return moduleJson;
40
42
  }
41
43
 
@@ -125,21 +127,6 @@ function getNestedFieldObjectForArgs(_args) {
125
127
 
126
128
  // src/storybook/moduleStory.tsx
127
129
  import { jsx } from "react/jsx-runtime";
128
- function moduleFieldsToJson(fields) {
129
- let moduleJson;
130
- const outputCallback = (callbackJson) => {
131
- moduleJson = callbackJson;
132
- };
133
- renderToStaticMarkup2(
134
- React.cloneElement(fields, {
135
- outputCallback
136
- })
137
- );
138
- if (!moduleJson) {
139
- throw new Error("couldn't render module fields definition to fields.json");
140
- }
141
- return moduleJson;
142
- }
143
130
  function moduleArgs(argTypes) {
144
131
  const args = {};
145
132
  for (const argKey in argTypes) {
@@ -163,18 +150,18 @@ function moduleStory(ModuleComponent, fields, storyArgs) {
163
150
  args
164
151
  };
165
152
  }
166
- function moduleStoryWithIsland(fields, moduleName, storyArgs) {
153
+ function moduleStoryWithIsland(moduleName, fields, storyArgs) {
167
154
  if (typeof moduleName !== "string") {
168
155
  throw new Error(
169
- "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"
156
+ "moduleStoryWithIsland takes a `moduleName` that matches the file or folder name for the module as a string for the first argument, and the module's Fields JSX as the second parameter"
170
157
  );
171
158
  }
172
- if (!moduleName) {
159
+ if (!fields) {
173
160
  throw new Error(
174
- "moduleStoryWithIsland requires a second moduleName parameter that matches the file or folder name for the module"
161
+ "moduleStoryWithIsland requires a second parameter of the module's fields configuration"
175
162
  );
176
163
  }
177
- const moduleJson = moduleFieldsToJson(fields);
164
+ const moduleJson = renderFieldsToJson(fields);
178
165
  const argTypes = getFieldsArgTypes(moduleJson);
179
166
  const args = { ...moduleArgs(argTypes), ...storyArgs };
180
167
  return {
@@ -199,7 +186,7 @@ function moduleStoryWithIsland(fields, moduleName, storyArgs) {
199
186
  iframeElement.setAttribute("id", "hs-module-iframe");
200
187
  iframeElement.setAttribute(
201
188
  "style",
202
- `border: none;width: 100%;height: 100%;overflow: auto;`
189
+ `border: none;width: 100%;height: 100%;overflow: auto;position: absolute;left: 0;top: 0;`
203
190
  );
204
191
  document.querySelector("#storybook-root").appendChild(iframeElement);
205
192
  return () => {
@@ -211,7 +198,6 @@ function moduleStoryWithIsland(fields, moduleName, storyArgs) {
211
198
  };
212
199
  }
213
200
  export {
214
- moduleFieldsToJson,
215
201
  moduleStory,
216
202
  moduleStoryWithIsland
217
203
  };
@@ -332,6 +332,9 @@ function renderFieldsToJson(fields) {
332
332
  outputCallback
333
333
  })
334
334
  );
335
+ if (!moduleJson) {
336
+ throw new Error("couldn't render module fields definition to fields.json");
337
+ }
335
338
  return moduleJson;
336
339
  }
337
340
  var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, serializeIslandDataToJSON, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, jsx2, promiseForNewWritableStream, renderStreamToPromise, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, GATES, ENABLED_FEATURES_GATE_MAP, BUILD_INFO_PATH, findAllComponentsIn;
@@ -628,7 +631,8 @@ var main_default = {
628
631
  ]
629
632
  },
630
633
  optimizeDeps: {
631
- include: ["react", "react-dom", "react-dom/client"]
634
+ include: ["react", "react-dom", "react-dom/client"],
635
+ exclude: ["fsevents"]
632
636
  },
633
637
  css: {
634
638
  postcss: webRoot
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
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.7.7",
28
+ "@hubspot/cms-components": "^0.7.9",
29
29
  "@storybook/addon-actions": "7.0.7",
30
30
  "@storybook/addon-essentials": "7.0.7",
31
31
  "@storybook/addon-interactions": "7.0.7",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "0a5d996b75302f9c7c600a937c42626728b98d48"
100
+ "gitHead": "fe80fcc6421a19c814bfcb1652d02d7c16c625b6"
101
101
  }
@@ -0,0 +1,2 @@
1
+ import { Alias } from 'vite';
2
+ export default function generateBpmAliases(webRoot: string): Alias[];
@@ -0,0 +1,3 @@
1
+ import { Plugin } from 'vite';
2
+ declare const noNodeBuiltinsPlugin: () => Plugin;
3
+ export default noNodeBuiltinsPlugin;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { Field } from '@hubspot/cms-components/fields';
3
2
  import { Args, ModuleStory } from './types.js';
4
3
  declare type ModuleProps = {
5
4
  fieldValues: any;
@@ -7,9 +6,6 @@ declare type ModuleProps = {
7
6
  hublParameters?: any;
8
7
  serverSideProps?: any;
9
8
  };
10
- export declare function moduleFieldsToJson(fields: JSX.Element): Field[];
11
9
  export declare function moduleStory(ModuleComponent: (moduleProps: ModuleProps) => React.ReactElement<any, any> | null, fields: JSX.Element, storyArgs: Args): ModuleStory;
12
- export declare function moduleStoryWithIsland(fields: JSX.Element, // was module component
13
- moduleName: string, // was fields jSX
14
- storyArgs: Args): ModuleStory;
10
+ export declare function moduleStoryWithIsland(moduleName: string, fields: JSX.Element, storyArgs: Args): ModuleStory;
15
11
  export {};