contentful-app-sdk
Advanced tools
Comparing version 3.30.0 to 3.31.0
@@ -0,1 +1,8 @@ | ||
# [3.31.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.30.0...v3.31.0) (2021-01-13) | ||
### Features | ||
* export module as contentfulApp ([#490](https://github.com/contentful/ui-extensions-sdk/issues/490)) ([0eb5aaa](https://github.com/contentful/ui-extensions-sdk/commit/0eb5aaa425adda39f5f800e64b906694d636b53d)) | ||
# [3.30.0](https://github.com/contentful/ui-extensions-sdk/compare/v3.29.2...v3.30.0) (2021-01-13) | ||
@@ -2,0 +9,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).contentfulExtension={})}(this,(function(e){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)};var n,r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};var i=function(){function e(){this._id=0,this._listeners={}}return e.prototype.dispatch=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r in this._listeners)(e=this._listeners)[r].apply(e,t)},e.prototype.attach=function(e){var t=this;if("function"!=typeof e)throw new Error("listener function expected");var n=this._id++;return this._listeners[n]=e,function(){return delete t._listeners[n]}},e}(),o="__private__memoized__arguments__",a=function(e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=e.call(this)||this;if(i[n]=[],!t.length)throw new Error("Initial value to be memoized expected");return i[o]=t,i}return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,e),r.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this[o]=t,e.prototype.dispatch.apply(this,t)},r.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this[o]),n},r}(i);n=o;var s=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){var n=0;return function(r,i){var o=n++;return t.postMessage({source:e,id:o,method:r,params:i},"*"),o}}(e,t.parent),t.addEventListener("message",(function(e){n._handleMessage(e.data)}))}return e.prototype.call=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._send(e,n);return new Promise((function(e,n){t._responseHandlers[i]={resolve:e,reject:n}}))},e.prototype.send=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this._send(e,t)},e.prototype.addHandler=function(e,t){return e in this._messageHandlers||(this._messageHandlers[e]=new i),this._messageHandlers[e].attach(t)},e.prototype._handleMessage=function(e){if(e.method){var t=e.method,n=e.params,r=this._messageHandlers[t];r&&r.dispatch.apply(r,n)}else{var i=e.id,o=this._responseHandlers[i];if(!o)return;"result"in e?o.resolve(e.result):"error"in e&&o.reject(e.error),delete this._responseHandlers[i]}},e}();var l=function(){function e(e,t){var n=this;this.id=t.id,this.locale=t.locale,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._value=t.value,this._valueSignal=new a(this._value),this._isDisabledSignal=new a(void 0),this._schemaErrorsChangedSignal=new a(void 0),this._channel=e,e.addHandler("valueChanged",(function(e,t,r){e!==n.id||t&&t!==n.locale||(n._value=r,n._valueSignal.dispatch(r))})),e.addHandler("isDisabledChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._isDisabledSignal.dispatch(r)})),e.addHandler("schemaErrorsChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._schemaErrorsChangedSignal.dispatch(r)}))}return e.prototype.getValue=function(){return this._value},e.prototype.setValue=function(e){return this._value=e,this._valueSignal.dispatch(e),this._channel.call("setValue",this.id,this.locale,e)},e.prototype.removeValue=function(){return this._value=void 0,this._channel.call("removeValue",this.id,this.locale)},e.prototype.setInvalid=function(e){return this._channel.call("setInvalid",e,this.locale)},e.prototype.onValueChanged=function(e){return this._valueSignal.attach(e)},e.prototype.onIsDisabledChanged=function(e){return this._isDisabledSignal.attach(e)},e.prototype.onSchemaErrorsChanged=function(e){return this._schemaErrorsChangedSignal.attach(e)},e}(),u=function(){function e(e,t,n){this.id=t.id,this.locales=t.locales,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._defaultLocale=n,this._fieldLocales=t.locales.reduce((function(n,i){var o,a=new l(e,{id:t.id,type:t.type,required:t.required,validations:t.validations,items:t.items,locale:i,value:t.values[i]});return r(r({},n),((o={})[i]=a,o))}),{}),this.assertHasLocale(n)}return e.prototype.getValue=function(e){return this._getFieldLocale(e).getValue()},e.prototype.setValue=function(e,t){return this._getFieldLocale(t).setValue(e)},e.prototype.removeValue=function(e){return this.setValue(void 0,e)},e.prototype.onValueChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onValueChanged(n)},e.prototype.onIsDisabledChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onIsDisabledChanged(n)},e.prototype._getFieldLocale=function(e){return e=e||this._defaultLocale,this.assertHasLocale(e),this._fieldLocales[e]},e.prototype.getForLocale=function(e){if(!e)throw new Error("getForLocale must be passed a locale");return this._getFieldLocale(e)},e.prototype.assertHasLocale=function(e){if(!this._fieldLocales[e])throw new Error('Unknown locale "'+e+'" for field "'+this.id+'"')},e}();function c(e,t){var n,r=e,i=r.document,o=r.MutationObserver,a=function(){u.updateHeight()},s=new o(a),l=!1,u={startAutoResizer:function(){if(u.updateHeight(),l)return;l=!0,s.observe(i.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",a)},stopAutoResizer:function(){if(!l)return;l=!1,s.disconnect(),e.removeEventListener("resize",a)},updateHeight:function(e){void 0===e&&(e=null);null===e&&(e=Math.ceil(i.documentElement.getBoundingClientRect().height));e!==n&&(t.send("setHeight",e),n=e)}};return u}function d(e,t,n,i){var o=t.sys,s=new a(o),l=t.metadata;return e.addHandler("sysChanged",(function(e){o=e,s.dispatch(o)})),r({getSys:function(){return o},onSysChanged:function(e){return s.attach(e)},fields:n.reduce((function(e,t){return e[t.id]=i(t),e}),{})},l?{metadata:l}:{})}var p=["getContentType","getEntry","getEntrySnapshots","getAsset","getEditorInterface","getPublishedEntries","getPublishedAssets","getContentTypes","getEntries","getEditorInterfaces","getAssets","createContentType","createEntry","createAsset","updateContentType","updateEntry","updateAsset","deleteContentType","deleteEntry","deleteAsset","publishEntry","publishAsset","unpublishEntry","unpublishAsset","archiveEntry","archiveAsset","unarchiveEntry","unarchiveAsset","createUpload","processAsset","waitUntilAssetProcessed","getUsers","getAllScheduledActions","getEntityScheduledActions","signRequest"];function f(e,t){var n={};return p.forEach((function(t){n[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.call("callSpaceMethod",t,n)}})),n.getCachedContentTypes=function(){return function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(t)},n}var h=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function v(e,t){return{openAlert:n.bind(null,"alert"),openConfirm:n.bind(null,"confirm"),openPrompt:n.bind(null,"prompt"),openExtension:i,openCurrentApp:o,openCurrent:function(e){return t.app?o(e):i(r(r({},e),{id:t.extension}))},selectSingleEntry:a.bind(null,"Entry",!1),selectSingleAsset:a.bind(null,"Asset",!1),selectMultipleEntries:a.bind(null,"Entry",!0),selectMultipleAssets:a.bind(null,"Asset",!0)};function n(t,n){return e.call("openDialog",t,h(n))}function i(n){if(n=h(n),(n=r(r({},n),{id:n.id||t.extension})).id)return e.call("openDialog","extension",n);throw new Error("Extension ID not provided.")}function o(n){if(n=h(n),t.app){var i=r(r({},n),{id:t.app});return e.call("openDialog","app",i)}throw new Error("Not in the app context.")}function a(t,n,r){return(r=h(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function g(e,t){var n=new a(void 0),r=new a(void 0);return e.addHandler("localeSettingsChanged",(function(e){n.dispatch(e)})),e.addHandler("showDisabledFieldsChanged",(function(e){r.dispatch(e)})),{editorInterface:t,onLocaleSettingsChanged:function(e){return n.attach(e)},onShowDisabledFieldsChanged:function(e){return r.attach(e)}}}function y(e,t){var n=new i;return e.addHandler("navigateSlideIn",(function(e){n.dispatch(e)})),{openEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:t}))},openNewEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:null,contentTypeId:t}))},openBulkEditor:function(t,n){return e.call("navigateToBulkEditor",r({entryId:t},n))},openAsset:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Asset",id:t}))},openNewAsset:function(t){return e.call("navigateToContentEntity",r(r({},t),{entityType:"Asset",id:null}))},openPageExtension:function(n){return e.call("navigateToPage",r({type:"extension",id:t.extension},n))},openCurrentAppPage:function(n){return e.call("navigateToPage",r({type:"app",id:t.app},n))},openAppConfig:function(){return e.call("navigateToAppConfig")},onSlideInNavigation:function(e){return n.attach(e)}}}var _="preInstall",m="postInstall",E=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},A=function(e){return"function"==typeof e},C=function(e){return console.error(e),Promise.resolve(!1)},I=function(e,t,n){if(!A(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return C(e)}var i,o=r;return E(i=o)&&A(i.then)||(o=Promise.resolve(o)),o.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(E(e)?e:t)}),C).catch(C)};function b(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!A(t))throw new Error("Handler must be a function.");n[e]=t};return e.addHandler("appHook",(function(t){var r=t.stage,i=t.installationRequestId,o=t.err;return r===_?I(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:i,result:t})})):r===m?I(n[r],void 0,o||null).then((function(){return e.send("appHookResult",{stage:r,installationRequestId:i})})):Promise.resolve()})),{setReady:function(){return e.call("callAppMethod","setReady")},isInstalled:function(){return e.call("callAppMethod","isInstalled")},getParameters:function(){return e.call("callAppMethod","getParameters")},getCurrentState:function(){return e.call("callAppMethod","getCurrentState")},onConfigure:function(e){r(_,e)},onConfigurationCompleted:function(e){r(m,e)}}}var T,w={LOCATION_ENTRY_FIELD:"entry-field",LOCATION_ENTRY_FIELD_SIDEBAR:"entry-field-sidebar",LOCATION_ENTRY_SIDEBAR:"entry-sidebar",LOCATION_DIALOG:"dialog",LOCATION_ENTRY_EDITOR:"entry-editor",LOCATION_PAGE:"page",LOCATION_APP_CONFIG:"app-config"},L=[S,H,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:new l(e,n)}},D,N],O=((T={})[w.LOCATION_ENTRY_FIELD]=L,T[w.LOCATION_ENTRY_FIELD_SIDEBAR]=L,T[w.LOCATION_ENTRY_SIDEBAR]=[S,H,D,N],T[w.LOCATION_ENTRY_EDITOR]=[S,H,D],T[w.LOCATION_DIALOG]=[S,function(e){return{close:function(t){return e.send("closeDialog",t)}}},N],T[w.LOCATION_PAGE]=[S],T[w.LOCATION_APP_CONFIG]=[S,function(e){return{app:b(e)}}],T);function S(e,t){var n=t.user,r=t.parameters,i=t.locales,o=t.ids,a=t.initialContentTypes,s=t.location||w.LOCATION_ENTRY_FIELD;return{location:{is:function(e){return s===e}},user:n,parameters:r,locales:{available:i.available,default:i.default,names:i.names,fallbacks:i.fallbacks,optional:i.optional,direction:i.direction},space:f(e,a),dialogs:v(e,o),navigator:y(e,o),notifier:{success:function(t){return e.send("notify",{type:"success",message:t})},error:function(t){return e.send("notify",{type:"error",message:t})}},ids:o,access:{can:function(t,n){return e.call("checkAccess",t,n)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function N(e,t,n){return{window:c(n,e)}}function D(e,t){return{editor:g(e,t.editorInterface)}}function H(e,t){var n=t.locales,r=t.contentType,i=t.entry,o=t.fieldInfo;return{contentType:r,entry:d(e,i,o,(function(t){return new u(e,t,n.default)}))}}var P,R,F,x,k=(P=window,R=function(e,t,n){return(O[t.location]||L).reduce((function(i,o){return r(r({},i),o(e,t,n))}),{})},(F={promise:null,resolve:null}).promise=new Promise((function(e){F.resolve=e})),(x=F).promise.then((function(e){var t=e[0],n=P.document;n.addEventListener("focus",(function(){return t.send("setActive",!0)}),!0),n.addEventListener("blur",(function(){return t.send("setActive",!1)}),!0)})),function(e,t){!function(e,t){function n(r){var i=r.data;"connect"===i.method&&(e.removeEventListener("message",n),t.apply(void 0,i.params))}e.addEventListener("message",n)}(e,(function(n,r){var i=new s(n.id,e);t(i,n,r)}))}(P,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return x.resolve(e)})),function(e,t){var n=void 0===t?{supressIframeWarning:!1}:t,r=n.makeCustomApi;n.supressIframeWarning||P.self!==P.top||console.error("Cannot use ui-extension-sdk outside of Contenful:\n\nIn order for the ui-extension-sdk to function correctly, your app needs to be run in an iframe in the Contentful Web App.\n\nLearn more about local development with the ui-extension-sdk here:\n https://www.contentful.com/developers/docs/extensibility/ui-extensions/faq/#how-can-i-use-the-ui-extension-sdk-locally"),x.promise.then((function(t){var n,i=t[0],o=t[1],a=t[2],s=R(i,o,P);"function"==typeof r&&(n=r(i,o)),a.forEach((function(e){i._handleMessage(e)})),e(s,n)}))});e.init=k,e.locations=w,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).contentfulExtension={})}(this,(function(e){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,n)};var n,r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};var i=function(){function e(){this._id=0,this._listeners={}}return e.prototype.dispatch=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r in this._listeners)(e=this._listeners)[r].apply(e,t)},e.prototype.attach=function(e){var t=this;if("function"!=typeof e)throw new Error("listener function expected");var n=this._id++;return this._listeners[n]=e,function(){return delete t._listeners[n]}},e}(),o="__private__memoized__arguments__",a=function(e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=e.call(this)||this;if(i[n]=[],!t.length)throw new Error("Initial value to be memoized expected");return i[o]=t,i}return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,e),r.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this[o]=t,e.prototype.dispatch.apply(this,t)},r.prototype.attach=function(t){var n=e.prototype.attach.call(this,t);return t.apply(void 0,this[o]),n},r}(i);n=o;var s=function(){function e(e,t){var n=this;this._messageHandlers={},this._responseHandlers={},this._send=function(e,t){var n=0;return function(r,i){var o=n++;return t.postMessage({source:e,id:o,method:r,params:i},"*"),o}}(e,t.parent),t.addEventListener("message",(function(e){n._handleMessage(e.data)}))}return e.prototype.call=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._send(e,n);return new Promise((function(e,n){t._responseHandlers[i]={resolve:e,reject:n}}))},e.prototype.send=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this._send(e,t)},e.prototype.addHandler=function(e,t){return e in this._messageHandlers||(this._messageHandlers[e]=new i),this._messageHandlers[e].attach(t)},e.prototype._handleMessage=function(e){if(e.method){var t=e.method,n=e.params,r=this._messageHandlers[t];r&&r.dispatch.apply(r,n)}else{var i=e.id,o=this._responseHandlers[i];if(!o)return;"result"in e?o.resolve(e.result):"error"in e&&o.reject(e.error),delete this._responseHandlers[i]}},e}();var l=function(){function e(e,t){var n=this;this.id=t.id,this.locale=t.locale,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._value=t.value,this._valueSignal=new a(this._value),this._isDisabledSignal=new a(void 0),this._schemaErrorsChangedSignal=new a(void 0),this._channel=e,e.addHandler("valueChanged",(function(e,t,r){e!==n.id||t&&t!==n.locale||(n._value=r,n._valueSignal.dispatch(r))})),e.addHandler("isDisabledChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._isDisabledSignal.dispatch(r)})),e.addHandler("schemaErrorsChangedForFieldLocale",(function(e,t,r){e===n.id&&t===n.locale&&n._schemaErrorsChangedSignal.dispatch(r)}))}return e.prototype.getValue=function(){return this._value},e.prototype.setValue=function(e){return this._value=e,this._valueSignal.dispatch(e),this._channel.call("setValue",this.id,this.locale,e)},e.prototype.removeValue=function(){return this._value=void 0,this._channel.call("removeValue",this.id,this.locale)},e.prototype.setInvalid=function(e){return this._channel.call("setInvalid",e,this.locale)},e.prototype.onValueChanged=function(e){return this._valueSignal.attach(e)},e.prototype.onIsDisabledChanged=function(e){return this._isDisabledSignal.attach(e)},e.prototype.onSchemaErrorsChanged=function(e){return this._schemaErrorsChangedSignal.attach(e)},e}(),u=function(){function e(e,t,n){this.id=t.id,this.locales=t.locales,this.type=t.type,this.required=t.required,this.validations=t.validations,this.items=t.items,this._defaultLocale=n,this._fieldLocales=t.locales.reduce((function(n,i){var o,a=new l(e,{id:t.id,type:t.type,required:t.required,validations:t.validations,items:t.items,locale:i,value:t.values[i]});return r(r({},n),((o={})[i]=a,o))}),{}),this.assertHasLocale(n)}return e.prototype.getValue=function(e){return this._getFieldLocale(e).getValue()},e.prototype.setValue=function(e,t){return this._getFieldLocale(t).setValue(e)},e.prototype.removeValue=function(e){return this.setValue(void 0,e)},e.prototype.onValueChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onValueChanged(n)},e.prototype.onIsDisabledChanged=function(e,t){var n=t||e;return t||(e=""),this._getFieldLocale(e).onIsDisabledChanged(n)},e.prototype._getFieldLocale=function(e){return e=e||this._defaultLocale,this.assertHasLocale(e),this._fieldLocales[e]},e.prototype.getForLocale=function(e){if(!e)throw new Error("getForLocale must be passed a locale");return this._getFieldLocale(e)},e.prototype.assertHasLocale=function(e){if(!this._fieldLocales[e])throw new Error('Unknown locale "'+e+'" for field "'+this.id+'"')},e}();function c(e,t){var n,r=e,i=r.document,o=r.MutationObserver,a=function(){u.updateHeight()},s=new o(a),l=!1,u={startAutoResizer:function(){if(u.updateHeight(),l)return;l=!0,s.observe(i.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),e.addEventListener("resize",a)},stopAutoResizer:function(){if(!l)return;l=!1,s.disconnect(),e.removeEventListener("resize",a)},updateHeight:function(e){void 0===e&&(e=null);null===e&&(e=Math.ceil(i.documentElement.getBoundingClientRect().height));e!==n&&(t.send("setHeight",e),n=e)}};return u}function d(e,t,n,i){var o=t.sys,s=new a(o),l=t.metadata;return e.addHandler("sysChanged",(function(e){o=e,s.dispatch(o)})),r({getSys:function(){return o},onSysChanged:function(e){return s.attach(e)},fields:n.reduce((function(e,t){return e[t.id]=i(t),e}),{})},l?{metadata:l}:{})}var p=["getContentType","getEntry","getEntrySnapshots","getAsset","getEditorInterface","getPublishedEntries","getPublishedAssets","getContentTypes","getEntries","getEditorInterfaces","getAssets","createContentType","createEntry","createAsset","updateContentType","updateEntry","updateAsset","deleteContentType","deleteEntry","deleteAsset","publishEntry","publishAsset","unpublishEntry","unpublishAsset","archiveEntry","archiveAsset","unarchiveEntry","unarchiveAsset","createUpload","processAsset","waitUntilAssetProcessed","getUsers","getAllScheduledActions","getEntityScheduledActions","signRequest"];function f(e,t){var n={};return p.forEach((function(t){n[t]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.call("callSpaceMethod",t,n)}})),n.getCachedContentTypes=function(){return function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(t)},n}var h=function(e){return"object"!=typeof(t=e)||null===t||Array.isArray(t)?{}:e;var t};function v(e,t){return{openAlert:n.bind(null,"alert"),openConfirm:n.bind(null,"confirm"),openPrompt:n.bind(null,"prompt"),openExtension:i,openCurrentApp:o,openCurrent:function(e){return t.app?o(e):i(r(r({},e),{id:t.extension}))},selectSingleEntry:a.bind(null,"Entry",!1),selectSingleAsset:a.bind(null,"Asset",!1),selectMultipleEntries:a.bind(null,"Entry",!0),selectMultipleAssets:a.bind(null,"Asset",!0)};function n(t,n){return e.call("openDialog",t,h(n))}function i(n){if(n=h(n),(n=r(r({},n),{id:n.id||t.extension})).id)return e.call("openDialog","extension",n);throw new Error("Extension ID not provided.")}function o(n){if(n=h(n),t.app){var i=r(r({},n),{id:t.app});return e.call("openDialog","app",i)}throw new Error("Not in the app context.")}function a(t,n,r){return(r=h(r)).entityType=t,r.multiple=n,e.call("openDialog","entitySelector",r)}}function g(e,t){var n=new a(void 0),r=new a(void 0);return e.addHandler("localeSettingsChanged",(function(e){n.dispatch(e)})),e.addHandler("showDisabledFieldsChanged",(function(e){r.dispatch(e)})),{editorInterface:t,onLocaleSettingsChanged:function(e){return n.attach(e)},onShowDisabledFieldsChanged:function(e){return r.attach(e)}}}function y(e,t){var n=new i;return e.addHandler("navigateSlideIn",(function(e){n.dispatch(e)})),{openEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:t}))},openNewEntry:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Entry",id:null,contentTypeId:t}))},openBulkEditor:function(t,n){return e.call("navigateToBulkEditor",r({entryId:t},n))},openAsset:function(t,n){return e.call("navigateToContentEntity",r(r({},n),{entityType:"Asset",id:t}))},openNewAsset:function(t){return e.call("navigateToContentEntity",r(r({},t),{entityType:"Asset",id:null}))},openPageExtension:function(n){return e.call("navigateToPage",r({type:"extension",id:t.extension},n))},openCurrentAppPage:function(n){return e.call("navigateToPage",r({type:"app",id:t.app},n))},openAppConfig:function(){return e.call("navigateToAppConfig")},onSlideInNavigation:function(e){return n.attach(e)}}}var _="preInstall",E="postInstall",m=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)},A=function(e){return"function"==typeof e},C=function(e){return console.error(e),Promise.resolve(!1)},I=function(e,t,n){if(!A(e))return Promise.resolve(t);var r;try{r=void 0===n?e():e(n)}catch(e){return C(e)}var i,o=r;return m(i=o)&&A(i.then)||(o=Promise.resolve(o)),o.then((function(e){return e instanceof Error?Promise.reject(e):!1!==e&&(m(e)?e:t)}),C).catch(C)};function w(e){var t,n=((t={}).preInstall=null,t.postInstall=null,t),r=function(e,t){if(!A(t))throw new Error("Handler must be a function.");n[e]=t};return e.addHandler("appHook",(function(t){var r=t.stage,i=t.installationRequestId,o=t.err;return r===_?I(n[r],{}).then((function(t){return e.send("appHookResult",{stage:r,installationRequestId:i,result:t})})):r===E?I(n[r],void 0,o||null).then((function(){return e.send("appHookResult",{stage:r,installationRequestId:i})})):Promise.resolve()})),{setReady:function(){return e.call("callAppMethod","setReady")},isInstalled:function(){return e.call("callAppMethod","isInstalled")},getParameters:function(){return e.call("callAppMethod","getParameters")},getCurrentState:function(){return e.call("callAppMethod","getCurrentState")},onConfigure:function(e){r(_,e)},onConfigurationCompleted:function(e){r(E,e)}}}var b,T={LOCATION_ENTRY_FIELD:"entry-field",LOCATION_ENTRY_FIELD_SIDEBAR:"entry-field-sidebar",LOCATION_ENTRY_SIDEBAR:"entry-sidebar",LOCATION_DIALOG:"dialog",LOCATION_ENTRY_EDITOR:"entry-editor",LOCATION_PAGE:"page",LOCATION_APP_CONFIG:"app-config"},L=[S,H,function(e,t){var n=t.field;if(!n)throw new Error('FieldAPI called for location without "field" property defined.');return{field:new l(e,n)}},D,N],O=((b={})[T.LOCATION_ENTRY_FIELD]=L,b[T.LOCATION_ENTRY_FIELD_SIDEBAR]=L,b[T.LOCATION_ENTRY_SIDEBAR]=[S,H,D,N],b[T.LOCATION_ENTRY_EDITOR]=[S,H,D],b[T.LOCATION_DIALOG]=[S,function(e){return{close:function(t){return e.send("closeDialog",t)}}},N],b[T.LOCATION_PAGE]=[S],b[T.LOCATION_APP_CONFIG]=[S,function(e){return{app:w(e)}}],b);function S(e,t){var n=t.user,r=t.parameters,i=t.locales,o=t.ids,a=t.initialContentTypes,s=t.location||T.LOCATION_ENTRY_FIELD;return{location:{is:function(e){return s===e}},user:n,parameters:r,locales:{available:i.available,default:i.default,names:i.names,fallbacks:i.fallbacks,optional:i.optional,direction:i.direction},space:f(e,a),dialogs:v(e,o),navigator:y(e,o),notifier:{success:function(t){return e.send("notify",{type:"success",message:t})},error:function(t){return e.send("notify",{type:"error",message:t})}},ids:o,access:{can:function(t,n){return e.call("checkAccess",t,n)},canEditAppConfig:function(){return e.call("checkAppConfigAccess")}}}}function N(e,t,n){return{window:c(n,e)}}function D(e,t){return{editor:g(e,t.editorInterface)}}function H(e,t){var n=t.locales,r=t.contentType,i=t.entry,o=t.fieldInfo;return{contentType:r,entry:d(e,i,o,(function(t){return new u(e,t,n.default)}))}}var P,R,x,F,k=(P=window,R=function(e,t,n){return(O[t.location]||L).reduce((function(i,o){return r(r({},i),o(e,t,n))}),{})},(x={promise:null,resolve:null}).promise=new Promise((function(e){x.resolve=e})),(F=x).promise.then((function(e){var t=e[0],n=P.document;n.addEventListener("focus",(function(){return t.send("setActive",!0)}),!0),n.addEventListener("blur",(function(){return t.send("setActive",!1)}),!0)})),function(e,t){!function(e,t){function n(r){var i=r.data;"connect"===i.method&&(e.removeEventListener("message",n),t.apply(void 0,i.params))}e.addEventListener("message",n)}(e,(function(n,r){var i=new s(n.id,e);t(i,n,r)}))}(P,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return F.resolve(e)})),function(e,t){var n=void 0===t?{supressIframeWarning:!1}:t,r=n.makeCustomApi;n.supressIframeWarning||P.self!==P.top||console.error("Cannot use ui-extension-sdk outside of Contenful:\n\nIn order for the ui-extension-sdk to function correctly, your app needs to be run in an iframe in the Contentful Web App.\n\nLearn more about local development with the ui-extension-sdk here:\n https://www.contentful.com/developers/docs/extensibility/ui-extensions/faq/#how-can-i-use-the-ui-extension-sdk-locally"),F.promise.then((function(t){var n,i=t[0],o=t[1],a=t[2],s=R(i,o,P);"function"==typeof r&&(n=r(i,o)),a.forEach((function(e){i._handleMessage(e)})),e(s,n)}))});e.init=k,e.locations=T,Object.defineProperty(e,"__esModule",{value:!0})})),window.contentfulApp=window.contentfulExtension; |
{ | ||
"name": "contentful-app-sdk", | ||
"description": "SDK to develop custom UI Extension for the Contentful Web App", | ||
"version": "3.30.0", | ||
"version": "3.31.0", | ||
"author": "Contentful GmbH", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
72631
1