@tinacms/core
Advanced tools
Comparing version 0.7.4 to 0.8.0-alpha.0
@@ -25,2 +25,3 @@ /** | ||
import { Plugin, PluginTypeManager } from './plugins'; | ||
import { EventBus } from './event'; | ||
/** | ||
@@ -33,2 +34,4 @@ * A [[CMS]] is the core object of any content management system. | ||
* - [[api|APIs]] which allow the CMS to integrate with third party services. | ||
* - [[EventBus|events]] which provide a way to communicate information about events happening | ||
* between decoupled parts of the CMS. | ||
* | ||
@@ -107,2 +110,3 @@ * The name [[CMS]] is a bit misleading. This object knows nothing of the user | ||
}; | ||
events: EventBus; | ||
/** | ||
@@ -109,0 +113,0 @@ * @hidden |
@@ -19,3 +19,4 @@ /** | ||
export * from './cms'; | ||
export * from './event'; | ||
export * from './subscribable'; | ||
export * from './plugins'; |
@@ -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 i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};var e=(n.prototype.subscribe=function(t){var e=this;return this.__subscribers.push(t),function(){return e.unsubscribe(t)}},n.prototype.unsubscribe=function(t){var e=this.__subscribers.indexOf(t);this.__subscribers.splice(e,1)},n.prototype.notifiySubscribers=function(){this.__subscribers.forEach(function(t){return t()})},n);function n(){this.__subscribers=[]}var r=(o.prototype.getType=function(t){return this.plugins[t]=this.plugins[t]||new c(t)},o.prototype.findOrCreateMap=function(t){return this.getType(t)},o.prototype.add=function(t){this.findOrCreateMap(t.__type).add(t)},o.prototype.remove=function(t){this.findOrCreateMap(t.__type).remove(t)},o.prototype.all=function(t){return this.findOrCreateMap(t).all()},o);function o(){this.plugins={}}var s,p,u,c=(i(s=a,p=u=e),void(s.prototype=null===p?Object.create(p):(f.prototype=p.prototype,new f)),a.prototype.add=function(t){var e=t;e.__type||(e.__type=this.__type),this.__plugins[e.name]=e,this.notifiySubscribers()},a.prototype.all=function(){var e=this;return Object.keys(this.__plugins).map(function(t){return e.__plugins[t]})},a.prototype.find=function(t){return this.__plugins[t]},a.prototype.remove=function(t){var e="string"==typeof t?t:t.name,i=this.__plugins[e];return delete this.__plugins[e],this.notifiySubscribers(),i},a);function f(){this.constructor=s}function a(t){var e=u.call(this)||this;return e.__type=t,e.__plugins={},e}var _=(y.prototype.registerApi=function(t,e){this.api[t]=e},y);function y(t){var n=this;void 0===t&&(t={}),this.api={},this.plugins=new r,t.plugins&&t.plugins.forEach(function(t){return n.plugins.add(t)}),t.apis&&Object.entries(t.apis).forEach(function(t){var e=t[0],i=t[1];return n.registerApi(e,i)})}t.CMS=_,t.PluginType=c,t.PluginTypeManager=r,t.Subscribable=e,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=(s.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})},s.prototype.all=function(){var e=this;return Object.keys(this.__plugins).map(function(t){return e.__plugins[t]})},s.prototype.find=function(t){return this.__plugins[t]},s.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},s.prototype.subscribe=function(t){return this.events.subscribe("plugin:*:"+this.__type,t)},s);function s(t,e){this.__type=t,this.events=e,this.__plugins={}}var r=function(){var i=this;this.listeners=new Set,this.subscribe=function(t,e){var n=new u(t,e);return i.listeners.add(n),function(){i.listeners.delete(n)}},this.dispatch=function(e){Array.from(i.listeners.values()).forEach(function(t){return t.handleEvent(e)})}},u=(p.prototype.handleEvent=function(t){return!!this.watchesEvent(t)&&(this.callback(t),!0)},p.prototype.watchesEvent=function(t){if("*"===this.eventPattern)return!0;for(var e=t.type.split(":"),n=this.eventPattern.split(":"),i=0,s=!1;!s&&i<n.length;){var r="*"===n[i],u=n[i]===e[i];s=!(r||u),i++}return!s},p);function p(t,e){this.eventPattern=t,this.callback=e}var o=(c.prototype.registerApi=function(t,e){this.api[t]=e},c);function c(t){var i=this;void 0===t&&(t={}),this.api={},this.events=new r,this.plugins=new e(this.events),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)})}var a=(h.prototype.subscribe=function(t){var e=this;return this.__subscribers.push(t),function(){return e.unsubscribe(t)}},h.prototype.unsubscribe=function(t){var e=this.__subscribers.indexOf(t);this.__subscribers.splice(e,1)},h.prototype.notifiySubscribers=function(){this.__subscribers.forEach(function(t){return t()})},h);function h(){this.__subscribers=[]}t.CMS=o,t.EventBus=r,t.Listener=u,t.PluginType=i,t.PluginTypeManager=e,t.Subscribable=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -44,3 +44,3 @@ /** | ||
*/ | ||
import { Subscribable } from './subscribable'; | ||
import { EventBus, Callback } from './event'; | ||
/** | ||
@@ -73,2 +73,3 @@ * An object used to extend or modify the behaviour of the content management system. | ||
export declare class PluginTypeManager { | ||
private events; | ||
/** | ||
@@ -78,2 +79,3 @@ * @ignore | ||
private plugins; | ||
constructor(events: EventBus); | ||
/** | ||
@@ -208,4 +210,5 @@ * Gets the [[PluginType|collection of plugins]] for the given type. | ||
*/ | ||
export declare class PluginType<T extends Plugin = Plugin> extends Subscribable { | ||
export declare class PluginType<T extends Plugin = Plugin> { | ||
private __type; | ||
private events; | ||
/** | ||
@@ -219,3 +222,3 @@ * @ignore | ||
*/ | ||
constructor(__type: string); | ||
constructor(__type: string, events: EventBus); | ||
/** | ||
@@ -266,3 +269,4 @@ * Adds a new plugin to the collection. | ||
remove(pluginOrName: string | T): T | undefined; | ||
subscribe(cb: Callback): () => void; | ||
} | ||
export {}; |
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.8.0-alpha.0](https://github.com/tinacms/tinacms/compare/@tinacms/core@0.7.4...@tinacms/core@0.8.0-alpha.0) (2020-05-08) | ||
### Features | ||
* **cms.events:** provides a way to subscribe to events in the cms ([4f9857d](https://github.com/tinacms/tinacms/commit/4f9857d)) | ||
## [0.7.4](https://github.com/tinacms/tinacms/compare/@tinacms/core@0.7.3...@tinacms/core@0.7.4) (2020-04-06) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@tinacms/core", | ||
"version": "0.7.4", | ||
"version": "0.8.0-alpha.0", | ||
"main": "build/index.js", | ||
@@ -32,3 +32,3 @@ "types": "build/index.d.ts", | ||
}, | ||
"gitHead": "4d74125e00320233a6a0ad1bb9282e801c5229e0" | ||
"gitHead": "5ca0ac802ab1ccd047195782301de28ac5878518" | ||
} |
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
39010
14
577