@bloomreach/react-sdk
Advanced tools
Comparing version 20.0.0 to 21.0.0-alpha.0
@@ -82,4 +82,4 @@ import * as _bloomreach_spa_sdk from '@bloomreach/spa-sdk'; | ||
constructor(props: BrPageProps); | ||
componentDidMount(): Promise<void>; | ||
componentDidUpdate(prevProps: BrPageProps, prevState: BrPageState): Promise<void>; | ||
componentDidMount(): void; | ||
componentDidUpdate(prevProps: BrPageProps, prevState: BrPageState): void; | ||
componentWillUnmount(): void; | ||
@@ -86,0 +86,0 @@ private initialize; |
@@ -94,24 +94,23 @@ import React, { useRef, useEffect, useState } from "react"; | ||
this.state = { | ||
page: undefined | ||
page: props.page && initialize(props.configuration, props.page) | ||
}; | ||
} | ||
componentDidMount() { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
yield this.initialize(); | ||
const {page: pageInState} = this.state; | ||
pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync(); | ||
})); | ||
const {page} = this.props; | ||
if (!page) { | ||
this.initialize(); | ||
} | ||
const {page: pageInState} = this.state; | ||
pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync(); | ||
} | ||
componentDidUpdate(prevProps, prevState) { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
const {configuration, page} = this.props; | ||
if (configuration !== prevProps.configuration || page !== prevProps.page) { | ||
this.destroy(); | ||
yield this.initialize(); | ||
} | ||
const {page: pageInState} = this.state; | ||
if (pageInState !== prevState.page) { | ||
this.forceUpdate((() => pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync())); | ||
} | ||
})); | ||
const {configuration, page} = this.props; | ||
if (configuration !== prevProps.configuration || page !== prevProps.page) { | ||
this.destroy(); | ||
this.initialize(page === prevProps.page); | ||
} | ||
const {page: pageInState} = this.state; | ||
if (pageInState !== prevState.page) { | ||
this.forceUpdate((() => pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync())); | ||
} | ||
} | ||
@@ -121,8 +120,9 @@ componentWillUnmount() { | ||
} | ||
initialize() { | ||
initialize(force = false) { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
const {page, configuration} = this.props; | ||
const model = force ? undefined : page; | ||
try { | ||
this.setState({ | ||
page: page ? yield initialize(configuration, page) : yield initialize(configuration) | ||
page: model ? initialize(configuration, model) : yield initialize(configuration) | ||
}); | ||
@@ -375,5 +375,3 @@ } catch (error) { | ||
function rewriteLinksAndSanitize() { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
setSafeHTML(yield page.prepareHTML(documentRef, dataFieldName)); | ||
})); | ||
setSafeHTML(page.prepareHTML(documentRef, dataFieldName)); | ||
} | ||
@@ -380,0 +378,0 @@ if (!page) { |
@@ -97,24 +97,23 @@ (function(global, factory) { | ||
this.state = { | ||
page: undefined | ||
page: props.page && spaSdk.initialize(props.configuration, props.page) | ||
}; | ||
} | ||
componentDidMount() { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
yield this.initialize(); | ||
const {page: pageInState} = this.state; | ||
pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync(); | ||
})); | ||
const {page} = this.props; | ||
if (!page) { | ||
this.initialize(); | ||
} | ||
const {page: pageInState} = this.state; | ||
pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync(); | ||
} | ||
componentDidUpdate(prevProps, prevState) { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
const {configuration, page} = this.props; | ||
if (configuration !== prevProps.configuration || page !== prevProps.page) { | ||
this.destroy(); | ||
yield this.initialize(); | ||
} | ||
const {page: pageInState} = this.state; | ||
if (pageInState !== prevState.page) { | ||
this.forceUpdate((() => pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync())); | ||
} | ||
})); | ||
const {configuration, page} = this.props; | ||
if (configuration !== prevProps.configuration || page !== prevProps.page) { | ||
this.destroy(); | ||
this.initialize(page === prevProps.page); | ||
} | ||
const {page: pageInState} = this.state; | ||
if (pageInState !== prevState.page) { | ||
this.forceUpdate((() => pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync())); | ||
} | ||
} | ||
@@ -124,8 +123,9 @@ componentWillUnmount() { | ||
} | ||
initialize() { | ||
initialize(force = false) { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
const {page, configuration} = this.props; | ||
const model = force ? undefined : page; | ||
try { | ||
this.setState({ | ||
page: page ? yield spaSdk.initialize(configuration, page) : yield spaSdk.initialize(configuration) | ||
page: model ? spaSdk.initialize(configuration, model) : yield spaSdk.initialize(configuration) | ||
}); | ||
@@ -358,5 +358,3 @@ } catch (error) { | ||
function rewriteLinksAndSanitize() { | ||
return __awaiter(this, void 0, void 0, (function*() { | ||
setSafeHTML(yield page.prepareHTML(documentRef, dataFieldName)); | ||
})); | ||
setSafeHTML(page.prepareHTML(documentRef, dataFieldName)); | ||
} | ||
@@ -363,0 +361,0 @@ if (!page) { |
{ | ||
"name": "@bloomreach/react-sdk", | ||
"version": "20.0.0", | ||
"version": "21.0.0-alpha.0", | ||
"description": "Bloomreach SPA SDK for React", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@bloomreach/spa-sdk": "20.0.0" | ||
"@bloomreach/spa-sdk": "21.0.0-alpha.0" | ||
}, | ||
@@ -116,3 +116,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "e253082582192b5b784be005a1d27e53ef16002e" | ||
"gitHead": "3839e8e31b3fd231e96a8d98bae2e359c93f0fef" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
110160
834
1
+ Added@bloomreach/spa-sdk@21.0.0-alpha.0(transitive)
- Removed@bloomreach/spa-sdk@20.0.0(transitive)