Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:Sitecore/jss into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
addy-pathania committed Jan 15, 2024
2 parents bd92a5c + 4829923 commit e0c62f5
Show file tree
Hide file tree
Showing 234 changed files with 2,816 additions and 2,769 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Our versioning strategy is as follows:
### 🧹 Chores

* Upgrade to Node.js 20.x ([#1679](https://github.com/Sitecore/jss/pull/1679))([#1681](https://github.com/Sitecore/jss/pull/1681))
* `[nextjs/template]` Upgrade graphql-codegen packages to latest ([#1711](https://github.com/Sitecore/jss/pull/1711))

## 21.6.0

Expand All @@ -48,6 +49,7 @@ Our versioning strategy is as follows:
* `[templates/nextjs]` `[sitecore-jss-nextjs]` Fix making a fetch to a nextjs api route in an editing environment, by adding additional variable publicUrl in runtime config ([#1656](https://github.com/Sitecore/jss/pull/1656))
* `[templates/nextjs-multisite]` Fix site info fetch errors (now skipped) on XM Cloud rendering/editing host builds. ([#1649](https://github.com/Sitecore/jss/pull/1649)) ([#1653](https://github.com/Sitecore/jss/pull/1653))
* `[templates/nextjs-xmcloud]` Fix double registration of BYOC components ([#1707](https://github.com/Sitecore/jss/pull/1707)) ([#1709](https://github.com/Sitecore/jss/pull/1709))
* `[sitecore-jss-nextjs] [templates/nextjs-xmcloud]` SDK initialization rejections are now correctly handled. Errors should no longer occur after getSDK() promises resolve when they shouldn't (for example, getting Events SDK in development environment) ([#1712](https://github.com/Sitecore/jss/pull/1712))

### 🛠 Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lerna": "3.22.1",
"packages": ["packages/*", "samples/*"],
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion packages/create-sitecore-jss/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-sitecore-jss",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "Sitecore JSS initializer",
"bin": "./dist/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const sdkModule: SDK<typeof Events> = {
init: async (props) => {
// Events module can't be initialized on the server side
// We also don't want to initialize it in development mode
if (typeof window === 'undefined' || process.env.NODE_ENV === 'development') return;

if (typeof window === 'undefined')
throw 'Browser Events SDK is not initialized in server context';
if (process.env.NODE_ENV === 'development')
throw 'Browser Events SDK is not initialized in development environment';

await Events.init({
siteName: props.siteName,
sitecoreEdgeUrl: props.sitecoreEdgeUrl,
Expand Down
16 changes: 8 additions & 8 deletions packages/create-sitecore-jss/src/templates/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@graphql-codegen/cli": "^1.21.8",
"@graphql-codegen/import-types-preset": "^2.2.6",
"@graphql-codegen/plugin-helpers": "^3.1.2",
"@graphql-codegen/typed-document-node": "^2.3.12",
"@graphql-codegen/typescript": "^2.8.7",
"@graphql-codegen/typescript-operations": "^2.5.12",
"@graphql-codegen/typescript-resolvers": "^2.7.12",
"@graphql-typed-document-node/core": "^3.1.1",
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/plugin-helpers": "^5.0.1",
"@graphql-codegen/typed-document-node": "^5.0.1",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-resolvers": "^4.0.1",
"@graphql-typed-document-node/core": "^3.2.0",
"@sitecore-jss/sitecore-jss-cli": "~21.7.0-canary",
"@sitecore-jss/sitecore-jss-dev-tools": "~21.7.0-canary",
"@types/node": "^18.11.18",
Expand Down
2 changes: 1 addition & 1 deletion packages/sitecore-jss-angular-schematics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-angular-schematics",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "Scaffolding schematics for Sitecore JSS Angular apps",
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-angular",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "",
"scripts": {
"build": "ng-packagr -p ng-package.json",
Expand Down Expand Up @@ -58,7 +58,7 @@
"rxjs": "~7.8.1"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44"
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47"
},
"main": "dist/esm2022/sitecore-jss-sitecore-jss-angular.mjs",
"module": "dist/esm2022/sitecore-jss-sitecore-jss-angular.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-cli",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "Sitecore JSS command-line",
"main": "dist/cjs/cli.js",
"module": "dist/esm/cli.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"url": "https://github.com/sitecore/jss/issues"
},
"dependencies": {
"@sitecore-jss/sitecore-jss-dev-tools": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss-dev-tools": "21.7.0-canary.47",
"chalk": "^4.1.2",
"cross-spawn": "^7.0.3",
"dotenv": "^16.0.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-dev-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-dev-tools",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "Utilities to assist in the development and deployment of Sitecore JSS apps.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"url": "https://github.com/sitecore/jss/issues"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47",
"axios": "^1.3.2",
"chalk": "^4.1.2",
"chokidar": "^3.5.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-forms",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"sideEffects": false,
Expand Down Expand Up @@ -43,7 +43,7 @@
"typescript": "~4.9.5"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44"
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47"
},
"description": "",
"types": "types/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions packages/sitecore-jss-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-nextjs",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"sideEffects": false,
Expand Down Expand Up @@ -72,9 +72,9 @@
"react-dom": "^18.2.0"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss-dev-tools": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss-react": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47",
"@sitecore-jss/sitecore-jss-dev-tools": "21.7.0-canary.47",
"@sitecore-jss/sitecore-jss-react": "21.7.0-canary.47",
"@vercel/kv": "^0.2.1",
"node-html-parser": "^6.1.4",
"prop-types": "^15.8.1",
Expand Down
37 changes: 37 additions & 0 deletions packages/sitecore-jss-nextjs/src/context/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ describe('Context', () => {
},
};

const errorSdk = {
Error: {
sdk: { error: 'yes' },
init: () => {
return new Promise<void>((_, reject) => {
reject('Cannot init Error');
});
},
},
};

const fooInitSpy = sinon.spy(sdks.Foo, 'init');
const barInitSpy = sinon.spy(sdks.Bar, 'init');

Expand Down Expand Up @@ -159,6 +170,32 @@ describe('Context', () => {

expect(context.siteName).to.equal('website-1');
});

it('should catch and log when SDK initialization rejects', () => {
const consoleSpy = sinon.spy(console, 'log');
const localProps = { ...props, sdks: errorSdk };
const context = new Context<typeof errorSdk>(localProps);
context.init();
expect(
consoleSpy.calledWith('Initialization for SDK Error skipped. Reason: \n Cannot init Error')
);
consoleSpy.restore();
});

it('should reject when getting SDK that rejected initialization', (done) => {
const localProps = { ...props, sdks: errorSdk };
const context = new Context<typeof errorSdk>(localProps);
context.init();
context
.getSDK('Error')
.then(() => {
throw new Error('should not resolve');
})
.catch((e) => {
expect(e).to.be.equal('Cannot init Error');
done();
});
});
});

describe('getSDK', () => {
Expand Down
17 changes: 11 additions & 6 deletions packages/sitecore-jss-nextjs/src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,17 @@ export class Context<SDKModules extends SDKModulesType> {
* @returns {void}
*/
protected initSDK<T extends keyof SDKModules>(name: T): void {
this.sdkPromises[name] = new Promise((resolve) => {
this.props.sdks[name].init(this).then(() => {
this.sdks[name] = this.props.sdks[name].sdk;

resolve(this.sdks[name]);
});
this.sdkPromises[name] = new Promise((resolve, reject) => {
this.props.sdks[name]
.init(this)
.then(() => {
this.sdks[name] = this.props.sdks[name].sdk;
resolve(this.sdks[name]);
})
.catch((e) => {
// if init rejects, getSDK will reject too now
reject(e);
});
});
}
}
2 changes: 1 addition & 1 deletion packages/sitecore-jss-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-proxy",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "Proxy middleware for express.js server.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-react-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-react-forms",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"sideEffects": false,
Expand Down Expand Up @@ -54,7 +54,7 @@
"react-dom": "^18.2.0"
},
"dependencies": {
"@sitecore-jss/sitecore-jss-forms": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss-forms": "21.7.0-canary.47",
"prop-types": "^15.8.1"
},
"description": "",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-react-native",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"url": "https://github.com/sitecore/jss/issues"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47",
"prop-types": "^15.7.2",
"react-native-htmlview": "^0.15.0",
"react-native-svg": "^5.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-react",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"sideEffects": false,
Expand Down Expand Up @@ -62,7 +62,7 @@
"react-dom": "^18.2.0"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47",
"deep-equal": "^2.1.0",
"prop-types": "^15.8.1",
"style-attr": "^1.3.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/sitecore-jss-rendering-host/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-rendering-host",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"sideEffects": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss-vue",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"description": "A library for building Sitecore JSS apps using Vue.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -50,7 +50,7 @@
"vue": "^3.2.45"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "21.7.0-canary.44",
"@sitecore-jss/sitecore-jss": "21.7.0-canary.47",
"@vue/compiler-sfc": "^3.0.11"
},
"types": "./types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/sitecore-jss/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sitecore-jss/sitecore-jss",
"version": "21.7.0-canary.44",
"version": "21.7.0-canary.47",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion ref-docs/sitecore-jss-angular-schematics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@

#### Defined in

[index.ts:41](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular-schematics/src/jss-component/index.ts#L41)
[index.ts:41](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular-schematics/src/jss-component/index.ts#L41)
4 changes: 2 additions & 2 deletions ref-docs/sitecore-jss-angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ sitecore-jss/types/utils/edit-frame.d.ts:57

#### Defined in

[sitecore-jss-angular/src/components/placeholder.token.ts:65](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L65)
[sitecore-jss-angular/src/components/placeholder.token.ts:65](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L65)

___

Expand Down Expand Up @@ -405,7 +405,7 @@ rendering is HtmlElementRendering

#### Defined in

[sitecore-jss-angular/src/components/rendering.ts:6](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular/src/components/rendering.ts#L6)
[sitecore-jss-angular/src/components/rendering.ts:6](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular/src/components/rendering.ts#L6)

___

Expand Down
8 changes: 4 additions & 4 deletions ref-docs/sitecore-jss-angular/classes/ComponentNameAndType.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Registers a statically loaded component

#### Defined in

[sitecore-jss-angular/src/components/placeholder.token.ts:12](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L12)
[sitecore-jss-angular/src/components/placeholder.token.ts:12](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L12)

___

Expand All @@ -41,7 +41,7 @@ ___

#### Defined in

[sitecore-jss-angular/src/components/placeholder.token.ts:9](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L9)
[sitecore-jss-angular/src/components/placeholder.token.ts:9](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L9)

___

Expand All @@ -55,7 +55,7 @@ ___

#### Defined in

[sitecore-jss-angular/src/components/placeholder.token.ts:17](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L17)
[sitecore-jss-angular/src/components/placeholder.token.ts:17](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L17)

___

Expand All @@ -65,4 +65,4 @@ ___

#### Defined in

[sitecore-jss-angular/src/components/placeholder.token.ts:10](https://github.com/Sitecore/jss/blob/d2233c355/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L10)
[sitecore-jss-angular/src/components/placeholder.token.ts:10](https://github.com/Sitecore/jss/blob/4e03c287a/packages/sitecore-jss-angular/src/components/placeholder.token.ts#L10)
Loading

0 comments on commit e0c62f5

Please sign in to comment.