@sitecore-jss/sitecore-jss-nextjs 21.7.0-canary.17 → 21.7.0-canary.19

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.
@@ -26,7 +26,7 @@ class Context {
26
26
  * @returns initialized SDK
27
27
  */
28
28
  this.getSDK = (name) => {
29
- return this.sdkPromises[name];
29
+ return this.sdkPromises[name] || Promise.reject(`Unknown SDK '${String(name)}'`);
30
30
  };
31
31
  this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
32
32
  this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getJssEditingSecret = exports.handleEditorFastRefresh = exports.getPublicUrl = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
4
  const utils_1 = require("@sitecore-jss/sitecore-jss/utils");
9
5
  /**
10
6
  * Get the publicUrl.
@@ -13,27 +9,19 @@ const utils_1 = require("@sitecore-jss/sitecore-jss/utils");
13
9
  * VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
14
10
  * preview deployment has unique url, we don't know exact url.
15
11
  * Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
12
+ * In production non-editing environments it is desirable to use relative urls, so in that case set PUBLIC_URL = ''
16
13
  */
17
14
  const getPublicUrl = () => {
18
- if (process.env.NETLIFY && process.env.DEPLOY_URL)
19
- return process.env.DEPLOY_URL;
20
- if (process.env.VERCEL_URL)
21
- return `https://${process.env.VERCEL_URL}`;
22
15
  let url = process.env.PUBLIC_URL;
23
16
  if (url === undefined) {
24
- console.warn(`${chalk_1.default.yellow.bold('Warning:')} An PUBLIC_URL environment variable is not defined. Falling back to http://localhost:3000.`);
17
+ if (process.env.NETLIFY && process.env.DEPLOY_URL)
18
+ return process.env.DEPLOY_URL;
19
+ if (process.env.VERCEL_URL)
20
+ return `https://${process.env.VERCEL_URL}`;
25
21
  url = 'http://localhost:3000';
26
22
  }
27
- else {
28
- try {
29
- new URL(url);
30
- }
31
- catch (error) {
32
- throw new Error(`The PUBLIC_URL environment variable '${url}' is not a valid URL.`);
33
- }
34
- }
35
23
  // Ensure no trailing slash
36
- return url.toString().replace(/\/$/, '');
24
+ return url.replace(/\/$/, '');
37
25
  };
38
26
  exports.getPublicUrl = getPublicUrl;
39
27
  /**
@@ -23,7 +23,7 @@ export class Context {
23
23
  * @returns initialized SDK
24
24
  */
25
25
  this.getSDK = (name) => {
26
- return this.sdkPromises[name];
26
+ return this.sdkPromises[name] || Promise.reject(`Unknown SDK '${String(name)}'`);
27
27
  };
28
28
  this.sitecoreEdgeUrl = props.sitecoreEdgeUrl;
29
29
  this.sitecoreEdgeContextId = props.sitecoreEdgeContextId;
@@ -1,4 +1,3 @@
1
- import chalk from 'chalk';
2
1
  import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/utils';
3
2
  /**
4
3
  * Get the publicUrl.
@@ -7,27 +6,19 @@ import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/u
7
6
  * VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
8
7
  * preview deployment has unique url, we don't know exact url.
9
8
  * Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
9
+ * In production non-editing environments it is desirable to use relative urls, so in that case set PUBLIC_URL = ''
10
10
  */
11
11
  export const getPublicUrl = () => {
12
- if (process.env.NETLIFY && process.env.DEPLOY_URL)
13
- return process.env.DEPLOY_URL;
14
- if (process.env.VERCEL_URL)
15
- return `https://${process.env.VERCEL_URL}`;
16
12
  let url = process.env.PUBLIC_URL;
17
13
  if (url === undefined) {
18
- console.warn(`${chalk.yellow.bold('Warning:')} An PUBLIC_URL environment variable is not defined. Falling back to http://localhost:3000.`);
14
+ if (process.env.NETLIFY && process.env.DEPLOY_URL)
15
+ return process.env.DEPLOY_URL;
16
+ if (process.env.VERCEL_URL)
17
+ return `https://${process.env.VERCEL_URL}`;
19
18
  url = 'http://localhost:3000';
20
19
  }
21
- else {
22
- try {
23
- new URL(url);
24
- }
25
- catch (error) {
26
- throw new Error(`The PUBLIC_URL environment variable '${url}' is not a valid URL.`);
27
- }
28
- }
29
20
  // Ensure no trailing slash
30
- return url.toString().replace(/\/$/, '');
21
+ return url.replace(/\/$/, '');
31
22
  };
32
23
  /**
33
24
  * Since Sitecore editors do not support Fast Refresh:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "21.7.0-canary.17",
3
+ "version": "21.7.0-canary.19",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -73,9 +73,9 @@
73
73
  "react-dom": "^18.2.0"
74
74
  },
75
75
  "dependencies": {
76
- "@sitecore-jss/sitecore-jss": "^21.7.0-canary.17",
77
- "@sitecore-jss/sitecore-jss-dev-tools": "^21.7.0-canary.17",
78
- "@sitecore-jss/sitecore-jss-react": "^21.7.0-canary.17",
76
+ "@sitecore-jss/sitecore-jss": "^21.7.0-canary.19",
77
+ "@sitecore-jss/sitecore-jss-dev-tools": "^21.7.0-canary.19",
78
+ "@sitecore-jss/sitecore-jss-react": "^21.7.0-canary.19",
79
79
  "@vercel/kv": "^0.2.1",
80
80
  "node-html-parser": "^6.1.4",
81
81
  "prop-types": "^15.8.1",
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "description": "",
86
86
  "types": "types/index.d.ts",
87
- "gitHead": "5ddad312682a0a08aacc86dbc8416690b69b7301",
87
+ "gitHead": "ade83983264829c9a7eb4f5426450e75b00ff9fc",
88
88
  "files": [
89
89
  "dist",
90
90
  "types",
@@ -92,7 +92,7 @@ export declare class Context<SDKModules extends SDKModulesType> {
92
92
  * @param {string} name SDK name
93
93
  * @returns initialized SDK
94
94
  */
95
- getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]> | undefined;
95
+ getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]>;
96
96
  /**
97
97
  * Initializes the Software Development Kit (SDK)
98
98
  *
@@ -5,6 +5,7 @@
5
5
  * VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
6
6
  * preview deployment has unique url, we don't know exact url.
7
7
  * Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
8
+ * In production non-editing environments it is desirable to use relative urls, so in that case set PUBLIC_URL = ''
8
9
  */
9
10
  export declare const getPublicUrl: () => string;
10
11
  /**