@hubspot/cms-dev-server 0.11.0 → 0.11.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 CHANGED
@@ -91,7 +91,13 @@ function devSecretsPlugin(secretNames) {
91
91
  const cmsComponents = await server.ssrLoadModule(
92
92
  "@hubspot/cms-components"
93
93
  );
94
- cmsComponents.setSecretsFromEnv(secretNames);
94
+ if (cmsComponents.setSecretsFromEnv) {
95
+ cmsComponents.setSecretsFromEnv(secretNames);
96
+ } else if (secretNames.length > 0) {
97
+ console.warn(
98
+ "Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
99
+ );
100
+ }
95
101
  }
96
102
  }
97
103
  };
@@ -118,9 +118,9 @@ var serializeIslandDataToJSON = (tweakedIslandsArray, indent = 0) => {
118
118
  ${indentString}`)}`;
119
119
  };
120
120
  var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
121
- const indentString = new Array(indent).fill(" ").join("");
122
121
  const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
123
122
  if (sharedStateIDs.length > 0) {
123
+ const indentString = " ".repeat(indent);
124
124
  const stateByID = {};
125
125
  sharedStateIDs.forEach(
126
126
  (id) => stateByID[id] = perServerRequestData.get(id)
@@ -128,12 +128,12 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) =>
128
128
  const stringifiedState = JSON.stringify(stateByID, null, 2);
129
129
  return `
130
130
 
131
- var newState = ${stringifiedState};
132
- if(window.__hsSSInit) {
133
- window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
134
- } else {
135
- window.__hsSSInit = newState;
136
- }`.replace(/\n/gm, `
131
+ var newState = ${stringifiedState};
132
+ if(window.__hsSSInit) {
133
+ window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
134
+ } else {
135
+ window.__hsSSInit = newState;
136
+ }`.replace(/\n/gm, `
137
137
  ${indentString}`);
138
138
  }
139
139
  return "";
@@ -187,7 +187,7 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
187
187
  perServerRequestData,
188
188
  viteDevServer
189
189
  );
190
- return `window.__islands = ${serializeIslandDataToJSON(
190
+ return `${" ".repeat(indent)}window.__islands = ${serializeIslandDataToJSON(
191
191
  islands,
192
192
  indent
193
193
  )}${writeSharedStateToJsGlobal(
@@ -491,10 +491,10 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
491
491
  globals.push(`window.__hsBasePath = '${hsBasePath}';`);
492
492
  }
493
493
  return `
494
- <script type="text/javascript">
495
- ${globals.join("\n ")}
496
- </script>
497
- `;
494
+ <script type="text/javascript">
495
+ ${globals.join("\n ")}
496
+ </script>
497
+ `;
498
498
  }
499
499
  function namespaceModulePropsShape(props) {
500
500
  const {
package/dist/run.js CHANGED
@@ -184,9 +184,9 @@ var serializeIslandDataToJSON = (tweakedIslandsArray, indent = 0) => {
184
184
  ${indentString}`)}`;
185
185
  };
186
186
  var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
187
- const indentString = new Array(indent).fill(" ").join("");
188
187
  const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
189
188
  if (sharedStateIDs.length > 0) {
189
+ const indentString = " ".repeat(indent);
190
190
  const stateByID = {};
191
191
  sharedStateIDs.forEach(
192
192
  (id) => stateByID[id] = perServerRequestData.get(id)
@@ -194,12 +194,12 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) =>
194
194
  const stringifiedState = JSON.stringify(stateByID, null, 2);
195
195
  return `
196
196
 
197
- var newState = ${stringifiedState};
198
- if(window.__hsSSInit) {
199
- window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
200
- } else {
201
- window.__hsSSInit = newState;
202
- }`.replace(/\n/gm, `
197
+ var newState = ${stringifiedState};
198
+ if(window.__hsSSInit) {
199
+ window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
200
+ } else {
201
+ window.__hsSSInit = newState;
202
+ }`.replace(/\n/gm, `
203
203
  ${indentString}`);
204
204
  }
205
205
  return "";
@@ -253,7 +253,7 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
253
253
  perServerRequestData,
254
254
  viteDevServer
255
255
  );
256
- return `window.__islands = ${serializeIslandDataToJSON(
256
+ return `${" ".repeat(indent)}window.__islands = ${serializeIslandDataToJSON(
257
257
  islands,
258
258
  indent
259
259
  )}${writeSharedStateToJsGlobal(
@@ -517,10 +517,10 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
517
517
  globals.push(`window.__hsBasePath = '${hsBasePath}';`);
518
518
  }
519
519
  return `
520
- <script type="text/javascript">
521
- ${globals.join("\n ")}
522
- </script>
523
- `;
520
+ <script type="text/javascript">
521
+ ${globals.join("\n ")}
522
+ </script>
523
+ `;
524
524
  }
525
525
  function namespaceModulePropsShape(props) {
526
526
  const {
@@ -739,7 +739,8 @@ var renderPartial_default = renderPartial;
739
739
  import { promises as fsPromises } from "fs";
740
740
  var { readFile } = fsPromises;
741
741
  var generateIslandSetupScriptBlock = () => {
742
- return `<script type="module">
742
+ return `
743
+ <script type="module">
743
744
  import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
744
745
  initConfigSingletonFromJSON(window.__hsEnvConfig);
745
746
  </script>
@@ -749,7 +750,7 @@ var generateIslandSetupScriptBlock = () => {
749
750
  "island-runtime"
750
751
  )}';
751
752
  setupIslandHydration();
752
- </script>
753
+ </script>
753
754
  `;
754
755
  };
755
756
  var createdPlainHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock) => {
@@ -793,13 +794,13 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, tit
793
794
  htmlTemplate = htmlTemplate.replace(
794
795
  "<!--islandsglobal-->",
795
796
  `<script>
796
- ${createIslandsGlobalJsForClientInDev(
797
+ ${createIslandsGlobalJsForClientInDev(
797
798
  renderContext.islands,
798
799
  renderContext.perServerRequestData,
799
800
  viteServer,
800
- 4
801
+ 6
801
802
  )}
802
- </script>
803
+ </script>
803
804
  `
804
805
  );
805
806
  } else {
@@ -868,7 +869,7 @@ function trackUsage(action) {
868
869
  eventName: EVENT_NAME,
869
870
  action,
870
871
  nodeVersion: getNodeVersionData(),
871
- version: "0.11.0",
872
+ version: "0.11.2",
872
873
  os: getPlatform()
873
874
  };
874
875
  const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2297,7 +2298,13 @@ function devSecretsPlugin(secretNames) {
2297
2298
  const cmsComponents2 = await server.ssrLoadModule(
2298
2299
  "@hubspot/cms-components"
2299
2300
  );
2300
- cmsComponents2.setSecretsFromEnv(secretNames);
2301
+ if (cmsComponents2.setSecretsFromEnv) {
2302
+ cmsComponents2.setSecretsFromEnv(secretNames);
2303
+ } else if (secretNames.length > 0) {
2304
+ console.warn(
2305
+ "Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
2306
+ );
2307
+ }
2301
2308
  }
2302
2309
  }
2303
2310
  };
@@ -285,10 +285,10 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
285
285
  globals.push(`window.__hsBasePath = '${hsBasePath}';`);
286
286
  }
287
287
  return `
288
- <script type="text/javascript">
289
- ${globals.join("\n ")}
290
- </script>
291
- `;
288
+ <script type="text/javascript">
289
+ ${globals.join("\n ")}
290
+ </script>
291
+ `;
292
292
  }
293
293
  function namespaceModulePropsShape(props) {
294
294
  const {
@@ -459,9 +459,9 @@ var init_dist = __esm({
459
459
  ${indentString}`)}`;
460
460
  };
461
461
  writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
462
- const indentString = new Array(indent).fill(" ").join("");
463
462
  const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
464
463
  if (sharedStateIDs.length > 0) {
464
+ const indentString = " ".repeat(indent);
465
465
  const stateByID = {};
466
466
  sharedStateIDs.forEach(
467
467
  (id) => stateByID[id] = perServerRequestData.get(id)
@@ -469,12 +469,12 @@ ${indentString}`)}`;
469
469
  const stringifiedState = JSON.stringify(stateByID, null, 2);
470
470
  return `
471
471
 
472
- var newState = ${stringifiedState};
473
- if(window.__hsSSInit) {
474
- window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
475
- } else {
476
- window.__hsSSInit = newState;
477
- }`.replace(/\n/gm, `
472
+ var newState = ${stringifiedState};
473
+ if(window.__hsSSInit) {
474
+ window.__hsSSInit = Object.assign(window.__hsSSInit, newState);
475
+ } else {
476
+ window.__hsSSInit = newState;
477
+ }`.replace(/\n/gm, `
478
478
  ${indentString}`);
479
479
  }
480
480
  return "";
@@ -485,7 +485,7 @@ ${indentString}`);
485
485
  perServerRequestData,
486
486
  viteDevServer
487
487
  );
488
- return `window.__islands = ${serializeIslandDataToJSON(
488
+ return `${" ".repeat(indent)}window.__islands = ${serializeIslandDataToJSON(
489
489
  islands,
490
490
  indent
491
491
  )}${writeSharedStateToJsGlobal(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -20,12 +20,12 @@
20
20
  "runBuild": "node dist/run.js",
21
21
  "start": "ts-node-esm --transpileOnly runWhenDeveloping.ts",
22
22
  "start-inspect": "node --loader ts-node/esm --inspect runWhenDeveloping.ts",
23
- "test": "NODE_ENV=test vitest run",
24
- "test:watch": "NODE_ENV=test vitest watch"
23
+ "test": "PORT=30042 NODE_ENV=test vitest run",
24
+ "test:watch": "PORT=30042 NODE_ENV=test vitest watch"
25
25
  },
26
26
  "dependencies": {
27
27
  "@hubspot/cli-lib": "^3.0.12",
28
- "@hubspot/cms-components": "^0.11.0",
28
+ "@hubspot/cms-components": "^0.11.2",
29
29
  "@originjs/vite-plugin-commonjs": "^1.0.3",
30
30
  "@storybook/addon-actions": "7.0.7",
31
31
  "@storybook/addon-essentials": "7.0.7",
@@ -101,5 +101,5 @@
101
101
  "publishConfig": {
102
102
  "access": "public"
103
103
  },
104
- "gitHead": "58a898a8a65a52b85a56d562289e5ee38becddfb"
104
+ "gitHead": "5fda95284c0941e0beff0ec91c048d270fc41eda"
105
105
  }
Binary file
@@ -1,2 +0,0 @@
1
- import { Alias } from 'vite';
2
- export default function generateBpmAliases(webRoot: string): Alias[];
@@ -1,3 +0,0 @@
1
- import { Plugin } from 'vite';
2
- declare const noNodeBuiltinsPlugin: () => Plugin;
3
- export default noNodeBuiltinsPlugin;
@@ -1,2 +0,0 @@
1
- import { Plugin } from 'vite';
2
- export default function resolveSharedDeps(): Plugin | null;