@garfish/bridge-react-v18
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -26,7 +26,7 @@ var __defProp = Object.defineProperty; | ||
var defaultOpts = { | ||
rootComponent: null, | ||
loadRootComponent: null, | ||
renderType: null, | ||
errorBoundary: null, | ||
el: null, | ||
rootComponent: void 0, | ||
loadRootComponent: void 0, | ||
renderType: void 0, | ||
errorBoundary: void 0, | ||
el: void 0, | ||
canUpdate: true, | ||
@@ -94,10 +94,16 @@ suppressComponentDidCatchWarning: false, | ||
}); | ||
opts.domElements[appInfo.appName] = domElement; | ||
opts.renderResults[appInfo.appName] = renderResult; | ||
if (opts.domElements) { | ||
opts.domElements[appInfo.appName] = domElement; | ||
} | ||
if (opts.renderResults) { | ||
opts.renderResults[appInfo.appName] = renderResult; | ||
} | ||
} | ||
function unmount(opts, appInfo) { | ||
const root = opts.renderResults[appInfo.appName]; | ||
root.unmount(); | ||
delete opts.domElements[appInfo.appName]; | ||
delete opts.renderResults[appInfo.appName]; | ||
if (opts.renderResults) { | ||
const root = opts.renderResults[appInfo.appName]; | ||
root.unmount(); | ||
opts.domElements && delete opts.domElements[appInfo.appName]; | ||
delete opts.renderResults[appInfo.appName]; | ||
} | ||
} | ||
@@ -129,6 +135,7 @@ function atLeastReact18(React2) { | ||
function getElementToRender(opts, appInfo) { | ||
const rootComponentElement = opts.React.createElement(opts.rootComponent, appInfo); | ||
var _a, _b; | ||
const rootComponentElement = (_a = opts.React) == null ? void 0 : _a.createElement(opts.rootComponent, appInfo); | ||
let elementToRender = rootComponentElement; | ||
if (opts.errorBoundary) { | ||
elementToRender = opts.React.createElement(createErrorBoundary(opts), appInfo, elementToRender); | ||
elementToRender = (_b = opts.React) == null ? void 0 : _b.createElement(createErrorBoundary(opts), appInfo, elementToRender); | ||
} | ||
@@ -139,3 +146,4 @@ return elementToRender; | ||
function GarfishSubAppReactErrorBoundary(appInfo) { | ||
opts.React.Component.apply(this, arguments); | ||
var _a; | ||
(_a = opts.React) == null ? void 0 : _a.Component.apply(this, arguments); | ||
this.state = { | ||
@@ -147,7 +155,7 @@ caughtError: null, | ||
} | ||
GarfishSubAppReactErrorBoundary.prototype = Object.create(opts.React.Component.prototype); | ||
GarfishSubAppReactErrorBoundary.prototype = opts.React && Object.create(opts.React.Component.prototype); | ||
GarfishSubAppReactErrorBoundary.prototype.render = function() { | ||
if (this.state.caughtError) { | ||
const errorBoundary = opts.errorBoundary; | ||
return errorBoundary(this.state.caughtError, this.props); | ||
return errorBoundary && errorBoundary(this.state.caughtError, this.props); | ||
} else { | ||
@@ -154,0 +162,0 @@ return this.props.children; |
@@ -52,7 +52,7 @@ var __create = Object.create; | ||
var defaultOpts = { | ||
rootComponent: null, | ||
loadRootComponent: null, | ||
renderType: null, | ||
errorBoundary: null, | ||
el: null, | ||
rootComponent: void 0, | ||
loadRootComponent: void 0, | ||
renderType: void 0, | ||
errorBoundary: void 0, | ||
el: void 0, | ||
canUpdate: true, | ||
@@ -120,10 +120,16 @@ suppressComponentDidCatchWarning: false, | ||
}); | ||
opts.domElements[appInfo.appName] = domElement; | ||
opts.renderResults[appInfo.appName] = renderResult; | ||
if (opts.domElements) { | ||
opts.domElements[appInfo.appName] = domElement; | ||
} | ||
if (opts.renderResults) { | ||
opts.renderResults[appInfo.appName] = renderResult; | ||
} | ||
} | ||
function unmount(opts, appInfo) { | ||
const root = opts.renderResults[appInfo.appName]; | ||
root.unmount(); | ||
delete opts.domElements[appInfo.appName]; | ||
delete opts.renderResults[appInfo.appName]; | ||
if (opts.renderResults) { | ||
const root = opts.renderResults[appInfo.appName]; | ||
root.unmount(); | ||
opts.domElements && delete opts.domElements[appInfo.appName]; | ||
delete opts.renderResults[appInfo.appName]; | ||
} | ||
} | ||
@@ -155,6 +161,7 @@ function atLeastReact18(React2) { | ||
function getElementToRender(opts, appInfo) { | ||
const rootComponentElement = opts.React.createElement(opts.rootComponent, appInfo); | ||
var _a, _b; | ||
const rootComponentElement = (_a = opts.React) == null ? void 0 : _a.createElement(opts.rootComponent, appInfo); | ||
let elementToRender = rootComponentElement; | ||
if (opts.errorBoundary) { | ||
elementToRender = opts.React.createElement(createErrorBoundary(opts), appInfo, elementToRender); | ||
elementToRender = (_b = opts.React) == null ? void 0 : _b.createElement(createErrorBoundary(opts), appInfo, elementToRender); | ||
} | ||
@@ -165,3 +172,4 @@ return elementToRender; | ||
function GarfishSubAppReactErrorBoundary(appInfo) { | ||
opts.React.Component.apply(this, arguments); | ||
var _a; | ||
(_a = opts.React) == null ? void 0 : _a.Component.apply(this, arguments); | ||
this.state = { | ||
@@ -173,7 +181,7 @@ caughtError: null, | ||
} | ||
GarfishSubAppReactErrorBoundary.prototype = Object.create(opts.React.Component.prototype); | ||
GarfishSubAppReactErrorBoundary.prototype = opts.React && Object.create(opts.React.Component.prototype); | ||
GarfishSubAppReactErrorBoundary.prototype.render = function() { | ||
if (this.state.caughtError) { | ||
const errorBoundary = opts.errorBoundary; | ||
return errorBoundary(this.state.caughtError, this.props); | ||
return errorBoundary && errorBoundary(this.state.caughtError, this.props); | ||
} else { | ||
@@ -180,0 +188,0 @@ return this.props.children; |
{ | ||
"name": "@garfish/bridge-react-v18", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "garfish module.", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@garfish/utils": "1.7.2" | ||
"@garfish/utils": "1.8.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19657
446
+ Added@garfish/utils@1.8.0(transitive)
- Removed@garfish/utils@1.7.2(transitive)
Updated@garfish/utils@1.8.0