@tinacms/core
Advanced tools
Comparing version 0.31.0-alpha.3 to 0.31.0-alpha.4
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self)["@tinacms/core"]={})}(this,function(t){"use strict";var e=(n.prototype.getType=function(t){return this.plugins[t]=this.plugins[t]||new i(t,this.events)},n.prototype.findOrCreateMap=function(t){return this.getType(t)},n.prototype.add=function(t){this.findOrCreateMap(t.__type).add(t)},n.prototype.remove=function(t){this.findOrCreateMap(t.__type).remove(t)},n.prototype.all=function(t){return this.findOrCreateMap(t).all()},n);function n(t){this.events=t,this.plugins={}}var i=(r.prototype.add=function(t){var e=t;e.__type||(e.__type=this.__type),this.__plugins[e.name]=e,this.events.dispatch({type:"plugin:add:"+this.__type})},r.prototype.all=function(){var e=this;return Object.keys(this.__plugins).map(function(t){return e.__plugins[t]})},r.prototype.find=function(t){return this.__plugins[t]},r.prototype.remove=function(t){var e="string"==typeof t?t:t.name,n=this.__plugins[e];return delete this.__plugins[e],this.events.dispatch({type:"plugin:remove:"+this.__type}),n},r.prototype.subscribe=function(t){return this.events.subscribe("plugin:*:"+this.__type,t)},r);function r(t,e){this.__type=t,this.events=e,this.__plugins={}}var s=function(){var i=this;this.listeners=new Set,this.subscribe=function(t,e){var n=("string"==typeof t?[t]:t).map(function(t){return new o(t,e)});return n.forEach(function(t){return i.listeners.add(t)}),function(){n.forEach(function(t){return i.listeners.delete(t)})}},this.dispatch=function(e){Array.from(i.listeners.values()).forEach(function(t){return t.handleEvent(e)})}},o=(u.prototype.handleEvent=function(t){return!!this.watchesEvent(t)&&(this.callback(t),!0)},u.prototype.watchesEvent=function(t){if("*"===this.eventPattern)return!0;for(var e=t.type.split(":"),n=this.eventPattern.split(":"),i=0,r=!1;!r&&i<n.length;){var s="*"===n[i],o=n[i]===e[i];r=!(s||o),i++}return!r},u);function u(t,e){this.eventPattern=t,this.callback=e}var a=function(){return(a=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function c(s,o,u,a){return new(u=u||Promise)(function(t,e){function n(t){try{r(a.next(t))}catch(t){e(t)}}function i(t){try{r(a.throw(t))}catch(t){e(t)}}function r(e){e.done?t(e.value):new u(function(t){t(e.value)}).then(n,i)}r((a=a.apply(s,o||[])).next())})}function p(n,i){var r,s,o,t,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,s&&(o=2&e[0]?s.return:e[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,e[1])).done)return o;switch(s=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(o=0<(o=u.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){u.label=e[1];break}if(6===e[0]&&u.label<o[1]){u.label=o[1],o=e;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(e);break}o[2]&&u.ops.pop(),u.trys.pop();continue}e=i.call(n,u)}catch(t){e=[6,t],s=0}finally{r=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var h=(l.prototype.open=function(t){void 0===t&&(t={}),this.events.dispatch(a({type:"media:open"},t))},Object.defineProperty(l.prototype,"accept",{get:function(){return this.store.accept},enumerable:!0,configurable:!0}),l.prototype.persist=function(i){return c(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch({type:"media:upload:start",uploaded:i}),[4,this.store.persist(i)];case 1:return e=t.sent(),this.events.dispatch({type:"media:upload:success",uploaded:i,media:e}),[2,e];case 2:throw n=t.sent(),this.events.dispatch({type:"media:upload:failure",uploaded:i,error:n}),n;case 3:return[2]}})})},l.prototype.delete=function(n){return c(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch({type:"media:delete:start",media:n}),[4,this.store.delete(n)];case 1:return t.sent(),this.events.dispatch({type:"media:delete:success",media:n}),[3,3];case 2:throw e=t.sent(),this.events.dispatch({type:"media:delete:failure",media:n,error:e}),e;case 3:return[2]}})})},l.prototype.list=function(i){return c(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch(a({type:"media:list:start"},i)),[4,this.store.list(i)];case 1:return e=t.sent(),this.events.dispatch(a(a({type:"media:list:success"},i),{media:e})),[2,e];case 2:throw n=t.sent(),this.events.dispatch(a(a({type:"media:list:failure"},i),{error:n})),n;case 3:return[2]}})})},l);function l(t,e){var n=this;this.store=t,this.events=e,this.previewSrc=function(i,r,s){return c(n,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch({type:"media:preview:start",src:i,fieldName:r,formValues:s}),[4,this.store.previewSrc(i,r,s)];case 1:return e=t.sent(),this.events.dispatch({type:"media:preview:success",src:i,url:e,fieldName:r,formValues:s}),[2,e];case 2:throw n=t.sent(),this.events.dispatch({type:"media:preview:failure",src:i,error:n,fieldName:r,formValues:s}),n;case 3:return[2]}})})}}var f=(d.prototype.persist=function(e){return c(this,void 0,void 0,function(){return p(this,function(t){return alert("UPLOADING FILES"),console.log(e),[2,e.map(function(t){var e=t.directory,n=t.file;return{id:n.name,type:"file",directory:e,filename:n.name}})]})})},d.prototype.previewSrc=function(e){return c(this,void 0,void 0,function(){return p(this,function(t){return[2,e]})})},d.prototype.list=function(){return c(this,void 0,void 0,function(){var e;return p(this,function(t){return e=[],alert("Add a media store to the CMS."),[2,{items:e,offset:0,limit:10,totalCount:0}]})})},d.prototype.delete=function(){return c(this,void 0,void 0,function(){return p(this,function(t){return[2]})})},d);function d(){this.accept="*"}var v=(y.prototype.registerApi=function(t,e){e.events instanceof s&&e.events.subscribe("*",this.events.dispatch),this.api[t]=e},Object.defineProperty(y.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"disabled",{get:function(){return!this._enabled},enumerable:!0,configurable:!0}),y.ENABLED={type:"cms:enable"},y.DISABLED={type:"cms:disable"},y);function y(t){var i=this;void 0===t&&(t={}),this._enabled=!1,this.api={},this.events=new s,this.media=new h(new f,this.events),this.enable=function(){i._enabled=!0,i.events.dispatch(y.ENABLED)},this.disable=function(){i._enabled=!1,i.events.dispatch(y.DISABLED)},this.toggle=function(){i.enabled?i.disable():i.enable()},this.plugins=new e(this.events),t.media&&(this.media.store=t.media),t.plugins&&t.plugins.forEach(function(t){return i.plugins.add(t)}),t.apis&&Object.entries(t.apis).forEach(function(t){var e=t[0],n=t[1];return i.registerApi(e,n)}),t.enabled&&this.enable()}var b=(m.prototype.subscribe=function(t){var e=this;return this.__subscribers.push(t),function(){return e.unsubscribe(t)}},m.prototype.unsubscribe=function(t){var e=this.__subscribers.indexOf(t);this.__subscribers.splice(e,1)},m.prototype.notifiySubscribers=function(){this.__subscribers.forEach(function(t){return t()})},m);function m(){this.__subscribers=[]}t.CMS=v,t.EventBus=s,t.Listener=o,t.MediaManager=h,t.PluginType=i,t.PluginTypeManager=e,t.Subscribable=b,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self)["@tinacms/core"]={})}(this,function(t){"use strict";var e=(n.prototype.getType=function(t){return this.plugins[t]=this.plugins[t]||new i(t,this.events)},n.prototype.findOrCreateMap=function(t){return this.getType(t)},n.prototype.add=function(t){this.findOrCreateMap(t.__type).add(t)},n.prototype.remove=function(t){this.findOrCreateMap(t.__type).remove(t)},n.prototype.all=function(t){return this.findOrCreateMap(t).all()},n);function n(t){this.events=t,this.plugins={}}var i=(r.prototype.add=function(t){var e=t;e.__type||(e.__type=this.__type),this.__plugins[e.name]=e,this.events.dispatch({type:"plugin:add:"+this.__type})},r.prototype.all=function(){var e=this;return Object.keys(this.__plugins).map(function(t){return e.__plugins[t]})},r.prototype.find=function(t){return this.__plugins[t]},r.prototype.remove=function(t){var e="string"==typeof t?t:t.name,n=this.__plugins[e];return delete this.__plugins[e],this.events.dispatch({type:"plugin:remove:"+this.__type}),n},r.prototype.subscribe=function(t){return this.events.subscribe("plugin:*:"+this.__type,t)},r);function r(t,e){this.__type=t,this.events=e,this.__plugins={}}var s=function(){var i=this;this.listeners=new Set,this.subscribe=function(t,e){var n=("string"==typeof t?[t]:t).map(function(t){return new o(t,e)});return n.forEach(function(t){return i.listeners.add(t)}),function(){n.forEach(function(t){return i.listeners.delete(t)})}},this.dispatch=function(e){Array.from(i.listeners.values()).forEach(function(t){return t.handleEvent(e)})}},o=(u.prototype.handleEvent=function(t){return!!this.watchesEvent(t)&&(this.callback(t),!0)},u.prototype.watchesEvent=function(t){if("*"===this.eventPattern)return!0;for(var e=t.type.split(":"),n=this.eventPattern.split(":"),i=0,r=!1;!r&&i<n.length;){var s="*"===n[i],o=n[i]===e[i];r=!(s||o),i++}return!r},u);function u(t,e){this.eventPattern=t,this.callback=e}var a=function(){return(a=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function c(s,o,u,a){return new(u=u||Promise)(function(t,e){function n(t){try{r(a.next(t))}catch(t){e(t)}}function i(t){try{r(a.throw(t))}catch(t){e(t)}}function r(e){e.done?t(e.value):new u(function(t){t(e.value)}).then(n,i)}r((a=a.apply(s,o||[])).next())})}function p(n,i){var r,s,o,t,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,s&&(o=2&e[0]?s.return:e[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,e[1])).done)return o;switch(s=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(o=0<(o=u.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){u.label=e[1];break}if(6===e[0]&&u.label<o[1]){u.label=o[1],o=e;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(e);break}o[2]&&u.ops.pop(),u.trys.pop();continue}e=i.call(n,u)}catch(t){e=[6,t],s=0}finally{r=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var h=(l.prototype.open=function(t){void 0===t&&(t={}),this.events.dispatch(a({type:"media:open"},t))},Object.defineProperty(l.prototype,"accept",{get:function(){return this.store.accept},enumerable:!0,configurable:!0}),l.prototype.persist=function(i){return c(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch({type:"media:upload:start",uploaded:i}),[4,this.store.persist(i)];case 1:return e=t.sent(),this.events.dispatch({type:"media:upload:success",uploaded:i,media:e}),[2,e];case 2:throw n=t.sent(),this.events.dispatch({type:"media:upload:failure",uploaded:i,error:n}),n;case 3:return[2]}})})},l.prototype.delete=function(n){return c(this,void 0,void 0,function(){var e;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch({type:"media:delete:start",media:n}),[4,this.store.delete(n)];case 1:return t.sent(),this.events.dispatch({type:"media:delete:success",media:n}),[3,3];case 2:throw e=t.sent(),this.events.dispatch({type:"media:delete:failure",media:n,error:e}),e;case 3:return[2]}})})},l.prototype.list=function(i){return c(this,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch(a({type:"media:list:start"},i)),[4,this.store.list(i)];case 1:return e=t.sent(),this.events.dispatch(a(a({type:"media:list:success"},i),{media:e})),[2,e];case 2:throw n=t.sent(),this.events.dispatch(a(a({type:"media:list:failure"},i),{error:n})),n;case 3:return[2]}})})},l);function l(t,e){var n=this;this.store=t,this.events=e,this.previewSrc=function(i,r,s){return void 0===r&&(r=""),void 0===s&&(s={}),c(n,void 0,void 0,function(){var e,n;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.events.dispatch({type:"media:preview:start",src:i,fieldName:r,formValues:s}),[4,this.store.previewSrc(i,r,s)];case 1:return e=t.sent(),this.events.dispatch({type:"media:preview:success",src:i,url:e,fieldName:r,formValues:s}),[2,e];case 2:throw n=t.sent(),this.events.dispatch({type:"media:preview:failure",src:i,error:n,fieldName:r,formValues:s}),n;case 3:return[2]}})})}}var f=(d.prototype.persist=function(e){return c(this,void 0,void 0,function(){return p(this,function(t){return alert("UPLOADING FILES"),console.log(e),[2,e.map(function(t){var e=t.directory,n=t.file;return{id:n.name,type:"file",directory:e,filename:n.name}})]})})},d.prototype.previewSrc=function(e){return c(this,void 0,void 0,function(){return p(this,function(t){return[2,e]})})},d.prototype.list=function(){return c(this,void 0,void 0,function(){var e;return p(this,function(t){return e=[],alert("Add a media store to the CMS."),[2,{items:e,offset:0,limit:10,totalCount:0}]})})},d.prototype.delete=function(){return c(this,void 0,void 0,function(){return p(this,function(t){return[2]})})},d);function d(){this.accept="*"}var v=(y.prototype.registerApi=function(t,e){e.events instanceof s&&e.events.subscribe("*",this.events.dispatch),this.api[t]=e},Object.defineProperty(y.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"disabled",{get:function(){return!this._enabled},enumerable:!0,configurable:!0}),y.ENABLED={type:"cms:enable"},y.DISABLED={type:"cms:disable"},y);function y(t){var i=this;void 0===t&&(t={}),this._enabled=!1,this.api={},this.events=new s,this.media=new h(new f,this.events),this.enable=function(){i._enabled=!0,i.events.dispatch(y.ENABLED)},this.disable=function(){i._enabled=!1,i.events.dispatch(y.DISABLED)},this.toggle=function(){i.enabled?i.disable():i.enable()},this.plugins=new e(this.events),t.media&&(this.media.store=t.media),t.plugins&&t.plugins.forEach(function(t){return i.plugins.add(t)}),t.apis&&Object.entries(t.apis).forEach(function(t){var e=t[0],n=t[1];return i.registerApi(e,n)}),t.enabled&&this.enable()}var b=(m.prototype.subscribe=function(t){var e=this;return this.__subscribers.push(t),function(){return e.unsubscribe(t)}},m.prototype.unsubscribe=function(t){var e=this.__subscribers.indexOf(t);this.__subscribers.splice(e,1)},m.prototype.notifiySubscribers=function(){this.__subscribers.forEach(function(t){return t()})},m);function m(){this.__subscribers=[]}t.CMS=v,t.EventBus=s,t.Listener=o,t.MediaManager=h,t.PluginType=i,t.PluginTypeManager=e,t.Subscribable=b,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -75,3 +75,3 @@ /** | ||
*/ | ||
previewSrc(src: string, fieldPath: string, formValues: any): Promise<string>; | ||
previewSrc(src: string, fieldPath?: string, formValues?: any): Promise<string> | string; | ||
/** | ||
@@ -122,3 +122,3 @@ * Lists all media in a specific directory. | ||
delete(media: Media): Promise<void>; | ||
previewSrc: (src: string, fieldName: string, formValues: any) => Promise<string>; | ||
previewSrc: (src: string, fieldName?: string, formValues?: any) => Promise<string>; | ||
list(options: MediaListOptions): Promise<MediaList>; | ||
@@ -125,0 +125,0 @@ } |
{ | ||
"name": "@tinacms/core", | ||
"version": "0.31.0-alpha.3", | ||
"version": "0.31.0-alpha.4", | ||
"main": "build/index.js", | ||
@@ -32,3 +32,3 @@ "types": "build/index.d.ts", | ||
}, | ||
"gitHead": "2dba298293e67677222fbb1ee1db74b386f34096" | ||
"gitHead": "42ab4db5edc94ae7d5a621023849269de45e5df2" | ||
} |
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
52071