|
|
@@ -1,12 +1,23 @@
|
|
|
import { reducerFunc } from './reducers/types'
|
|
|
+import { eventDefParserFunc } from './structs/event'
|
|
|
+import { eventDragMutationMassager } from './interactions/EventDragging'
|
|
|
+import { eventDefMutationApplier } from './structs/event-mutation'
|
|
|
+
|
|
|
+// TODO: easier way to add new hooks? need to update a million things
|
|
|
|
|
|
export interface PluginDefInput {
|
|
|
deps?: PluginDef[]
|
|
|
reducers?: reducerFunc[]
|
|
|
+ eventDefParsers?: eventDefParserFunc[]
|
|
|
+ eventDragMutationMassagers: eventDragMutationMassager[]
|
|
|
+ eventDefMutationAppliers: eventDefMutationApplier[]
|
|
|
}
|
|
|
|
|
|
export interface PluginHooks {
|
|
|
reducers: reducerFunc[]
|
|
|
+ eventDefParsers: eventDefParserFunc[]
|
|
|
+ eventDragMutationMassagers: eventDragMutationMassager[]
|
|
|
+ eventDefMutationAppliers: eventDefMutationApplier[]
|
|
|
}
|
|
|
|
|
|
export interface PluginDef extends PluginHooks {
|
|
|
@@ -20,7 +31,10 @@ export function createPlugin(input: PluginDefInput): PluginDef {
|
|
|
return {
|
|
|
id: String(uid++),
|
|
|
deps: input.deps || [],
|
|
|
- reducers: input.reducers || []
|
|
|
+ reducers: input.reducers || [],
|
|
|
+ eventDefParsers: input.eventDefParsers || [],
|
|
|
+ eventDragMutationMassagers: input.eventDragMutationMassagers || [],
|
|
|
+ eventDefMutationAppliers: input.eventDefMutationAppliers || []
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -31,7 +45,10 @@ export class PluginSystem {
|
|
|
|
|
|
constructor() {
|
|
|
this.hooks = {
|
|
|
- reducers: []
|
|
|
+ reducers: [],
|
|
|
+ eventDefParsers: [],
|
|
|
+ eventDragMutationMassagers: [],
|
|
|
+ eventDefMutationAppliers: []
|
|
|
}
|
|
|
this.addedHash = {}
|
|
|
}
|
|
|
@@ -52,6 +69,9 @@ export class PluginSystem {
|
|
|
|
|
|
function combineHooks(hooks0: PluginHooks, hooks1: PluginHooks): PluginHooks {
|
|
|
return {
|
|
|
- reducers: hooks0.reducers.concat(hooks1.reducers)
|
|
|
+ reducers: hooks0.reducers.concat(hooks1.reducers),
|
|
|
+ eventDefParsers: hooks0.eventDefParsers.concat(hooks1.eventDefParsers),
|
|
|
+ eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
|
|
|
+ eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers)
|
|
|
}
|
|
|
}
|