@sitecore-jss/sitecore-jss
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -1,1 +0,1 @@ | ||
'use strict';var _extends=Object.assign||function(a){for(var c,b=1;b<arguments.length;b++)for(var d in c=arguments[b],c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d]);return a};Object.defineProperty(exports,'__esModule',{value:!0}),exports.fetchItemData=exports.fetchPlaceholderData=exports.fetchRouteData=void 0;require('isomorphic-fetch');var _=require('./');function _objectWithoutProperties(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}var getJsonErrorMessage=function(a){var b=(0,_.tryParseJson)(a);if(!b)return null;var c;return b.Message&&(c=b.Message+' '),b.ModelState&&Object.keys(b.ModelState).forEach(function(d){c=''+c+b.ModelState[d]+' '}),c},checkStatus=function(a){return 200<=a.status&&300>a.status?a:a.text().then(function(b){var c=getJsonErrorMessage(b);c||(c=b||a.statusText);var d=new Error(c||b||a.statusText);throw d.response=a,d})},getQueryString=function(a){return Object.keys(a).map(function(b){return encodeURIComponent(b)+'='+encodeURIComponent(a[b])}).join('&')},fetchData=function(a,b,c){var d=Object.assign({},c,{credentials:'include'}),e=getQueryString(b),f=-1===a.indexOf('?')?a+'?'+e:a+'&'+e;return fetch(f,d).then(checkStatus).then(function(g){return g.json()})},fetchRouteData=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=b.host,d=b.params,e=_objectWithoutProperties(b,['host','params']);return fetchData(c+'/sc-layout',_extends({route:a},d),e).then(function(f){return(0,_.convertRouteData)(f)})};exports.fetchRouteData=fetchRouteData;var fetchPlaceholderData=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=c.host,e=c.params,f=_objectWithoutProperties(c,['host','params']);return fetchData(d+'/sc-layout/placeholder',_extends({placeholderName:a,route:b},e),f).then(function(g){return(0,_.shapeLayoutData)(g)})};exports.fetchPlaceholderData=fetchPlaceholderData;var fetchItemData=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=b.host,d=b.params,e=_objectWithoutProperties(b,['host','params']);return fetchData(c+'/sc-content',_extends({itemPath:a},d),e)};exports.fetchItemData=fetchItemData; | ||
'use strict';var _extends=Object.assign||function(a){for(var c,b=1;b<arguments.length;b++)for(var d in c=arguments[b],c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d]);return a};Object.defineProperty(exports,'__esModule',{value:!0}),exports.fetchItemData=exports.fetchPlaceholderData=exports.fetchRouteData=void 0;require('isomorphic-fetch');var _=require('./');function _objectWithoutProperties(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}var getJsonErrorMessage=function(a){var b=(0,_.tryParseJson)(a);if(!b)return null;var c;return b.Message&&(c=b.Message+' '),b.ModelState&&Object.keys(b.ModelState).forEach(function(d){c=''+c+b.ModelState[d]+' '}),c},checkStatus=function(a){return 200<=a.status&&300>a.status?a:a.text().then(function(b){var c=getJsonErrorMessage(b);c||(c=b||a.statusText);var d=new Error(c||b||a.statusText);throw d.response=a,d})},getQueryString=function(a){return Object.keys(a).map(function(b){return encodeURIComponent(b)+'='+encodeURIComponent(a[b])}).join('&')},fetchData=function(a,b,c){var d=Object.assign({},c,{credentials:'include'}),e=getQueryString(b),f=-1===a.indexOf('?')?a+'?'+e:a+'&'+e;return fetch(f,d).then(checkStatus).then(function(g){return g.json()})},fetchRouteData=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=b.host,d=b.params,e=_objectWithoutProperties(b,['host','params']);return fetchData(c+'/sitecore/layoutsvc/render/jss',_extends({item:a},d),e).then(function(f){return(0,_.shapeLayoutData)(f)})};exports.fetchRouteData=fetchRouteData;var fetchPlaceholderData=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=c.host,e=c.params,f=_objectWithoutProperties(c,['host','params']);return fetchData(d+'/sitecore/layoutsvc/placeholder/jss',_extends({placeholderName:a,item:b},e),f).then(function(g){return(0,_.convertPlaceholderData)(g,a,b)})};exports.fetchPlaceholderData=fetchPlaceholderData;var fetchItemData=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=b.host,d=b.params,e=_objectWithoutProperties(b,['host','params']);return fetchData(c+'/sc-content',_extends({itemPath:a},d),e)};exports.fetchItemData=fetchItemData; |
@@ -1,1 +0,1 @@ | ||
'use strict';var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},_flatLayoutToNested=require('./flatLayoutToNested'),_dataApi2=require('./dataApi'),_dataApi=_interopRequireWildcard(_dataApi2);Object.defineProperty(exports,'__esModule',{value:!0}),exports.dataApi=exports.getDynamicPlaceholderKey=exports.makePath=exports.isServer=exports.getCookieValue=exports.shapeLayoutData=exports.convertRouteData=exports.isPrimitive=exports.tryParseJson=exports.isJson=void 0;function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}function _objectWithoutProperties(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}var isJson=exports.isJson=function(a){try{JSON.parse(a)}catch(b){return!1}return!0},tryParseJson=exports.tryParseJson=function(a){try{var b=JSON.parse(a);if(b&&'object'===('undefined'==typeof b?'undefined':_typeof(b))&&null!==b)return b}catch(b){console.error(b)}return!1},isPrimitive=exports.isPrimitive=function(a){var b='undefined'==typeof a?'undefined':_typeof(a);return null===a||'object'!==b&&'function'!==b},convertRouteData=exports.convertRouteData=function(a){return(0,_flatLayoutToNested.convertToNestedLayout)(shapeLayoutData(a))},shapeLayoutData=function(a){var b=a.name,c=a.displayName,d=a.placeholders,f=a.fields,g=_objectWithoutProperties(a,['name','displayName','placeholders','fields']);return{sitecore:{context:g,route:{name:b,displayName:c,placeholders:d,fields:f}}}};exports.shapeLayoutData=shapeLayoutData;var getCookieValue=exports.getCookieValue=function(a,b){var c='',d=0,f=0;return 0<b.length&&(d=b.indexOf(a+'='),-1!==d&&(d+=a.length+1,f=b.indexOf(';',d),-1===f&&(f=b.length),c=unescape(b.substring(d,f)))),c},isServer=exports.isServer=function(){return!('undefined'!=typeof window&&window.document)},makePath=exports.makePath=function(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];var f=[];c.forEach(function(h){var j=h?h.split(a).filter(function(k){return k}):[];j.length&&(f=f.concat(j))});var g=f.join(a);return c[0]&&0===c[0].indexOf(a)&&(g=''+a+g),g},getDynamicPlaceholderKey=exports.getDynamicPlaceholderKey=function(a,b,c){if(b&&b.uid){var d=formatGuid(b.uid);return makePath('/',a,c+'_'+d)}return makePath('/',a,c)},formatGuid=function(a){return a=a.replace('{','').replace('}',''),a.toUpperCase()};exports.dataApi=_dataApi; | ||
'use strict';var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},_dynamicPlaceholders=require('./dynamicPlaceholders');Object.defineProperty(exports,'__esModule',{value:!0}),exports.getDynamicPlaceholderKey=exports.dataApi=exports.resetExperienceEditorChromes=exports.isExperienceEditorActive=exports.convertPlaceholderData=exports.isServer=exports.getCookieValue=exports.shapeLayoutData=exports.isPrimitive=exports.tryParseJson=exports.isJson=void 0;Object.defineProperty(exports,'getDynamicPlaceholderKey',{enumerable:!0,get:function get(){return _dynamicPlaceholders.getDynamicPlaceholderKey}});var _dataApi2=require('./dataApi'),_dataApi=_interopRequireWildcard(_dataApi2);function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b.default=a,b}var isJson=exports.isJson=function(a){try{JSON.parse(a)}catch(b){return!1}return!0},tryParseJson=exports.tryParseJson=function(a){try{var b=JSON.parse(a);if(b&&'object'===('undefined'==typeof b?'undefined':_typeof(b))&&null!==b)return b}catch(b){console.error(b)}return!1},isPrimitive=exports.isPrimitive=function(a){var b='undefined'==typeof a?'undefined':_typeof(a);return null===a||'object'!==b&&'function'!==b},shapeLayoutData=exports.shapeLayoutData=function(a){var b=a.name,c=a.displayName,d=a.placeholders,f=a.fields,g=a.context;return{sitecore:{context:g,route:{name:b,displayName:c,placeholders:d,fields:f}}}},getCookieValue=exports.getCookieValue=function(a,b){var c='',d=0,f=0;return 0<b.length&&(d=b.indexOf(a+'='),-1!==d&&(d+=a.length+1,f=b.indexOf(';',d),-1===f&&(f=b.length),c=unescape(b.substring(d,f)))),c},isServer=exports.isServer=function(){return!('undefined'!=typeof window&&window.document)},convertPlaceholderData=exports.convertPlaceholderData=function(a,b,c){return{name:b,route:c,data:a}},isExperienceEditorActive=exports.isExperienceEditorActive=function(){return!!(!isServer()&&window.Sitecore&&window.Sitecore.PageModes&&window.Sitecore.PageModes.ChromeManager)},resetExperienceEditorChromes=exports.resetExperienceEditorChromes=function(){isExperienceEditorActive()&&window.Sitecore.PageModes.ChromeManager.resetChromes()};exports.dataApi=_dataApi; |
{ | ||
"name": "@sitecore-jss/sitecore-jss", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"main": "dist/index.js", | ||
@@ -8,3 +8,3 @@ "scripts": { | ||
"test": "mocha --compilers js:babel-core/register \"./src/**/*.test.js\"", | ||
"prepublish": "npm run build" | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -11,0 +11,0 @@ "author": "Sitecore Corporation", |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3
6198