Socket
Socket
Sign inDemoInstall

@murasoftware/next-core

Package Overview
Dependencies
318
Maintainers
5
Versions
108
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.98 to 2.0.1

754

dist/index.modern.js
import { useEffect, useState, createContext } from 'react';
import Mura from 'mura.js';
import Mura$1 from 'mura.js';
import styleMap from 'mura.js/src/core/stylemap-static';

@@ -7,3 +7,3 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';

function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {

@@ -21,5 +21,10 @@ var source = arguments[i];

};
return _extends.apply(this, arguments);
}
Mura$1.styleMap = styleMap;
var _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
function _settle(pact, state, value) {

@@ -55,6 +60,90 @@ if (!pact.s) {

var getModuleProps = function getModuleProps(item, moduleStyleData, isEditMode, content, queryParams, requestContext) {
var _Pact = /*#__PURE__*/function () {
function _Pact() {}
_Pact.prototype.then = function (onFulfilled, onRejected) {
var result = new _Pact();
var state = this.s;
if (state) {
var callback = state & 1 ? onFulfilled : onRejected;
if (callback) {
try {
_settle(result, 1, callback(this.v));
} catch (e) {
_settle(result, 2, e);
}
return result;
} else {
return this;
}
}
this.o = function (_this) {
try {
var value = _this.v;
if (_this.s & 1) {
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
} else if (onRejected) {
_settle(result, 1, onRejected(value));
} else {
_settle(result, 2, value);
}
} catch (e) {
_settle(result, 2, e);
}
};
return result;
};
return _Pact;
}();
function _isSettledPact(thenable) {
return thenable instanceof _Pact && thenable.s & 1;
}
function _forTo(array, body, check) {
var i = -1,
pact,
reject;
function _cycle(result) {
try {
while (++i < array.length && (!check || !check())) {
result = body(i);
if (result && result.then) {
if (_isSettledPact(result)) {
result = result.v;
} else {
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
return;
}
}
}
if (pact) {
_settle(pact, 1, result);
} else {
pact = result;
}
} catch (e) {
_settle(pact || (pact = new _Pact()), 2, e);
}
}
_cycle();
return pact;
}
var getModuleProps = function getModuleProps(item, moduleStyleData, renderMode, content, queryParams, Mura) {
try {
var _temp29 = function _temp29() {
if (isEditMode || !Mura.isInNode()) {
var _temp35 = function _temp35() {
if (renderMode == 'dynamic' || !Mura.isInNode()) {
return {

@@ -71,5 +160,3 @@ cssRules: []

getMura();
var _temp30 = _catch(function () {
var _temp36 = _catch(function () {
var objectkey = item.object;

@@ -81,6 +168,6 @@

var _temp26 = function () {
var _temp32 = function () {
if (typeof ComponentRegistry[objectkey] != 'undefined') {
var _temp31 = function _temp31() {
var _temp23 = function () {
var _temp37 = function _temp37() {
var _temp29 = function () {
if (item.object == 'container') {

@@ -95,6 +182,6 @@ if (typeof item.items != 'undefined' && !Array.isArray(item.items)) {

var _temp33 = _forIn(item.items, function (containerIdx) {
var _temp39 = _forIn(item.items, function (containerIdx) {
var containerItem = item.items[containerIdx];
containerItem.instanceid = containerItem.instanceid || Mura.createUUID();
return Promise.resolve(getModuleProps(containerItem, moduleStyleData, isEditMode, content, queryParams, requestContext)).then(function (_getModuleProps3) {
return Promise.resolve(getModuleProps(containerItem, moduleStyleData, renderMode, content, queryParams, Mura)).then(function (_getModuleProps3) {
moduleStyleData[containerItem.instanceid] = _getModuleProps3;

@@ -104,16 +191,16 @@ });

if (_temp33 && _temp33.then) return _temp33.then(function () {});
if (_temp39 && _temp39.then) return _temp39.then(function () {});
}
}();
if (_temp23 && _temp23.then) return _temp23.then(function () {});
if (_temp29 && _temp29.then) return _temp29.then(function () {});
};
var _temp32 = function () {
var _temp38 = function () {
if (ComponentRegistry[objectkey].SSR) {
var _temp34 = _catch(function () {
var _temp40 = _catch(function () {
return Promise.resolve(ComponentRegistry[objectkey].getDynamicProps(_extends({}, item, {
content: content,
queryParams: queryParams,
requestContext: requestContext
Mura: Mura
}))).then(function (_ComponentRegistry$ob) {

@@ -127,11 +214,11 @@ item.dynamicProps = _ComponentRegistry$ob;

if (_temp34 && _temp34.then) return _temp34.then(function () {});
if (_temp40 && _temp40.then) return _temp40.then(function () {});
}
}();
return _temp32 && _temp32.then ? _temp32.then(_temp31) : _temp31(_temp32);
return _temp38 && _temp38.then ? _temp38.then(_temp37) : _temp37(_temp38);
}
}();
if (_temp26 && _temp26.then) return _temp26.then(function () {});
if (_temp32 && _temp32.then) return _temp32.then(function () {});
}, function (e) {

@@ -141,3 +228,5 @@ console.error(e);

return Promise.resolve(_temp30 && _temp30.then ? _temp30.then(_temp29) : _temp29(_temp30));
//This is so that the getDynamicProps call has a new getMura()
//Important for server side thread safety
return Promise.resolve(_temp36 && _temp36.then ? _temp36.then(_temp35) : _temp35(_temp36));
} catch (e) {

@@ -148,89 +237,78 @@ return Promise.reject(e);

var _Pact = /*#__PURE__*/function () {
function _Pact() {}
function _forOf(target, body, check) {
if (typeof target[_iteratorSymbol] === "function") {
var _cycle = function _cycle(result) {
try {
while (!(step = iterator.next()).done && (!check || !check())) {
result = body(step.value);
_Pact.prototype.then = function (onFulfilled, onRejected) {
var result = new _Pact();
var state = this.s;
if (state) {
var callback = state & 1 ? onFulfilled : onRejected;
if (callback) {
try {
_settle(result, 1, callback(this.v));
} catch (e) {
_settle(result, 2, e);
if (result && result.then) {
if (_isSettledPact(result)) {
result = result.v;
} else {
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
return;
}
}
}
return result;
} else {
return this;
}
}
this.o = function (_this) {
try {
var value = _this.v;
if (_this.s & 1) {
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
} else if (onRejected) {
_settle(result, 1, onRejected(value));
if (pact) {
_settle(pact, 1, result);
} else {
_settle(result, 2, value);
pact = result;
}
} catch (e) {
_settle(result, 2, e);
_settle(pact || (pact = new _Pact()), 2, e);
}
};
return result;
};
var iterator = target[_iteratorSymbol](),
step,
pact,
reject;
return _Pact;
}();
_cycle();
function _isSettledPact(thenable) {
return thenable instanceof _Pact && thenable.s & 1;
}
if (iterator.return) {
var _fixup = function _fixup(value) {
try {
if (!step.done) {
iterator.return();
}
} catch (e) {}
function _forTo(array, body, check) {
var i = -1,
pact,
reject;
return value;
};
function _cycle(result) {
try {
while (++i < array.length && (!check || !check())) {
result = body(i);
if (result && result.then) {
if (_isSettledPact(result)) {
result = result.v;
} else {
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
return;
}
}
if (pact && pact.then) {
return pact.then(_fixup, function (e) {
throw _fixup(e);
});
}
if (pact) {
_settle(pact, 1, result);
} else {
pact = result;
}
} catch (e) {
_settle(pact || (pact = new _Pact()), 2, e);
_fixup();
}
return pact;
} // No support for Symbol.iterator
if (!("length" in target)) {
throw new TypeError("Object is not iterable");
} // Handle live collections properly
var values = [];
for (var i = 0; i < target.length; i++) {
values.push(target[i]);
}
_cycle();
return pact;
return _forTo(values, function (i) {
return body(values[i]);
}, check);
}
var getRegionProps = function getRegionProps(content, queryParams, isEditMode, requestContext) {
var getRegionProps = function getRegionProps(content, queryParams, renderMode, Mura) {
try {
getMura();
var moduleStyleData = {};

@@ -240,8 +318,8 @@ content.displayregions = content.displayregions || {};

var _temp19 = _forIn(regions, function (regionIdx) {
function _temp17() {
var _temp15 = _forIn(region.local.items, function (itemIdx) {
var _temp25 = _forIn(regions, function (regionIdx) {
function _temp23() {
var _temp21 = _forIn(region.local.items, function (itemIdx) {
var item = region.local.items[itemIdx];
item.instanceid = item.instanceid || Mura.createUUID();
return Promise.resolve(getModuleProps(item, moduleStyleData, isEditMode, content, queryParams, requestContext)).then(function (_getModuleProps2) {
return Promise.resolve(getModuleProps(item, moduleStyleData, renderMode, content, queryParams, Mura)).then(function (_getModuleProps2) {
moduleStyleData[item.instanceid] = _getModuleProps2;

@@ -251,3 +329,3 @@ });

if (_temp15 && _temp15.then) return _temp15.then(function () {});
if (_temp21 && _temp21.then) return _temp21.then(function () {});
}

@@ -257,8 +335,8 @@

var _temp16 = function () {
var _temp22 = function () {
if (typeof region.inherited != 'undefined' && Array.isArray(region.inherited.items)) {
var _temp20 = _forIn(region.inherited.items, function (itemdIx) {
var _temp26 = _forIn(region.inherited.items, function (itemdIx) {
var item = region.inherited.items[itemdIx];
item.instanceid = item.instanceid || Mura.createUUID();
return Promise.resolve(getModuleProps(item, moduleStyleData, isEditMode, content, queryParams, requestContext)).then(function (_getModuleProps) {
return Promise.resolve(getModuleProps(item, moduleStyleData, renderMode, content, queryParams, Mura)).then(function (_getModuleProps) {
moduleStyleData[item.instanceid] = _getModuleProps;

@@ -268,10 +346,10 @@ });

if (_temp20 && _temp20.then) return _temp20.then(function () {});
if (_temp26 && _temp26.then) return _temp26.then(function () {});
}
}();
return _temp16 && _temp16.then ? _temp16.then(_temp17) : _temp17(_temp16);
return _temp22 && _temp22.then ? _temp22.then(_temp23) : _temp23(_temp22);
});
return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {
return Promise.resolve(_temp25 && _temp25.then ? _temp25.then(function () {
return moduleStyleData;

@@ -298,3 +376,3 @@ }) : moduleStyleData);

var renderContent = function renderContent(context, isEditMode, params, requestContext) {
var renderContent = function renderContent(context, renderMode, params, Mura) {
try {

@@ -309,6 +387,3 @@ var query = {};

if (isEditMode) {
query.isEditRoute = isEditMode;
}
query.renderMode = renderMode;
var filename = '';

@@ -318,3 +393,7 @@

if (Array.isArray(query.page)) {
filename = query.page[query.page.length - 1].split("/");
if (query.page[query.page.length - 1].indexOf('/') == -1) {
filename = query.page[query.page.length - 1].split("/");
} else {
filename = query.page;
}
} else {

@@ -340,6 +419,5 @@ filename = query.page.split("/");

query = Object.assign(query, params);
} //console.log('request params',filename, query);
}
return Promise.resolve(requestContext.renderFilename(filename, query).then(function (rendered) {
return Promise.resolve(Mura.renderFilename(filename, query).then(function (rendered) {
return Promise.resolve(rendered);

@@ -366,9 +444,11 @@ }, function (rendered) {

Mura.styleMap = styleMap;
var MuraClass = Object.create(Mura$1);
var muraConfig, connectorConfig, ComponentRegistry, ConnectorConfig, ExternalModules;
var isEditMode = false;
var MuraJSRefPlaceholder = '"undefined"!=typeof window&&function(u){u.queuedMuraCmds=[],u.queuedMuraPreInitCmds=[],"function"!=typeof u.Mura&&(u.Mura=u.mura=u.Mura=function(e){u.queuedMuraCmds.push(e)},u.Mura.preInit=function(e){u.queuedMuraPreInitCmds.push(e)})}(window);';
var MuraJSRefPlaceholder = '"undefined"!=typeof window&&function(u){u.queuedMuraCmds=[],u.queuedMuraPreInitCmds=[],"function"!=typeof u.Mura&&(u.Mura=u.mura=u.Mura=function(e){u.queuedMuraCmds.push(e)},u.Mura.preInit=function(e){u.queuedMuraPreInitCmds.push(e)})}(window);'; //deprecated
var setIsEditMode = function setIsEditMode(value) {
isEditMode = value;
};
}; //deprecated
var getIsEditMode = function getIsEditMode() {

@@ -399,3 +479,4 @@ return isEditMode;

}, [asyncFn, onSuccess]);
};
}; //Needs to account for thread safe Mura instance
var getHref = function getHref(filename) {

@@ -420,8 +501,8 @@ var path = filename.split('/').filter(function (item) {

};
var getComponent = function getComponent(item) {
getMura();
var objectkey = item.object;
var getComponent = function getComponent(props) {
var Mura = props.Mura;
var objectkey = props.object;
if (typeof ComponentRegistry[objectkey] == 'undefined') {
objectkey = Mura.firstToUpperCase(item.object);
objectkey = Mura.firstToUpperCase(props.object);
}

@@ -431,8 +512,8 @@

var ComponentVariable = ComponentRegistry[objectkey].component;
return /*#__PURE__*/jsx(ComponentVariable, _extends({}, item), item.instanceid);
return /*#__PURE__*/jsx(ComponentVariable, _extends({}, props), props.instanceid);
}
return /*#__PURE__*/jsxs("p", {
children: ["DisplayRegion: ", item.objectname]
}, item.instanceid);
children: ["DisplayRegion: ", props.objectname]
}, props.instanceid);
};

@@ -442,3 +523,3 @@ var getMuraPaths = function getMuraPaths() {

var _temp3 = function _temp3() {
var paths = pathList.map(function (item) {
return pathList.map(function (item) {
var page = [];

@@ -460,3 +541,2 @@

});
return paths;
};

@@ -471,4 +551,4 @@

var _temp4 = _forTo(siteids, function (index) {
getMura(siteids[index]);
var _temp4 = _forOf(siteids, function (siteid) {
var Mura = getMuraInstance(siteid);
return Promise.resolve(Mura.getFeed('content').maxItems(0).itemsPerPage(0).sort('orderno').where().prop('type').isNotIn('File,Link,Calendar').getQuery({

@@ -490,3 +570,86 @@ renderMode: 'static'

};
var getMuraInstance = function getMuraInstance(context) {
//If not in node, just return the global instance;
var isInNode = !(typeof process !== 'undefined' && {}.toString.call(process) === '[object process]' || typeof document == 'undefined');
if (isInNode) {
return getMura(context);
}
var startingsiteid = '';
var Mura = Object.create(MuraClass);
var instanceConfig = Object.assign({}, ConnectorConfig);
if (typeof Mura.deInit == 'function') {
try {
Mura.deInit();
} catch (e) {}
}
if (typeof context == 'string' && instanceConfig.siteid.find(function (item) {
return item === context;
})) {
instanceConfig.siteid = context;
} else {
var ishomepage = context && !(context.params && context.params.page) || typeof location != 'undefined' && (location.pathname == "/" || location.pathname == ConnectorConfig.editroute + "/");
if (Array.isArray(ConnectorConfig.siteid)) {
if (ishomepage) {
instanceConfig.siteid = ConnectorConfig.siteid[0];
} else {
var page = [];
if (context && context.params && context.params.page) {
page = [].concat(context.params.page);
page = page.filter(function (item) {
return item.length;
});
} else if (typeof location != 'undefined') {
page = location.pathname.split("/");
page = page.filter(function (item) {
return item.length;
});
if (page.length && ConnectorConfig.editroute && page[0] === ConnectorConfig.editroute.split("/")[1]) {
page.shift();
}
}
if (page.length) {
if (ConnectorConfig.siteid.find(function (item) {
return item === page[0];
})) {
instanceConfig.siteid = page[0];
instanceConfig.siteidinurls = true;
} else {
instanceConfig.siteid = ConnectorConfig.siteid[0];
}
}
}
}
}
if (context && context.res) {
Object.assign(instanceConfig, {
response: context.res,
request: context.req
}); //console.log('initing', connectorConfig.siteid)
Mura.init(instanceConfig);
} else if (startingsiteid != instanceConfig.siteid) {
//console.log('changing siteid',startingsiteid,connectorConfig.siteid)
Mura.init(instanceConfig);
}
Mura.holdReady(true);
return Mura;
}; //get global Mura instances for browser
var getMura = function getMura(context) {
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]' || typeof document == 'undefined') {
return getMuraInstance(context);
}
var Mura = Mura$1;
var startingsiteid = Mura.siteid;

@@ -560,175 +723,216 @@

return Mura;
};
}; //Deprecated
var getRootPath = function getRootPath() {
return getMura().rootpath;
};
}; //Deprecated
var getSiteName = function getSiteName() {
return getMura().sitename;
};
var getMuraProps = function getMuraProps(context, isEditMode, params, callback) {
var getMuraProps = function getMuraProps(context, isEditMode, params) {
try {
var _content;
var _temp17 = function _temp17() {
function _temp13() {
if (content.filename == '404') {
if (typeof context.params != 'undefined') {
console.error('404 rendering content', context.params);
}
var _temp12 = function _temp12() {
if (content.filename == '404') {
if (typeof context.params != 'undefined') {
console.error('404 rendering content', context.params);
if (typeof context.res != 'undefined') {
context.res.statusCode = 404;
}
}
if (typeof context.res != 'undefined') {
if (typeof content.isondisplay != 'undefined' && !content.isondisplay) {
context.res.statusCode = 404;
}
}
} else {
if (content.redirect) {
//match casing of nodeProxyRedirectCasing in mura.js
context.res.setHeader('Location', content.redirect);
if (typeof content.isondisplay != 'undefined' && !content.isondisplay) {
context.res.statusCode = 404;
} else {
if (content.redirect) {
//match casing of nodeProxyRedirectCasing in mura.js
context.res.setHeader('Location', content.redirect);
if (content.statuscode) {
context.res.statusCode = content.statuscode;
} else {
context.res.statusCode = 301;
}
if (content.statuscode) {
context.res.statusCode = content.statuscode;
} else {
context.res.statusCode = 301;
if (context.res.statusCode != 301) {
context.res.setHeader('Cache-Control', 'no-cache, no-store');
context.res.setHeader('Expires', 'Mon, 01 Jan 1990 00:00:00 GMT');
}
}
if (context.res.statusCode != 301) {
context.res.setHeader('Cache-Control', 'no-cache, no-store');
context.res.setHeader('Expires', 'Mon, 01 Jan 1990 00:00:00 GMT');
}
}
}
var queryParams = {};
var queryParams = {};
if (context.browser) {
queryParams = Mura.getQueryStringParams();
} else if (context.query) {
queryParams = _extends({}, context.query);
}
if (context.browser) {
queryParams = _Mura.getQueryStringParams();
} else if (context.query) {
queryParams = _extends({}, context.query);
}
return Promise.resolve(getRegionProps(content, queryParams, isEditMode, requestContext)).then(function (moduleStyleData) {
function _temp9() {
function _temp7() {
if (Mura.isInNode() && (typeof callback == 'undefined' || typeof callback == 'boolean' && callback)) {
Mura.deInit();
return Promise.resolve(getRegionProps(content, queryParams, renderMode, _Mura)).then(function (moduleStyleData) {
function _temp11() {
function _temp9() {
if (renderMode == 'dynamic') {
return {
props: props
};
} else {
return {
props: props,
revalidate: 1
};
}
}
if (isEditMode) {
return {
props: props
};
} else {
return {
props: props,
revalidate: 1
};
}
var props = {
content: content,
moduleStyleData: moduleStyleData,
externalModules: ExternalModules,
codeblocks: codeblocks,
queryParams: queryParams,
renderMode: renderMode
};
var _temp8 = function () {
if (typeof onAfter == 'function') {
var _temp16 = _catch(function () {
return Promise.resolve(onAfter(props, _Mura)).then(function () {});
}, function (e) {
console.log('Error running onAfter event in getMuraProps:', e);
});
if (_temp16 && _temp16.then) return _temp16.then(function () {});
}
}();
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
}
var props = {
content: content,
moduleStyleData: moduleStyleData,
externalModules: ExternalModules,
codeblocks: codeblocks,
queryParams: queryParams
var codeblocks = {
header: [],
bodystart: [],
footer: []
};
var _temp6 = function () {
if (typeof callback == 'function') {
return Promise.resolve(callback(callback)).then(function () {});
}
}();
var _temp10 = _catch(function () {
var _temp6 = function () {
if (connectorConfig.codeblocks && (context.res || context.browser) && !(queryParams.codeblocks && queryParams.codeblocks === "false")) {
return Promise.resolve(_Mura.getFeed('codeblock').where().prop('active').isEQ(1).getQuery()).then(function (codeCollection) {
codeCollection.forEach(function (item) {
var placement = item.get('placement').toLowerCase();
return _temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6);
}
if (placement == 'header') {
codeblocks.header.push(item.get('code'));
} else if (placement == 'footer') {
codeblocks.footer.push(item.get('code'));
} else if (placement == 'bodystart') {
codeblocks.bodystart.push(item.get('code'));
}
});
});
}
}();
var codeblocks = {
header: [],
bodystart: [],
footer: []
};
if (_temp6 && _temp6.then) return _temp6.then(function () {});
}, function (e) {
console.error(e);
});
var _temp8 = _catch(function () {
var _temp5 = function () {
if (connectorConfig.codeblocks && (context.res || context.browser) && !(queryParams.codeblocks && queryParams.codeblocks === "false")) {
return Promise.resolve(requestContext.getFeed('codeblock').where().prop('active').isEQ(1).getQuery()).then(function (codeCollection) {
codeCollection.forEach(function (item) {
var placement = item.get('placement').toLowerCase();
return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
});
}
if (placement == 'header') {
codeblocks.header.push(item.get('code'));
} else if (placement == 'footer') {
codeblocks.footer.push(item.get('code'));
} else if (placement == 'bodystart') {
codeblocks.bodystart.push(item.get('code'));
}
});
});
var content = {
title: "We're sorry, an error occurred",
menutitle: "We're sorry, an error occurred",
body: "",
isnew: 1,
siteid: _Mura.siteid,
type: 'Page',
subtype: 'Default',
contentid: _Mura.createUUID(),
contenthistid: _Mura.createUUID(),
filename: "500",
statusCode: 500,
errors: [],
displayregions: {
primarycontent: {
local: {
items: []
}
}();
}
}
};
if (_temp5 && _temp5.then) return _temp5.then(function () {});
}, function (e) {
console.error(e);
var _temp12 = _catch(function () {
return Promise.resolve(renderContent(context, renderMode, params, _Mura)).then(function (muraObject) {
if (typeof muraObject != 'undefined' && typeof muraObject.getAll != 'undefined') {
content = muraObject.getAll();
} else {
console.error('Error rendering content', muraObject);
if (typeof context.res != 'undefined') {
if (typeof muraObject != 'undefined' && typeof muraObject.statusCode != 'undefined') {
context.res.statusCode = muraObject.statusCode;
} else {
context.res.statusCode = 500;
}
}
}
});
}, function (e) {
console.error(e);
});
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
});
return _temp12 && _temp12.then ? _temp12.then(_temp13) : _temp13(_temp12);
};
getMura(context);
setIsEditMode(isEditMode);
Mura.renderMode = 'dynamic';
var _Mura;
if (!isEditMode) {
Mura.renderMode = 'static';
var renderMode = 'dynamic';
if (Mura.isInNode() && process && process.env && process.env.MURA_SSR_BASICTOKEN) {
Mura.setRequestHeader("Authorization", "Basic " + process.env.MURA_SSR_BASICTOKEN);
Mura.setMode("rest");
Mura.setAPIEndpoint(Mura.getAPIEndpoint().replace('/json/', '/rest/'));
if (typeof context === 'object' && context.context) {
params = context.params || {};
renderMode = typeof context.renderMode == 'undefined' ? 'dynamic' : context.renderMode;
if (typeof context.context === 'object') {
context = context.context;
}
}
var requestContext = Mura.getRequestContext();
var content = (_content = {
title: "We're sorry, an error occurred",
menutitle: "We're sorry, an error occurred",
body: "",
contentid: Mura.createUUID(),
isnew: 1,
siteid: Mura.siteid,
type: 'Page',
subtype: 'Default'
}, _content["contentid"] = Mura.createUUID(), _content.contenthistid = Mura.createUUID(), _content.filename = "500", _content.statusCode = 500, _content.errors = [], _content.displayregions = {
primarycontent: {
local: {
items: []
}
if (typeof context.Mura != 'undefined') {
_Mura = context.Mura;
} else {
_Mura = getMura(context);
}
}, _content);
} else {
renderMode = typeof isEditMode == 'undefined' || isEditMode ? 'dynamic' : 'static';
_Mura = getMura(context);
}
var _temp13 = _catch(function () {
return Promise.resolve(renderContent(context, isEditMode, params, requestContext)).then(function (muraObject) {
if (typeof muraObject != 'undefined' && typeof muraObject.getAll != 'undefined') {
content = muraObject.getAll();
} else {
console.error('Error rendering content', muraObject);
_Mura.renderMode = renderMode;
if (typeof context.res != 'undefined') {
if (typeof muraObject != 'undefined' && typeof muraObject.statusCode != 'undefined') {
context.res.statusCode = muraObject.statusCode;
} else {
context.res.statusCode = 500;
}
}
}
});
}, function (e) {
console.error(e);
});
if (_Mura.renderMode === 'static' && _Mura.isInNode() && process && process.env && process.env.MURA_SSR_BASICTOKEN) {
_Mura.setRequestHeader("Authorization", "Basic " + process.env.MURA_SSR_BASICTOKEN);
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
_Mura.setMode("rest");
_Mura.setAPIEndpoint(_Mura.getAPIEndpoint().replace('/json/', '/rest/'));
}
var _temp18 = function () {
if (typeof onBefore == 'function') {
var _temp19 = _catch(function () {
return Promise.resolve(onBefore(_Mura)).then(function () {});
}, function (e) {
console.log('Error running onBefore event in getMuraProps:', e);
});
if (_temp19 && _temp19.then) return _temp19.then(function () {});
}
}();
return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(_temp17) : _temp17(_temp18));
} catch (e) {

@@ -740,3 +944,4 @@ return Promise.reject(e);

function Decorator(props) {
var Mura = getMura();
var Mura = props.Mura;
Mura.renderMode = Mura.renderMode || 'dynamic';
var muraConfig = getMuraConfig();

@@ -749,3 +954,2 @@ var ComponentRegistry = muraConfig.ComponentRegistry,

children = props.children;
var isEditMode = getIsEditMode();

@@ -769,3 +973,3 @@ var _useState = useState(false),

if (!mounted && isEditMode && typeof props.stylesupport == 'object' && Object.keys(props.stylesupport).length) {
if (!mounted && Mura.renderMode != 'static' && typeof props.stylesupport == 'object' && Object.keys(props.stylesupport).length) {
var _props$stylesupport, _props$stylesupport2, _props$stylesupport3;

@@ -828,2 +1032,3 @@

var isExternalModule = ExternalModules[props.object];
console.log('isExternalModule ' + props.object, isExternalModule);
var objectKey = props.object;

@@ -841,3 +1046,3 @@

if (isEditMode || isExternalModule || !isSSR) {
if (Mura.renderMode != 'static' || isExternalModule || !isSSR) {
Object.keys(props).forEach(function (key) {

@@ -911,3 +1116,3 @@ if (!['queryParams', 'Router', 'Link', 'html', 'content', 'children', 'isEditMode', 'renderMode', 'dynamicProps', 'moduleStyleData', 'regionContext', 'requestContext', 'Mura'].find(function (restrictedkey) {

}, domObject, {
children: [label ? /*#__PURE__*/jsx("eta", {
children: [label ? /*#__PURE__*/jsx(Meta, {
styles: metaStyles,

@@ -979,6 +1184,6 @@ label: label,

section = _ref.section,
isEditMode = _ref.isEditMode;
renderMode = _ref.renderMode;
var out = null;
if (typeof region.name !== 'undefined' && isEditMode) {
if (typeof region.name !== 'undefined' && renderMode != 'static') {
if (section === 'inherited' && region.inherited.items.length) {

@@ -1032,5 +1237,5 @@ out = /*#__PURE__*/jsxs("div", {

context = _ref2.context,
queryParams = _ref2.queryParams;
var isEditMode = getIsEditMode();
var requestContext = getMura().getRequestContext();
queryParams = _ref2.queryParams,
Mura = _ref2.Mura;
Mura.renderMode = Mura.renderMode || 'dynamic';
var inherited = ''; // Mura inheritance, where modules are inherited from parent content

@@ -1041,3 +1246,3 @@

region: region,
isEditMode: isEditMode,
renderMode: Mura.renderMode,
section: "inherited",

@@ -1051,3 +1256,3 @@ children: region.inherited.items.map(function (item) {

obj.regionContext = context;
obj.requestContext = requestContext;
obj.Mura = Mura;
return /*#__PURE__*/jsx(Decorator, _extends({}, obj, {

@@ -1065,3 +1270,3 @@ children: getComponent(obj)

region: region,
isEditMode: isEditMode,
renderMode: Mura.renderMode,
section: "local",

@@ -1075,3 +1280,3 @@ children: region.local.items.map(function (item) {

obj.regionContext = context;
obj.requestContext = requestContext;
obj.Mura = Mura;
return /*#__PURE__*/jsx(Decorator, _extends({}, obj, {

@@ -1133,5 +1338,6 @@ children: getComponent(obj)

function Styles(props) {
var moduleStyleData = props.moduleStyleData;
var moduleStyleData = props.moduleStyleData,
Mura = props.Mura;
if (!getIsEditMode() && typeof moduleStyleData !== 'undefined') {
if (Mura.renderMode === 'static' && typeof moduleStyleData !== 'undefined') {
return /*#__PURE__*/jsx(Fragment, {

@@ -1156,4 +1362,4 @@ children: Object.keys(moduleStyleData).map(function (instanceid) {

var MainLayout = function MainLayout(props) {
var Mura = getMura();
var content = props.content,
var Mura = props.Mura,
content = props.content,
moduleStyleData = props.moduleStyleData,

@@ -1260,3 +1466,3 @@ children = props.children;

export { Decorator, DisplayRegion, EditContext, EditLayout, ExternalAssets, MainLayout, MuraContext, MuraJSRefPlaceholder, Styles, getComponent, getHref, getIsEditMode, getMura, getMuraConfig, getMuraPaths, getMuraProps, getRootPath, getSiteName, setIsEditMode, setMuraConfig, useAsync };
export { Decorator, DisplayRegion, EditContext, EditLayout, ExternalAssets, MainLayout, MuraContext, MuraJSRefPlaceholder, Styles, getComponent, getHref, getIsEditMode, getMura, getMuraConfig, getMuraInstance, getMuraPaths, getMuraProps, getRootPath, getSiteName, setIsEditMode, setMuraConfig, useAsync };
//# sourceMappingURL=index.modern.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('mura.js'), require('mura.js/src/core/stylemap-static'), require('react/jsx-runtime')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'mura.js', 'mura.js/src/core/stylemap-static', 'react/jsx-runtime'], factory) :
(global = global || self, factory(global.nextCore = {}, global.react, global.Mura, global.styleMap, global.jsx));
})(this, (function (exports, react, Mura, styleMap, jsxRuntime) {
(global = global || self, factory(global.nextCore = {}, global.react, global.Mura$1, global.styleMap, global.jsx));
})(this, (function (exports, react, Mura$1, styleMap, jsxRuntime) {
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var Mura__default = /*#__PURE__*/_interopDefaultLegacy(Mura);
var Mura__default = /*#__PURE__*/_interopDefaultLegacy(Mura$1);
var styleMap__default = /*#__PURE__*/_interopDefaultLegacy(styleMap);
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {

@@ -25,5 +25,10 @@ var source = arguments[i];

};
return _extends.apply(this, arguments);
}
Mura__default["default"].styleMap = styleMap__default["default"];
var _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
function _settle(pact, state, value) {

@@ -59,88 +64,2 @@ if (!pact.s) {

var getModuleProps = function getModuleProps(item, moduleStyleData, isEditMode, content, queryParams, requestContext) {
try {
var _temp29 = function _temp29() {
if (isEditMode || !Mura__default["default"].isInNode()) {
return {
cssRules: []
};
} else {
var styleData = Mura__default["default"].recordModuleStyles(item);
delete styleData.deleteRule;
delete styleData.insertRule;
return styleData;
}
};
getMura();
var _temp30 = _catch(function () {
var objectkey = item.object;
if (typeof ComponentRegistry[objectkey] == 'undefined') {
objectkey = Mura__default["default"].firstToUpperCase(item.object);
}
var _temp26 = function () {
if (typeof ComponentRegistry[objectkey] != 'undefined') {
var _temp31 = function _temp31() {
var _temp23 = function () {
if (item.object == 'container') {
if (typeof item.items != 'undefined' && !Array.isArray(item.items)) {
try {
item.items = JSON.parse(item.items);
} catch (e) {
item.items = [];
}
}
var _temp33 = _forIn(item.items, function (containerIdx) {
var containerItem = item.items[containerIdx];
containerItem.instanceid = containerItem.instanceid || Mura__default["default"].createUUID();
return Promise.resolve(getModuleProps(containerItem, moduleStyleData, isEditMode, content, queryParams, requestContext)).then(function (_getModuleProps3) {
moduleStyleData[containerItem.instanceid] = _getModuleProps3;
});
});
if (_temp33 && _temp33.then) return _temp33.then(function () {});
}
}();
if (_temp23 && _temp23.then) return _temp23.then(function () {});
};
var _temp32 = function () {
if (ComponentRegistry[objectkey].SSR) {
var _temp34 = _catch(function () {
return Promise.resolve(ComponentRegistry[objectkey].getDynamicProps(_extends({}, item, {
content: content,
queryParams: queryParams,
requestContext: requestContext
}))).then(function (_ComponentRegistry$ob) {
item.dynamicProps = _ComponentRegistry$ob;
});
}, function (e) {
console.error('Error getting dynamicProps', e);
item.dynamicProps = {};
});
if (_temp34 && _temp34.then) return _temp34.then(function () {});
}
}();
return _temp32 && _temp32.then ? _temp32.then(_temp31) : _temp31(_temp32);
}
}();
if (_temp26 && _temp26.then) return _temp26.then(function () {});
}, function (e) {
console.error(e);
});
return Promise.resolve(_temp30 && _temp30.then ? _temp30.then(_temp29) : _temp29(_temp30));
} catch (e) {
return Promise.reject(e);
}
};
var _Pact = /*#__PURE__*/function () {

@@ -230,5 +149,164 @@ function _Pact() {}

var getRegionProps = function getRegionProps(content, queryParams, isEditMode, requestContext) {
var getModuleProps = function getModuleProps(item, moduleStyleData, renderMode, content, queryParams, Mura) {
try {
getMura();
var _temp35 = function _temp35() {
if (renderMode == 'dynamic' || !Mura.isInNode()) {
return {
cssRules: []
};
} else {
var styleData = Mura.recordModuleStyles(item);
delete styleData.deleteRule;
delete styleData.insertRule;
return styleData;
}
};
var _temp36 = _catch(function () {
var objectkey = item.object;
if (typeof ComponentRegistry[objectkey] == 'undefined') {
objectkey = Mura.firstToUpperCase(item.object);
}
var _temp32 = function () {
if (typeof ComponentRegistry[objectkey] != 'undefined') {
var _temp37 = function _temp37() {
var _temp29 = function () {
if (item.object == 'container') {
if (typeof item.items != 'undefined' && !Array.isArray(item.items)) {
try {
item.items = JSON.parse(item.items);
} catch (e) {
item.items = [];
}
}
var _temp39 = _forIn(item.items, function (containerIdx) {
var containerItem = item.items[containerIdx];
containerItem.instanceid = containerItem.instanceid || Mura.createUUID();
return Promise.resolve(getModuleProps(containerItem, moduleStyleData, renderMode, content, queryParams, Mura)).then(function (_getModuleProps3) {
moduleStyleData[containerItem.instanceid] = _getModuleProps3;
});
});
if (_temp39 && _temp39.then) return _temp39.then(function () {});
}
}();
if (_temp29 && _temp29.then) return _temp29.then(function () {});
};
var _temp38 = function () {
if (ComponentRegistry[objectkey].SSR) {
var _temp40 = _catch(function () {
return Promise.resolve(ComponentRegistry[objectkey].getDynamicProps(_extends({}, item, {
content: content,
queryParams: queryParams,
Mura: Mura
}))).then(function (_ComponentRegistry$ob) {
item.dynamicProps = _ComponentRegistry$ob;
});
}, function (e) {
console.error('Error getting dynamicProps', e);
item.dynamicProps = {};
});
if (_temp40 && _temp40.then) return _temp40.then(function () {});
}
}();
return _temp38 && _temp38.then ? _temp38.then(_temp37) : _temp37(_temp38);
}
}();
if (_temp32 && _temp32.then) return _temp32.then(function () {});
}, function (e) {
console.error(e);
});
//This is so that the getDynamicProps call has a new getMura()
//Important for server side thread safety
return Promise.resolve(_temp36 && _temp36.then ? _temp36.then(_temp35) : _temp35(_temp36));
} catch (e) {
return Promise.reject(e);
}
};
function _forOf(target, body, check) {
if (typeof target[_iteratorSymbol] === "function") {
var _cycle = function _cycle(result) {
try {
while (!(step = iterator.next()).done && (!check || !check())) {
result = body(step.value);
if (result && result.then) {
if (_isSettledPact(result)) {
result = result.v;
} else {
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
return;
}
}
}
if (pact) {
_settle(pact, 1, result);
} else {
pact = result;
}
} catch (e) {
_settle(pact || (pact = new _Pact()), 2, e);
}
};
var iterator = target[_iteratorSymbol](),
step,
pact,
reject;
_cycle();
if (iterator.return) {
var _fixup = function _fixup(value) {
try {
if (!step.done) {
iterator.return();
}
} catch (e) {}
return value;
};
if (pact && pact.then) {
return pact.then(_fixup, function (e) {
throw _fixup(e);
});
}
_fixup();
}
return pact;
} // No support for Symbol.iterator
if (!("length" in target)) {
throw new TypeError("Object is not iterable");
} // Handle live collections properly
var values = [];
for (var i = 0; i < target.length; i++) {
values.push(target[i]);
}
return _forTo(values, function (i) {
return body(values[i]);
}, check);
}
var getRegionProps = function getRegionProps(content, queryParams, renderMode, Mura) {
try {
var moduleStyleData = {};

@@ -238,8 +316,8 @@ content.displayregions = content.displayregions || {};

var _temp19 = _forIn(regions, function (regionIdx) {
function _temp17() {
var _temp15 = _forIn(region.local.items, function (itemIdx) {
var _temp25 = _forIn(regions, function (regionIdx) {
function _temp23() {
var _temp21 = _forIn(region.local.items, function (itemIdx) {
var item = region.local.items[itemIdx];
item.instanceid = item.instanceid || Mura__default["default"].createUUID();
return Promise.resolve(getModuleProps(item, moduleStyleData, isEditMode, content, queryParams, requestContext)).then(function (_getModuleProps2) {
item.instanceid = item.instanceid || Mura.createUUID();
return Promise.resolve(getModuleProps(item, moduleStyleData, renderMode, content, queryParams, Mura)).then(function (_getModuleProps2) {
moduleStyleData[item.instanceid] = _getModuleProps2;

@@ -249,3 +327,3 @@ });

if (_temp15 && _temp15.then) return _temp15.then(function () {});
if (_temp21 && _temp21.then) return _temp21.then(function () {});
}

@@ -255,8 +333,8 @@

var _temp16 = function () {
var _temp22 = function () {
if (typeof region.inherited != 'undefined' && Array.isArray(region.inherited.items)) {
var _temp20 = _forIn(region.inherited.items, function (itemdIx) {
var _temp26 = _forIn(region.inherited.items, function (itemdIx) {
var item = region.inherited.items[itemdIx];
item.instanceid = item.instanceid || Mura__default["default"].createUUID();
return Promise.resolve(getModuleProps(item, moduleStyleData, isEditMode, content, queryParams, requestContext)).then(function (_getModuleProps) {
item.instanceid = item.instanceid || Mura.createUUID();
return Promise.resolve(getModuleProps(item, moduleStyleData, renderMode, content, queryParams, Mura)).then(function (_getModuleProps) {
moduleStyleData[item.instanceid] = _getModuleProps;

@@ -266,10 +344,10 @@ });

if (_temp20 && _temp20.then) return _temp20.then(function () {});
if (_temp26 && _temp26.then) return _temp26.then(function () {});
}
}();
return _temp16 && _temp16.then ? _temp16.then(_temp17) : _temp17(_temp16);
return _temp22 && _temp22.then ? _temp22.then(_temp23) : _temp23(_temp22);
});
return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {
return Promise.resolve(_temp25 && _temp25.then ? _temp25.then(function () {
return moduleStyleData;

@@ -296,3 +374,3 @@ }) : moduleStyleData);

var renderContent = function renderContent(context, isEditMode, params, requestContext) {
var renderContent = function renderContent(context, renderMode, params, Mura) {
try {

@@ -302,3 +380,3 @@ var query = {};

if (context.browser) {
query = Mura__default["default"].getQueryStringParams();
query = Mura.getQueryStringParams();
} else if (context.query) {

@@ -308,6 +386,3 @@ query = _extends({}, context.query);

if (isEditMode) {
query.isEditRoute = isEditMode;
}
query.renderMode = renderMode;
var filename = '';

@@ -317,3 +392,7 @@

if (Array.isArray(query.page)) {
filename = query.page[query.page.length - 1].split("/");
if (query.page[query.page.length - 1].indexOf('/') == -1) {
filename = query.page[query.page.length - 1].split("/");
} else {
filename = query.page;
}
} else {

@@ -339,6 +418,5 @@ filename = query.page.split("/");

query = Object.assign(query, params);
} //console.log('request params',filename, query);
}
return Promise.resolve(requestContext.renderFilename(filename, query).then(function (rendered) {
return Promise.resolve(Mura.renderFilename(filename, query).then(function (rendered) {
return Promise.resolve(rendered);

@@ -365,9 +443,11 @@ }, function (rendered) {

Mura__default["default"].styleMap = styleMap__default["default"];
var MuraClass = Object.create(Mura__default["default"]);
var muraConfig, connectorConfig, ComponentRegistry, ConnectorConfig, ExternalModules;
var isEditMode = false;
var MuraJSRefPlaceholder = '"undefined"!=typeof window&&function(u){u.queuedMuraCmds=[],u.queuedMuraPreInitCmds=[],"function"!=typeof u.Mura&&(u.Mura=u.mura=u.Mura=function(e){u.queuedMuraCmds.push(e)},u.Mura.preInit=function(e){u.queuedMuraPreInitCmds.push(e)})}(window);';
var MuraJSRefPlaceholder = '"undefined"!=typeof window&&function(u){u.queuedMuraCmds=[],u.queuedMuraPreInitCmds=[],"function"!=typeof u.Mura&&(u.Mura=u.mura=u.Mura=function(e){u.queuedMuraCmds.push(e)},u.Mura.preInit=function(e){u.queuedMuraPreInitCmds.push(e)})}(window);'; //deprecated
var setIsEditMode = function setIsEditMode(value) {
isEditMode = value;
};
}; //deprecated
var getIsEditMode = function getIsEditMode() {

@@ -398,3 +478,4 @@ return isEditMode;

}, [asyncFn, onSuccess]);
};
}; //Needs to account for thread safe Mura instance
var getHref = function getHref(filename) {

@@ -407,5 +488,5 @@ var path = filename.split('/').filter(function (item) {

if (path.length) {
return '/' + Mura__default["default"].siteid + '/' + path.join('/') + '/';
return '/' + Mura.siteid + '/' + path.join('/') + '/';
} else {
return '/' + Mura__default["default"].siteid + '/';
return '/' + Mura.siteid + '/';
}

@@ -420,8 +501,8 @@ } else {

};
var getComponent = function getComponent(item) {
getMura();
var objectkey = item.object;
var getComponent = function getComponent(props) {
var Mura = props.Mura;
var objectkey = props.object;
if (typeof ComponentRegistry[objectkey] == 'undefined') {
objectkey = Mura__default["default"].firstToUpperCase(item.object);
objectkey = Mura.firstToUpperCase(props.object);
}

@@ -431,8 +512,8 @@

var ComponentVariable = ComponentRegistry[objectkey].component;
return /*#__PURE__*/jsxRuntime.jsx(ComponentVariable, _extends({}, item), item.instanceid);
return /*#__PURE__*/jsxRuntime.jsx(ComponentVariable, _extends({}, props), props.instanceid);
}
return /*#__PURE__*/jsxRuntime.jsxs("p", {
children: ["DisplayRegion: ", item.objectname]
}, item.instanceid);
children: ["DisplayRegion: ", props.objectname]
}, props.instanceid);
};

@@ -442,3 +523,3 @@ var getMuraPaths = function getMuraPaths() {

var _temp3 = function _temp3() {
var paths = pathList.map(function (item) {
return pathList.map(function (item) {
var page = [];

@@ -460,3 +541,2 @@

});
return paths;
};

@@ -471,5 +551,5 @@

var _temp4 = _forTo(siteids, function (index) {
getMura(siteids[index]);
return Promise.resolve(Mura__default["default"].getFeed('content').maxItems(0).itemsPerPage(0).sort('orderno').where().prop('type').isNotIn('File,Link,Calendar').getQuery({
var _temp4 = _forOf(siteids, function (siteid) {
var Mura = getMuraInstance(siteid);
return Promise.resolve(Mura.getFeed('content').maxItems(0).itemsPerPage(0).sort('orderno').where().prop('type').isNotIn('File,Link,Calendar').getQuery({
renderMode: 'static'

@@ -490,5 +570,88 @@ })).then(function (items) {

};
var getMuraInstance = function getMuraInstance(context) {
//If not in node, just return the global instance;
var isInNode = !(typeof process !== 'undefined' && {}.toString.call(process) === '[object process]' || typeof document == 'undefined');
if (isInNode) {
return getMura(context);
}
var startingsiteid = '';
var Mura = Object.create(MuraClass);
var instanceConfig = Object.assign({}, ConnectorConfig);
if (typeof Mura.deInit == 'function') {
try {
Mura.deInit();
} catch (e) {}
}
if (typeof context == 'string' && instanceConfig.siteid.find(function (item) {
return item === context;
})) {
instanceConfig.siteid = context;
} else {
var ishomepage = context && !(context.params && context.params.page) || typeof location != 'undefined' && (location.pathname == "/" || location.pathname == ConnectorConfig.editroute + "/");
if (Array.isArray(ConnectorConfig.siteid)) {
if (ishomepage) {
instanceConfig.siteid = ConnectorConfig.siteid[0];
} else {
var page = [];
if (context && context.params && context.params.page) {
page = [].concat(context.params.page);
page = page.filter(function (item) {
return item.length;
});
} else if (typeof location != 'undefined') {
page = location.pathname.split("/");
page = page.filter(function (item) {
return item.length;
});
if (page.length && ConnectorConfig.editroute && page[0] === ConnectorConfig.editroute.split("/")[1]) {
page.shift();
}
}
if (page.length) {
if (ConnectorConfig.siteid.find(function (item) {
return item === page[0];
})) {
instanceConfig.siteid = page[0];
instanceConfig.siteidinurls = true;
} else {
instanceConfig.siteid = ConnectorConfig.siteid[0];
}
}
}
}
}
if (context && context.res) {
Object.assign(instanceConfig, {
response: context.res,
request: context.req
}); //console.log('initing', connectorConfig.siteid)
Mura.init(instanceConfig);
} else if (startingsiteid != instanceConfig.siteid) {
//console.log('changing siteid',startingsiteid,connectorConfig.siteid)
Mura.init(instanceConfig);
}
Mura.holdReady(true);
return Mura;
}; //get global Mura instances for browser
var getMura = function getMura(context) {
var startingsiteid = Mura__default["default"].siteid;
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]' || typeof document == 'undefined') {
return getMuraInstance(context);
}
var Mura = Mura__default["default"];
var startingsiteid = Mura.siteid;
if (typeof context == 'string' && ConnectorConfig.siteid.find(function (item) {

@@ -540,4 +703,4 @@ return item === context;

delete connectorConfig.apiendpoint;
delete Mura__default["default"].apiEndpoint;
delete Mura__default["default"].apiendpoint;
delete Mura.apiEndpoint;
delete Mura.apiendpoint;
};

@@ -552,184 +715,225 @@

Mura__default["default"].init(connectorConfig);
Mura.init(connectorConfig);
} else if (startingsiteid != connectorConfig.siteid) {
//console.log('changing siteid',startingsiteid,connectorConfig.siteid)
clearMuraAPICache();
Mura__default["default"].init(connectorConfig);
Mura.init(connectorConfig);
}
Mura__default["default"].holdReady(true);
return Mura__default["default"];
};
Mura.holdReady(true);
return Mura;
}; //Deprecated
var getRootPath = function getRootPath() {
return getMura().rootpath;
};
}; //Deprecated
var getSiteName = function getSiteName() {
return getMura().sitename;
};
var getMuraProps = function getMuraProps(context, isEditMode, params, callback) {
var getMuraProps = function getMuraProps(context, isEditMode, params) {
try {
var _content;
var _temp17 = function _temp17() {
function _temp13() {
if (content.filename == '404') {
if (typeof context.params != 'undefined') {
console.error('404 rendering content', context.params);
}
var _temp12 = function _temp12() {
if (content.filename == '404') {
if (typeof context.params != 'undefined') {
console.error('404 rendering content', context.params);
if (typeof context.res != 'undefined') {
context.res.statusCode = 404;
}
}
if (typeof context.res != 'undefined') {
if (typeof content.isondisplay != 'undefined' && !content.isondisplay) {
context.res.statusCode = 404;
}
}
} else {
if (content.redirect) {
//match casing of nodeProxyRedirectCasing in mura.js
context.res.setHeader('Location', content.redirect);
if (typeof content.isondisplay != 'undefined' && !content.isondisplay) {
context.res.statusCode = 404;
} else {
if (content.redirect) {
//match casing of nodeProxyRedirectCasing in mura.js
context.res.setHeader('Location', content.redirect);
if (content.statuscode) {
context.res.statusCode = content.statuscode;
} else {
context.res.statusCode = 301;
}
if (content.statuscode) {
context.res.statusCode = content.statuscode;
} else {
context.res.statusCode = 301;
if (context.res.statusCode != 301) {
context.res.setHeader('Cache-Control', 'no-cache, no-store');
context.res.setHeader('Expires', 'Mon, 01 Jan 1990 00:00:00 GMT');
}
}
if (context.res.statusCode != 301) {
context.res.setHeader('Cache-Control', 'no-cache, no-store');
context.res.setHeader('Expires', 'Mon, 01 Jan 1990 00:00:00 GMT');
}
}
}
var queryParams = {};
var queryParams = {};
if (context.browser) {
queryParams = Mura__default["default"].getQueryStringParams();
} else if (context.query) {
queryParams = _extends({}, context.query);
}
if (context.browser) {
queryParams = _Mura.getQueryStringParams();
} else if (context.query) {
queryParams = _extends({}, context.query);
}
return Promise.resolve(getRegionProps(content, queryParams, isEditMode, requestContext)).then(function (moduleStyleData) {
function _temp9() {
function _temp7() {
if (Mura__default["default"].isInNode() && (typeof callback == 'undefined' || typeof callback == 'boolean' && callback)) {
Mura__default["default"].deInit();
return Promise.resolve(getRegionProps(content, queryParams, renderMode, _Mura)).then(function (moduleStyleData) {
function _temp11() {
function _temp9() {
if (renderMode == 'dynamic') {
return {
props: props
};
} else {
return {
props: props,
revalidate: 1
};
}
}
if (isEditMode) {
return {
props: props
};
} else {
return {
props: props,
revalidate: 1
};
}
var props = {
content: content,
moduleStyleData: moduleStyleData,
externalModules: ExternalModules,
codeblocks: codeblocks,
queryParams: queryParams,
renderMode: renderMode
};
var _temp8 = function () {
if (typeof onAfter == 'function') {
var _temp16 = _catch(function () {
return Promise.resolve(onAfter(props, _Mura)).then(function () {});
}, function (e) {
console.log('Error running onAfter event in getMuraProps:', e);
});
if (_temp16 && _temp16.then) return _temp16.then(function () {});
}
}();
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
}
var props = {
content: content,
moduleStyleData: moduleStyleData,
externalModules: ExternalModules,
codeblocks: codeblocks,
queryParams: queryParams
var codeblocks = {
header: [],
bodystart: [],
footer: []
};
var _temp6 = function () {
if (typeof callback == 'function') {
return Promise.resolve(callback(callback)).then(function () {});
}
}();
var _temp10 = _catch(function () {
var _temp6 = function () {
if (connectorConfig.codeblocks && (context.res || context.browser) && !(queryParams.codeblocks && queryParams.codeblocks === "false")) {
return Promise.resolve(_Mura.getFeed('codeblock').where().prop('active').isEQ(1).getQuery()).then(function (codeCollection) {
codeCollection.forEach(function (item) {
var placement = item.get('placement').toLowerCase();
return _temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6);
}
if (placement == 'header') {
codeblocks.header.push(item.get('code'));
} else if (placement == 'footer') {
codeblocks.footer.push(item.get('code'));
} else if (placement == 'bodystart') {
codeblocks.bodystart.push(item.get('code'));
}
});
});
}
}();
var codeblocks = {
header: [],
bodystart: [],
footer: []
};
if (_temp6 && _temp6.then) return _temp6.then(function () {});
}, function (e) {
console.error(e);
});
var _temp8 = _catch(function () {
var _temp5 = function () {
if (connectorConfig.codeblocks && (context.res || context.browser) && !(queryParams.codeblocks && queryParams.codeblocks === "false")) {
return Promise.resolve(requestContext.getFeed('codeblock').where().prop('active').isEQ(1).getQuery()).then(function (codeCollection) {
codeCollection.forEach(function (item) {
var placement = item.get('placement').toLowerCase();
return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
});
}
if (placement == 'header') {
codeblocks.header.push(item.get('code'));
} else if (placement == 'footer') {
codeblocks.footer.push(item.get('code'));
} else if (placement == 'bodystart') {
codeblocks.bodystart.push(item.get('code'));
}
});
});
var content = {
title: "We're sorry, an error occurred",
menutitle: "We're sorry, an error occurred",
body: "",
isnew: 1,
siteid: _Mura.siteid,
type: 'Page',
subtype: 'Default',
contentid: _Mura.createUUID(),
contenthistid: _Mura.createUUID(),
filename: "500",
statusCode: 500,
errors: [],
displayregions: {
primarycontent: {
local: {
items: []
}
}();
}
}
};
if (_temp5 && _temp5.then) return _temp5.then(function () {});
}, function (e) {
console.error(e);
var _temp12 = _catch(function () {
return Promise.resolve(renderContent(context, renderMode, params, _Mura)).then(function (muraObject) {
if (typeof muraObject != 'undefined' && typeof muraObject.getAll != 'undefined') {
content = muraObject.getAll();
} else {
console.error('Error rendering content', muraObject);
if (typeof context.res != 'undefined') {
if (typeof muraObject != 'undefined' && typeof muraObject.statusCode != 'undefined') {
context.res.statusCode = muraObject.statusCode;
} else {
context.res.statusCode = 500;
}
}
}
});
}, function (e) {
console.error(e);
});
return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
});
return _temp12 && _temp12.then ? _temp12.then(_temp13) : _temp13(_temp12);
};
getMura(context);
setIsEditMode(isEditMode);
Mura__default["default"].renderMode = 'dynamic';
var _Mura;
if (!isEditMode) {
Mura__default["default"].renderMode = 'static';
var renderMode = 'dynamic';
if (Mura__default["default"].isInNode() && process && process.env && process.env.MURA_SSR_BASICTOKEN) {
Mura__default["default"].setRequestHeader("Authorization", "Basic " + process.env.MURA_SSR_BASICTOKEN);
Mura__default["default"].setMode("rest");
Mura__default["default"].setAPIEndpoint(Mura__default["default"].getAPIEndpoint().replace('/json/', '/rest/'));
if (typeof context === 'object' && context.context) {
params = context.params || {};
renderMode = typeof context.renderMode == 'undefined' ? 'dynamic' : context.renderMode;
if (typeof context.context === 'object') {
context = context.context;
}
}
var requestContext = Mura__default["default"].getRequestContext();
var content = (_content = {
title: "We're sorry, an error occurred",
menutitle: "We're sorry, an error occurred",
body: "",
contentid: Mura__default["default"].createUUID(),
isnew: 1,
siteid: Mura__default["default"].siteid,
type: 'Page',
subtype: 'Default'
}, _content["contentid"] = Mura__default["default"].createUUID(), _content.contenthistid = Mura__default["default"].createUUID(), _content.filename = "500", _content.statusCode = 500, _content.errors = [], _content.displayregions = {
primarycontent: {
local: {
items: []
}
if (typeof context.Mura != 'undefined') {
_Mura = context.Mura;
} else {
_Mura = getMura(context);
}
}, _content);
} else {
renderMode = typeof isEditMode == 'undefined' || isEditMode ? 'dynamic' : 'static';
_Mura = getMura(context);
}
var _temp13 = _catch(function () {
return Promise.resolve(renderContent(context, isEditMode, params, requestContext)).then(function (muraObject) {
if (typeof muraObject != 'undefined' && typeof muraObject.getAll != 'undefined') {
content = muraObject.getAll();
} else {
console.error('Error rendering content', muraObject);
_Mura.renderMode = renderMode;
if (typeof context.res != 'undefined') {
if (typeof muraObject != 'undefined' && typeof muraObject.statusCode != 'undefined') {
context.res.statusCode = muraObject.statusCode;
} else {
context.res.statusCode = 500;
}
}
}
});
}, function (e) {
console.error(e);
});
if (_Mura.renderMode === 'static' && _Mura.isInNode() && process && process.env && process.env.MURA_SSR_BASICTOKEN) {
_Mura.setRequestHeader("Authorization", "Basic " + process.env.MURA_SSR_BASICTOKEN);
return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
_Mura.setMode("rest");
_Mura.setAPIEndpoint(_Mura.getAPIEndpoint().replace('/json/', '/rest/'));
}
var _temp18 = function () {
if (typeof onBefore == 'function') {
var _temp19 = _catch(function () {
return Promise.resolve(onBefore(_Mura)).then(function () {});
}, function (e) {
console.log('Error running onBefore event in getMuraProps:', e);
});
if (_temp19 && _temp19.then) return _temp19.then(function () {});
}
}();
return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(_temp17) : _temp17(_temp18));
} catch (e) {

@@ -741,3 +945,4 @@ return Promise.reject(e);

function Decorator(props) {
var Mura = getMura();
var Mura = props.Mura;
Mura.renderMode = Mura.renderMode || 'dynamic';
var muraConfig = getMuraConfig();

@@ -750,3 +955,2 @@ var ComponentRegistry = muraConfig.ComponentRegistry,

children = props.children;
var isEditMode = getIsEditMode();

@@ -770,3 +974,3 @@ var _useState = react.useState(false),

if (!mounted && isEditMode && typeof props.stylesupport == 'object' && Object.keys(props.stylesupport).length) {
if (!mounted && Mura.renderMode != 'static' && typeof props.stylesupport == 'object' && Object.keys(props.stylesupport).length) {
var _props$stylesupport, _props$stylesupport2, _props$stylesupport3;

@@ -829,2 +1033,3 @@

var isExternalModule = ExternalModules[props.object];
console.log('isExternalModule ' + props.object, isExternalModule);
var objectKey = props.object;

@@ -842,3 +1047,3 @@

if (isEditMode || isExternalModule || !isSSR) {
if (Mura.renderMode != 'static' || isExternalModule || !isSSR) {
Object.keys(props).forEach(function (key) {

@@ -912,3 +1117,3 @@ if (!['queryParams', 'Router', 'Link', 'html', 'content', 'children', 'isEditMode', 'renderMode', 'dynamicProps', 'moduleStyleData', 'regionContext', 'requestContext', 'Mura'].find(function (restrictedkey) {

}, domObject, {
children: [label ? /*#__PURE__*/jsxRuntime.jsx("eta", {
children: [label ? /*#__PURE__*/jsxRuntime.jsx(Meta, {
styles: metaStyles,

@@ -980,6 +1185,6 @@ label: label,

section = _ref.section,
isEditMode = _ref.isEditMode;
renderMode = _ref.renderMode;
var out = null;
if (typeof region.name !== 'undefined' && isEditMode) {
if (typeof region.name !== 'undefined' && renderMode != 'static') {
if (section === 'inherited' && region.inherited.items.length) {

@@ -1033,5 +1238,5 @@ out = /*#__PURE__*/jsxRuntime.jsxs("div", {

context = _ref2.context,
queryParams = _ref2.queryParams;
var isEditMode = getIsEditMode();
var requestContext = getMura().getRequestContext();
queryParams = _ref2.queryParams,
Mura = _ref2.Mura;
Mura.renderMode = Mura.renderMode || 'dynamic';
var inherited = ''; // Mura inheritance, where modules are inherited from parent content

@@ -1042,3 +1247,3 @@

region: region,
isEditMode: isEditMode,
renderMode: Mura.renderMode,
section: "inherited",

@@ -1052,3 +1257,3 @@ children: region.inherited.items.map(function (item) {

obj.regionContext = context;
obj.requestContext = requestContext;
obj.Mura = Mura;
return /*#__PURE__*/jsxRuntime.jsx(Decorator, _extends({}, obj, {

@@ -1066,3 +1271,3 @@ children: getComponent(obj)

region: region,
isEditMode: isEditMode,
renderMode: Mura.renderMode,
section: "local",

@@ -1076,3 +1281,3 @@ children: region.local.items.map(function (item) {

obj.regionContext = context;
obj.requestContext = requestContext;
obj.Mura = Mura;
return /*#__PURE__*/jsxRuntime.jsx(Decorator, _extends({}, obj, {

@@ -1134,5 +1339,6 @@ children: getComponent(obj)

function Styles(props) {
var moduleStyleData = props.moduleStyleData;
var moduleStyleData = props.moduleStyleData,
Mura = props.Mura;
if (!getIsEditMode() && typeof moduleStyleData !== 'undefined') {
if (Mura.renderMode === 'static' && typeof moduleStyleData !== 'undefined') {
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {

@@ -1157,4 +1363,4 @@ children: Object.keys(moduleStyleData).map(function (instanceid) {

var MainLayout = function MainLayout(props) {
var Mura = getMura();
var content = props.content,
var Mura = props.Mura,
content = props.content,
moduleStyleData = props.moduleStyleData,

@@ -1172,7 +1378,7 @@ children = props.children;

function contentDidChange(_content) {
var content = Mura__default["default"].getEntity('content').set(_content);
var content = Mura.getEntity('content').set(_content);
getMura();
if (content.get('redirect')) {
if (Mura__default["default"].editroute) {
if (Mura.editroute) {
var pathArray = window.location.pathname.split('/').filter(function (item) {

@@ -1183,3 +1389,3 @@ if (item) {

});
var isEditMode = pathArray.length && '/' + pathArray[0] == Mura__default["default"].editroute; //console.log(isEditMode, pathArray,Mura.editroute, content.get('redirect').indexOf('lockdown'))
var isEditMode = pathArray.length && '/' + pathArray[0] == Mura.editroute; //console.log(isEditMode, pathArray,Mura.editroute, content.get('redirect').indexOf('lockdown'))

@@ -1217,20 +1423,20 @@ /*

Mura__default["default"]('#mura-remote-footer, .mura-cta, [data-transient="true"]').remove();
Mura('#mura-remote-footer, .mura-cta, [data-transient="true"]').remove();
if (typeof Mura__default["default"].deInitLayoutManager !== 'undefined') {
Mura__default["default"].deInitLayoutManager();
if (typeof Mura.deInitLayoutManager !== 'undefined') {
Mura.deInitLayoutManager();
}
Mura__default["default"]('html,body').attr('class', '');
Mura('html,body').attr('class', '');
setTimeout(function () {
// Ensure edit classes are removed
if (typeof MuraInlineEditor === 'undefined') {
Mura__default["default"]('html,body').attr('class', '');
Mura('html,body').attr('class', '');
} // If edit route this will exist
var htmlQueueContainerInner = Mura__default["default"]('#htmlqueues');
var htmlQueueContainerInner = Mura('#htmlqueues');
if (htmlQueueContainerInner.length) {
Mura__default["default"]('#htmlqueues').html(content.get('htmlheadqueue') + content.get('htmlfootqueue'));
Mura('#htmlqueues').html(content.get('htmlheadqueue') + content.get('htmlfootqueue'));
}

@@ -1243,3 +1449,3 @@ /*

Mura__default["default"].init(Mura__default["default"].extend({
Mura.init(Mura.extend({
processMarkup: true,

@@ -1249,13 +1455,13 @@ queueObjects: false,

}));
Mura__default["default"].holdReady(false); //This will happen on static route (IE not edit route)
Mura.holdReady(false); //This will happen on static route (IE not edit route)
if (!htmlQueueContainerInner.length && Mura__default["default"].variations) {
Mura__default["default"].loader().loadjs(Mura__default["default"].rootpath + "/core/modules/v1/core_assets/js/variation.js?siteid=" + Mura__default["default"].siteid + '&cacheid=' + Math.random());
if (!htmlQueueContainerInner.length && Mura.variations) {
Mura.loader().loadjs(Mura.rootpath + "/core/modules/v1/core_assets/js/variation.js?siteid=" + Mura.siteid + '&cacheid=' + Math.random());
}
if (Mura__default["default"].MXP) {
if (Mura__default["default"].MXPTracking === 'basic') {
Mura__default["default"].loader().loadjs(Mura__default["default"].rootpath + "/plugins/MXP/remote/basic/?siteid=" + Mura__default["default"].siteid + "&contenthistid=" + Mura__default["default"].contenthistid + "&contentid=" + Mura__default["default"].contentid + "&cacheid=" + Math.random());
if (Mura.MXP) {
if (Mura.MXPTracking === 'basic') {
Mura.loader().loadjs(Mura.rootpath + "/plugins/MXP/remote/basic/?siteid=" + Mura.siteid + "&contenthistid=" + Mura.contenthistid + "&contentid=" + Mura.contentid + "&cacheid=" + Math.random());
} else {
Mura__default["default"].loader().loadjs(Mura__default["default"].rootpath + "/plugins/MXP/remote/native/?siteid=" + Mura__default["default"].siteid + "&contenthistid=" + Mura__default["default"].contenthistid + "&contentid=" + Mura__default["default"].contentid + "&cacheid=" + Math.random());
Mura.loader().loadjs(Mura.rootpath + "/plugins/MXP/remote/native/?siteid=" + Mura.siteid + "&contenthistid=" + Mura.contenthistid + "&contentid=" + Mura.contentid + "&cacheid=" + Math.random());
}

@@ -1280,2 +1486,3 @@ }

exports.getMuraConfig = getMuraConfig;
exports.getMuraInstance = getMuraInstance;
exports.getMuraPaths = getMuraPaths;

@@ -1282,0 +1489,0 @@ exports.getMuraProps = getMuraProps;

{
"name": "@murasoftware/next-core",
"version": "1.0.98",
"version": "2.0.1",
"description": "Core utilties for Mura.js and Next.js",

@@ -19,3 +19,3 @@ "author": "Mura Software",

"peerDependencies": {
"mura.js": ">=1.0.379",
"mura.js": "^1.0.379",
"react": ">=17.0.1",

@@ -45,5 +45,5 @@ "react-dom": ">=17.0.1"

},
"overrides" :{
"nth-check":"2.0.1",
"postcss":"7.0.36"
"overrides": {
"nth-check": "2.0.1",
"postcss": "7.0.36"
},

@@ -50,0 +50,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc