Adam Shaw 5 سال پیش
والد
کامیت
1c398652a4
43فایلهای تغییر یافته به همراه217 افزوده شده و 163 حذف شده
  1. 1 1
      packages-contrib/angular
  2. 2 1
      packages/core/src/Calendar.tsx
  3. 5 3
      packages/core/src/CalendarApi.tsx
  4. 1 1
      packages/core/src/CalendarComponent.tsx
  5. 1 1
      packages/core/src/ViewApi.ts
  6. 2 1
      packages/core/src/api/EventApi.ts
  7. 2 2
      packages/core/src/component/ComponentContext.ts
  8. 1 1
      packages/core/src/component/DateComponent.ts
  9. 2 1
      packages/core/src/component/event-rendering.ts
  10. 1 1
      packages/core/src/component/event-splitting.ts
  11. 1 1
      packages/core/src/event-sources/array-event-source.ts
  12. 1 1
      packages/core/src/event-sources/func-event-source.ts
  13. 1 1
      packages/core/src/interactions/event-dragging.ts
  14. 6 5
      packages/core/src/main.ts
  15. 4 4
      packages/core/src/plugin-system-struct.ts
  16. 3 40
      packages/core/src/reducers/Action.ts
  17. 42 0
      packages/core/src/reducers/CalendarState.ts
  18. 6 2
      packages/core/src/reducers/CalendarStateReducer.ts
  19. 2 2
      packages/core/src/reducers/ReducerContext.ts
  20. 1 1
      packages/core/src/reducers/current-date.ts
  21. 1 1
      packages/core/src/reducers/date-profile.ts
  22. 1 1
      packages/core/src/reducers/date-selection.ts
  23. 1 1
      packages/core/src/reducers/event-drag.ts
  24. 1 1
      packages/core/src/reducers/event-resize.ts
  25. 1 1
      packages/core/src/reducers/eventSources.ts
  26. 4 2
      packages/core/src/reducers/eventStore.ts
  27. 1 1
      packages/core/src/reducers/selected-event.ts
  28. 1 1
      packages/core/src/reducers/view-type.ts
  29. 1 1
      packages/core/src/structs/business-hours.ts
  30. 1 1
      packages/core/src/structs/constraint.ts
  31. 2 1
      packages/core/src/structs/date-span.ts
  32. 1 1
      packages/core/src/structs/drag-meta.ts
  33. 33 0
      packages/core/src/structs/event-def.ts
  34. 30 0
      packages/core/src/structs/event-instance.ts
  35. 2 1
      packages/core/src/structs/event-mutation.ts
  36. 3 60
      packages/core/src/structs/event-parse.ts
  37. 1 1
      packages/core/src/structs/event-source-parse.ts
  38. 1 1
      packages/core/src/structs/event-source.ts
  39. 10 9
      packages/core/src/structs/event-store.ts
  40. 1 1
      packages/core/src/structs/recurring-event-simple.ts
  41. 4 4
      packages/core/src/structs/recurring-event.ts
  42. 1 1
      packages/core/src/types/input-types.ts
  43. 30 2
      scripts/lib/rollup-dts.js

+ 1 - 1
packages-contrib/angular

@@ -1 +1 @@
-Subproject commit 04e9a4df130ec7a648071b388a52fbf37b10c103
+Subproject commit cb600eb6a44712efa362b33191d90d2a55bc4c79

+ 2 - 1
packages/core/src/Calendar.tsx

@@ -1,5 +1,6 @@
 import { OptionsInput } from './types/input-types'
-import { CalendarState, Action } from './reducers/types'
+import { Action } from './reducers/Action'
+import { CalendarState } from './reducers/CalendarState'
 import { CalendarComponent } from './CalendarComponent'
 import { __assign } from 'tslib'
 import { render, h, flushToDom } from './vdom'

+ 5 - 3
packages/core/src/CalendarApi.tsx

@@ -6,10 +6,12 @@ import { createDuration, DurationInput } from './datelib/duration'
 import { parseDateSpan, DateSpanInput } from './structs/date-span'
 import { DateRangeInput } from './datelib/date-range'
 import { EventSourceInput, parseEventSource } from './structs/event-source-parse'
-import { EventInput, parseEvent } from './structs/event'
-import { CalendarState, Action } from './reducers/types'
+import { EventInput, parseEvent } from './structs/event-parse'
+import { CalendarState } from './reducers/CalendarState'
+import { Action } from './reducers/Action'
 import { EventSourceApi } from './api/EventSourceApi'
 import { EventApi } from './api/EventApi'
+import { ViewApi } from './ViewApi'
 import { eventTupleToStore } from './structs/event-store'
 import { ViewSpec } from './structs/view-spec'
 import { __assign } from 'tslib'
@@ -26,7 +28,7 @@ export class CalendarApi {
   getCurrentState: () => CalendarState
   emitter: Emitter
 
-  get view() { return this.getCurrentState().viewApi } // for public API
+  get view(): ViewApi { return this.getCurrentState().viewApi } // for public API
 
 
   constructor(protected reducer: CalendarStateReducer) {

+ 1 - 1
packages/core/src/CalendarComponent.tsx

@@ -6,7 +6,7 @@ import { DateProfileGenerator, DateProfile } from './DateProfileGenerator'
 import { rangeContainsMarker } from './datelib/date-range'
 import { memoize } from './util/memoize'
 import { DateMarker } from './datelib/marker'
-import { CalendarState } from './reducers/types'
+import { CalendarState } from './reducers/CalendarState'
 import { ViewPropsTransformerClass } from './plugin-system-struct'
 import { __assign } from 'tslib'
 import { h, createRef, Component } from './vdom'

+ 1 - 1
packages/core/src/ViewApi.ts

@@ -1,5 +1,5 @@
 import { DateEnv } from './datelib/env'
-import { CalendarState } from './reducers/types'
+import { CalendarState } from './reducers/CalendarState'
 
 
 export class ViewApi { // always represents the current view

+ 2 - 1
packages/core/src/api/EventApi.ts

@@ -1,4 +1,5 @@
-import { EventDef, EventInstance, NON_DATE_PROPS, DATE_PROPS } from '../structs/event'
+import { EventDef, NON_DATE_PROPS, DATE_PROPS } from '../structs/event-def'
+import { EventInstance } from '../structs/event-instance'
 import { UNSCOPED_EVENT_UI_PROPS } from '../component/event-ui'
 import { EventMutation } from '../structs/event-mutation'
 import { DateInput } from '../datelib/env'

+ 2 - 2
packages/core/src/component/ComponentContext.ts

@@ -8,9 +8,9 @@ import { ScrollResponder, ScrollRequestHandler } from '../ScrollResponder'
 import { DateProfileGenerator } from '../DateProfileGenerator'
 import { ViewSpec } from '../structs/view-spec'
 import { ReducerContext } from '../reducers/ReducerContext'
-import { Action } from '../reducers/types'
+import { Action } from '../reducers/Action'
 import { Emitter } from '../common/Emitter'
-import { CalendarState } from '../reducers/types'
+import { CalendarState } from '../reducers/CalendarState'
 import { InteractionSettingsInput } from '../interactions/interaction'
 import { DateComponent } from './DateComponent'
 

+ 1 - 1
packages/core/src/component/DateComponent.ts

@@ -1,7 +1,7 @@
 import { BaseComponent } from '../vdom-util'
 import { EventRenderRange } from './event-rendering'
 import { DateSpan } from '../structs/date-span'
-import { EventInstanceHash } from '../structs/event'
+import { EventInstanceHash } from '../structs/event-instance'
 import { rangeContainsRange } from '../datelib/date-range'
 import { Hit } from '../interactions/hit'
 import { elementClosest } from '../util/dom-manip'

+ 2 - 1
packages/core/src/component/event-rendering.ts

@@ -1,4 +1,5 @@
-import { EventDef, EventTuple, EventDefHash } from '../structs/event'
+import { EventDef, EventDefHash } from '../structs/event-def'
+import { EventTuple } from '../structs/event-parse'
 import { EventStore } from '../structs/event-store'
 import { DateRange, invertRanges, intersectRanges, rangeContainsMarker } from '../datelib/date-range'
 import { Duration } from '../datelib/duration'

+ 1 - 1
packages/core/src/component/event-splitting.ts

@@ -1,5 +1,5 @@
 import { EventStore, createEmptyEventStore } from '../structs/event-store'
-import { EventDef } from '../structs/event'
+import { EventDef } from '../structs/event-def'
 import { EventInteractionState } from '../interactions/event-interaction-state'
 import { mapHash } from '../util/object'
 import { memoize } from '../util/memoize'

+ 1 - 1
packages/core/src/event-sources/array-event-source.ts

@@ -1,6 +1,6 @@
 import { createPlugin } from '../plugin-system'
 import { EventSourceDef } from '../structs/event-source-def'
-import { EventInput } from '../structs/event'
+import { EventInput } from '../structs/event-parse'
 
 let eventSourceDef: EventSourceDef = {
   ignoreRange: true,

+ 1 - 1
packages/core/src/event-sources/func-event-source.ts

@@ -1,7 +1,7 @@
 import { unpromisify } from '../util/promise'
 import { EventSourceDef } from '../structs/event-source-def'
 import { EventSourceError } from '../structs/event-source'
-import { EventInput } from '../structs/event'
+import { EventInput } from '../structs/event-parse'
 import { createPlugin } from '../plugin-system'
 
 export type EventSourceFunc = (

+ 1 - 1
packages/core/src/interactions/event-dragging.ts

@@ -1,6 +1,6 @@
 import { EventMutation } from '../structs/event-mutation'
 import { Hit } from './hit'
-import { EventDef } from '../structs/event'
+import { EventDef } from '../structs/event-def'
 import { EventUi } from '../component/event-ui'
 import { ReducerContext } from '../reducers/ReducerContext'
 

+ 6 - 5
packages/core/src/main.ts

@@ -7,10 +7,9 @@ export const version = '<%= version %>'
 
 // types
 export { OptionsInput } from './types/input-types'
-export {
-  EventInput, EventDef, EventDefHash, EventInstance, EventInstanceHash,
-  parseEventDef, createEventInstance, EventTuple
-} from './structs/event'
+export { EventDef, EventDefHash } from './structs/event-def'
+export { EventInstance, EventInstanceHash, createEventInstance } from './structs/event-instance'
+export { EventInput, parseEventDef, EventTuple } from './structs/event-parse'
 export { BusinessHoursInput, parseBusinessHours } from './structs/business-hours'
 
 export {
@@ -147,7 +146,9 @@ export { DragMetaInput, DragMeta, parseDragMeta } from './structs/drag-meta'
 
 export { PluginDef, PluginDefInput, ViewPropsTransformer, ViewContainerAppend } from './plugin-system-struct'
 export { createPlugin } from './plugin-system'
-export { reducerFunc, Action, CalendarState } from './reducers/types'
+export { ReducerFunc } from './reducers/CalendarStateReducer'
+export { CalendarState } from './reducers/CalendarState'
+export { Action } from './reducers/Action'
 export { ReducerContext } from './reducers/ReducerContext'
 export { CalendarComponentProps } from './CalendarComponent'
 

+ 4 - 4
packages/core/src/plugin-system-struct.ts

@@ -1,5 +1,5 @@
-import { reducerFunc } from './reducers/types'
-import { eventDefParserFunc } from './structs/event'
+import { ReducerFunc } from './reducers/CalendarStateReducer'
+import { eventDefParserFunc } from './structs/event-parse'
 import { eventDefMutationApplier } from './structs/event-mutation'
 import { DatePointTransform, DateSpanTransform, CalendarInteractionClass, OptionChangeHandlerMap } from './calendar-utils'
 import { ViewConfigInputHash } from './structs/view-config'
@@ -27,7 +27,7 @@ import { ContentTypeHandlers } from './common/render-hook'
 
 export interface PluginDefInput {
   deps?: PluginDef[]
-  reducers?: reducerFunc[]
+  reducers?: ReducerFunc[]
   eventDefParsers?: eventDefParserFunc[]
   isDraggableTransformers?: eventIsDraggableTransformer[]
   eventDragMutationMassagers?: eventDragMutationMassager[]
@@ -57,7 +57,7 @@ export interface PluginDefInput {
 }
 
 export interface PluginHooks {
-  reducers: reducerFunc[]
+  reducers: ReducerFunc[]
   eventDefParsers: eventDefParserFunc[]
   isDraggableTransformers: eventIsDraggableTransformer[]
   eventDragMutationMassagers: eventDragMutationMassager[]

+ 3 - 40
packages/core/src/reducers/types.ts → packages/core/src/reducers/Action.ts

@@ -1,49 +1,12 @@
-import { EventInput, EventInstanceHash } from '../structs/event'
+import { EventInstanceHash } from '../structs/event-instance'
+import { EventInput } from '../structs/event-parse'
 import { DateRange } from '../datelib/date-range'
 import { EventStore } from '../structs/event-store'
 import { EventMutation } from '../structs/event-mutation'
-import { EventSource, EventSourceHash, EventSourceError } from '../structs/event-source'
-import { DateProfile, DateProfileGenerator } from '../DateProfileGenerator'
+import { EventSource, EventSourceError } from '../structs/event-source'
 import { EventInteractionState } from '../interactions/event-interaction-state'
 import { DateSpan } from '../structs/date-span'
 import { DateMarker } from '../datelib/marker'
-import { RawLocaleMap } from '../datelib/locale'
-import { Theme } from '../theme/Theme'
-import { ViewSpecHash, ViewSpec } from '../structs/view-spec'
-import { ReducerContext } from './ReducerContext'
-import { EventUiHash, EventUi } from '../component/event-ui'
-import { ViewApi } from '../ViewApi'
-
-export interface CalendarState extends ReducerContext {
-  businessHours: EventStore
-  calendarOptions: any // NOTE: use `options` instead. view-specific
-  eventSources: EventSourceHash
-  eventSourceLoadingLevel: number
-  eventUiBases: EventUiHash
-  loadingLevel: number
-  viewType: string
-  currentDate: DateMarker
-  dateProfile: DateProfile | null // for the current view
-  eventStore: EventStore
-  renderableEventStore: EventStore
-  dateSelection: DateSpan | null
-  eventSelection: string
-  eventDrag: EventInteractionState | null
-  eventResize: EventInteractionState | null
-  optionOverrides: any
-  dynamicOptionOverrides: any
-  availableRawLocales: RawLocaleMap
-  theme: Theme
-  dateProfileGenerator: DateProfileGenerator
-  viewSpecs: ViewSpecHash
-  toolbarConfig
-  selectionConfig: EventUi
-  viewSpec: ViewSpec
-  viewTitle: string
-  viewApi: ViewApi
-}
-
-export type reducerFunc = (state: CalendarState, action: Action, context: ReducerContext) => CalendarState
 
 export type Action =
 

+ 42 - 0
packages/core/src/reducers/CalendarState.ts

@@ -0,0 +1,42 @@
+import { EventStore } from '../structs/event-store'
+import { EventSourceHash } from '../structs/event-source'
+import { DateProfile, DateProfileGenerator } from '../DateProfileGenerator'
+import { EventInteractionState } from '../interactions/event-interaction-state'
+import { DateSpan } from '../structs/date-span'
+import { DateMarker } from '../datelib/marker'
+import { RawLocaleMap } from '../datelib/locale'
+import { Theme } from '../theme/Theme'
+import { ViewSpecHash, ViewSpec } from '../structs/view-spec'
+import { ReducerContext } from './ReducerContext'
+import { EventUiHash, EventUi } from '../component/event-ui'
+import { ViewApi } from '../ViewApi'
+
+
+export interface CalendarState extends ReducerContext {
+  businessHours: EventStore
+  calendarOptions: any // NOTE: use `options` instead. view-specific
+  eventSources: EventSourceHash
+  eventSourceLoadingLevel: number
+  eventUiBases: EventUiHash
+  loadingLevel: number
+  viewType: string
+  currentDate: DateMarker
+  dateProfile: DateProfile | null // for the current view
+  eventStore: EventStore
+  renderableEventStore: EventStore
+  dateSelection: DateSpan | null
+  eventSelection: string
+  eventDrag: EventInteractionState | null
+  eventResize: EventInteractionState | null
+  optionOverrides: any
+  dynamicOptionOverrides: any
+  availableRawLocales: RawLocaleMap
+  theme: Theme
+  dateProfileGenerator: DateProfileGenerator
+  viewSpecs: ViewSpecHash
+  toolbarConfig
+  selectionConfig: EventUi
+  viewSpec: ViewSpec
+  viewTitle: string
+  viewApi: ViewApi
+}

+ 6 - 2
packages/core/src/reducers/CalendarStateReducer.ts

@@ -1,6 +1,7 @@
 import { buildLocale, RawLocaleInfo, organizeRawLocales } from '../datelib/locale'
 import { memoize, memoizeObjArg } from '../util/memoize'
-import { Action, CalendarState } from './types'
+import { CalendarState } from './CalendarState'
+import { Action } from './Action'
 import { buildPluginHooks } from '../plugin-system'
 import { PluginHooks } from '../plugin-system-struct'
 import { DateEnv } from '../datelib/env'
@@ -22,7 +23,7 @@ import { reduceEventResize } from './event-resize'
 import { Emitter } from '../common/Emitter'
 import { ReducerContext, buildComputedOptions } from './ReducerContext'
 import { processScopedUiProps, EventUiHash, EventUi } from '../component/event-ui'
-import { EventDefHash } from '../structs/event'
+import { EventDefHash } from '../structs/event-def'
 import { parseToolbars } from '../toolbar-parse'
 import { firstDefined } from '../util/misc'
 import { globalDefaults, mergeOptions } from '../options'
@@ -35,6 +36,9 @@ import { TaskRunner } from '../util/runner'
 import { globalPlugins } from '../global-plugins'
 
 
+export type ReducerFunc = (state: CalendarState, action: Action, context: ReducerContext) => CalendarState // for plugins
+
+
 export class CalendarStateReducer {
 
   private buildPluginHooks = memoize(buildPluginHooks)

+ 2 - 2
packages/core/src/reducers/ReducerContext.ts

@@ -1,11 +1,11 @@
-import { Action } from './types'
 import { PluginHooks } from '../plugin-system-struct'
 import { DateEnv } from '../datelib/env'
 import { CalendarApi } from '../CalendarApi'
 import { Emitter } from '../common/Emitter'
 import { parseFieldSpecs } from '../util/misc'
 import { createDuration, Duration } from '../datelib/duration'
-import { CalendarState } from '../reducers/types'
+import { CalendarState } from './CalendarState'
+import { Action } from './Action'
 
 
 export interface ReducerContext {

+ 1 - 1
packages/core/src/reducers/current-date.ts

@@ -1,5 +1,5 @@
 import { DateMarker } from '../datelib/marker'
-import { Action } from './types'
+import { Action } from './Action'
 import { DateProfile } from '../DateProfileGenerator'
 import { rangeContainsMarker } from '../datelib/date-range'
 import { DateEnv } from '../datelib/env'

+ 1 - 1
packages/core/src/reducers/date-profile.ts

@@ -1,5 +1,5 @@
 import { DateProfile, DateProfileGenerator, DATE_PROFILE_OPTIONS } from '../DateProfileGenerator'
-import { Action } from './types'
+import { Action } from './Action'
 import { DateMarker } from '../datelib/marker'
 import { rangeContainsMarker } from '../datelib/date-range'
 

+ 1 - 1
packages/core/src/reducers/date-selection.ts

@@ -1,5 +1,5 @@
 import { DateSpan } from '../structs/date-span'
-import { Action } from './types'
+import { Action } from './Action'
 
 
 export function reduceDateSelection(currentSelection: DateSpan | null, action: Action) {

+ 1 - 1
packages/core/src/reducers/event-drag.ts

@@ -1,4 +1,4 @@
-import { Action } from './types'
+import { Action } from './Action'
 import { EventInteractionState } from '../interactions/event-interaction-state'
 
 

+ 1 - 1
packages/core/src/reducers/event-resize.ts

@@ -1,5 +1,5 @@
 import { EventInteractionState } from '../interactions/event-interaction-state'
-import { Action } from './types'
+import { Action } from './Action'
 
 
 export function reduceEventResize(currentResize: EventInteractionState | null, action: Action): EventInteractionState | null {

+ 1 - 1
packages/core/src/reducers/eventSources.ts

@@ -3,7 +3,7 @@ import { parseEventSource } from '../structs/event-source-parse'
 import { arrayToHash, filterHash } from '../util/object'
 import { DateRange } from '../datelib/date-range'
 import { DateProfile } from '../DateProfileGenerator'
-import { Action } from './types'
+import { Action } from './Action'
 import { guid } from '../util/misc'
 import { ReducerContext } from './ReducerContext'
 

+ 4 - 2
packages/core/src/reducers/eventStore.ts

@@ -1,6 +1,8 @@
 import { filterHash, mapHash } from '../util/object'
 import { EventMutation, applyMutationToEventStore } from '../structs/event-mutation'
-import { EventDef, EventInstance, EventInput, EventInstanceHash } from '../structs/event'
+import { EventDef } from '../structs/event-def'
+import { EventInstance, EventInstanceHash } from '../structs/event-instance'
+import { EventInput } from '../structs/event-parse'
 import {
   EventStore,
   mergeEventStores,
@@ -9,7 +11,7 @@ import {
   filterEventStoreDefs,
   parseEvents
 } from '../structs/event-store'
-import { Action } from './types'
+import { Action } from './Action'
 import { EventSourceHash, EventSource } from '../structs/event-source'
 import { DateRange } from '../datelib/date-range'
 import { DateProfile } from '../DateProfileGenerator'

+ 1 - 1
packages/core/src/reducers/selected-event.ts

@@ -1,4 +1,4 @@
-import { Action } from './types'
+import { Action } from './Action'
 
 
 export function reduceSelectedEvent(currentInstanceId: string, action: Action): string {

+ 1 - 1
packages/core/src/reducers/view-type.ts

@@ -1,4 +1,4 @@
-import { Action } from './types'
+import { Action } from './Action'
 
 
 export function reduceViewType(viewType: string, action: Action, availableViewHash): string {

+ 1 - 1
packages/core/src/structs/business-hours.ts

@@ -1,4 +1,4 @@
-import { EventInput } from './event'
+import { EventInput } from './event-parse'
 import { EventStore, parseEvents } from './event-store'
 import { ReducerContext } from '../reducers/ReducerContext'
 

+ 1 - 1
packages/core/src/structs/constraint.ts

@@ -1,5 +1,5 @@
 import { EventStore, parseEvents } from './event-store'
-import { EventInput } from './event'
+import { EventInput } from './event-parse'
 import { DateSpanApi } from './date-span'
 import { EventApi } from '../api/EventApi'
 import { SplittableProps } from '../component/event-splitting'

+ 2 - 1
packages/core/src/structs/date-span.ts

@@ -2,7 +2,8 @@ import { DateRange, rangesEqual, OpenDateRange } from '../datelib/date-range'
 import { DateInput, DateEnv } from '../datelib/env'
 import { refineProps } from '../util/misc'
 import { Duration } from '../datelib/duration'
-import { parseEventDef, createEventInstance } from './event'
+import { createEventInstance } from './event-instance'
+import { parseEventDef } from './event-parse'
 import { EventRenderRange, compileEventUi } from '../component/event-rendering'
 import { EventUiHash } from '../component/event-ui'
 import { ReducerContext } from '../reducers/ReducerContext'

+ 1 - 1
packages/core/src/structs/drag-meta.ts

@@ -1,6 +1,6 @@
 import { createDuration, Duration, DurationInput } from '../datelib/duration'
 import { refineProps } from '../util/misc'
-import { EventNonDateInput } from '../structs/event'
+import { EventNonDateInput } from './event-parse'
 
 /*
 Information about what will happen when an external element is dragged-and-dropped

+ 33 - 0
packages/core/src/structs/event-def.ts

@@ -0,0 +1,33 @@
+import { Duration } from '../datelib/duration'
+import { EventUi } from '../component/event-ui'
+
+export interface EventDef {
+  defId: string
+  sourceId: string
+  publicId: string
+  groupId: string
+  allDay: boolean
+  hasEnd: boolean
+  recurringDef: { typeId: number, typeData: any, duration: Duration | null } | null
+  title: string
+  url: string
+  ui: EventUi
+  extendedProps: any
+}
+
+export type EventDefHash = { [defId: string]: EventDef }
+
+export const NON_DATE_PROPS = { // ...that are NOT in the EventUi object
+  id: String,
+  groupId: String,
+  title: String,
+  url: String,
+  extendedProps: null
+}
+
+export const DATE_PROPS = {
+  start: null,
+  date: null, // alias for start
+  end: null,
+  allDay: null
+}

+ 30 - 0
packages/core/src/structs/event-instance.ts

@@ -0,0 +1,30 @@
+import { DateRange } from '../datelib/date-range'
+import { guid } from '../util/misc'
+
+
+export interface EventInstance {
+  instanceId: string
+  defId: string
+  range: DateRange
+  forcedStartTzo: number | null
+  forcedEndTzo: number | null
+}
+
+
+export type EventInstanceHash = { [instanceId: string]: EventInstance }
+
+
+export function createEventInstance(
+  defId: string,
+  range: DateRange,
+  forcedStartTzo?: number,
+  forcedEndTzo?: number
+): EventInstance {
+  return {
+    instanceId: guid(),
+    defId,
+    range,
+    forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
+    forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
+  }
+}

+ 2 - 1
packages/core/src/structs/event-mutation.ts

@@ -1,6 +1,7 @@
 import { Duration } from '../datelib/duration'
 import { EventStore, createEmptyEventStore } from './event-store'
-import { EventDef, EventInstance } from './event'
+import { EventDef } from './event-def'
+import { EventInstance } from './event-instance'
 import { computeAlignedDayRange } from '../util/date'
 import { startOfDay } from '../datelib/marker'
 import { EventUiHash, EventUi } from '../component/event-ui'

+ 3 - 60
packages/core/src/structs/event.ts → packages/core/src/structs/event-parse.ts

@@ -1,12 +1,12 @@
 import { refineProps, guid } from '../util/misc'
 import { DateInput } from '../datelib/env'
-import { DateRange } from '../datelib/date-range'
 import { startOfDay } from '../datelib/marker'
 import { parseRecurring } from './recurring-event'
-import { Duration } from '../datelib/duration'
-import { UnscopedEventUiInput, EventUi, processUnscopedUiProps } from '../component/event-ui'
+import { UnscopedEventUiInput, processUnscopedUiProps } from '../component/event-ui'
 import { __assign } from 'tslib'
 import { ReducerContext } from '../reducers/ReducerContext'
+import { EventDef, DATE_PROPS, NON_DATE_PROPS } from './event-def'
+import { EventInstance, createEventInstance } from './event-instance'
 
 /*
 Utils for parsing event-input data. Each util parses a subset of the event-input's data.
@@ -32,51 +32,11 @@ export interface EventDateInput {
 export type EventInput = EventNonDateInput & EventDateInput
 export type EventInputTransformer = (eventInput: EventInput) => EventInput | null
 
-export interface EventDef {
-  defId: string
-  sourceId: string
-  publicId: string
-  groupId: string
-  allDay: boolean
-  hasEnd: boolean
-  recurringDef: { typeId: number, typeData: any, duration: Duration | null } | null
-  title: string
-  url: string
-  ui: EventUi
-  extendedProps: any
-}
-
-export interface EventInstance {
-  instanceId: string
-  defId: string
-  range: DateRange
-  forcedStartTzo: number | null
-  forcedEndTzo: number | null
-}
-
 export interface EventTuple {
   def: EventDef
   instance: EventInstance | null
 }
 
-export type EventInstanceHash = { [instanceId: string]: EventInstance }
-export type EventDefHash = { [defId: string]: EventDef }
-
-export const NON_DATE_PROPS = { // ...that are NOT in the EventUi object
-  id: String,
-  groupId: String,
-  title: String,
-  url: String,
-  extendedProps: null
-}
-
-export const DATE_PROPS = {
-  start: null,
-  date: null, // alias for start
-  end: null,
-  allDay: null
-}
-
 
 export function parseEvent(raw: EventInput, sourceId: string, context: ReducerContext, allowOpenRange?: boolean): EventTuple | null {
   let defaultAllDay = computeIsDefaultAllDay(sourceId, context)
@@ -148,23 +108,6 @@ export function parseEventDef(raw: EventNonDateInput, sourceId: string, allDay:
 export type eventDefParserFunc = (def: EventDef, props: any, leftovers: any) => void
 
 
-export function createEventInstance(
-  defId: string,
-  range: DateRange,
-  forcedStartTzo?: number,
-  forcedEndTzo?: number
-): EventInstance {
-  return {
-    instanceId: guid()
-,
-    defId,
-    range,
-    forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
-    forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
-  }
-}
-
-
 function parseSingle(raw: EventInput, defaultAllDay: boolean | null, context: ReducerContext, leftovers?, allowOpenRange?: boolean) {
   let props = pluckDateProps(raw, leftovers)
   let allDay = props.allDay

+ 1 - 1
packages/core/src/structs/event-source-parse.ts

@@ -1,4 +1,4 @@
-import { EventInput, EventInputTransformer } from './event'
+import { EventInput, EventInputTransformer } from './event-parse'
 import { EventSourceFunc } from '../event-sources/func-event-source'
 import { ConstraintInput, AllowFunc } from './constraint'
 import { EventSource, EventSourceSuccessResponseHandler, EventSourceErrorResponseHandler } from './event-source'

+ 1 - 1
packages/core/src/structs/event-source.ts

@@ -1,4 +1,4 @@
-import { EventInput, EventInputTransformer } from './event'
+import { EventInput, EventInputTransformer } from './event-parse'
 import { DateRange } from '../datelib/date-range'
 import { EventUi } from '../component/event-ui'
 import { ReducerContext } from '../reducers/ReducerContext'

+ 10 - 9
packages/core/src/structs/event-store.ts

@@ -1,12 +1,6 @@
-import {
-  EventInput,
-  EventDef,
-  EventDefHash,
-  EventInstance,
-  EventInstanceHash,
-  parseEvent,
-  EventTuple
-} from './event'
+import { EventDef, EventDefHash } from './event-def'
+import { EventInstance, EventInstanceHash } from './event-instance'
+import { EventInput, parseEvent, EventTuple } from './event-parse'
 import { filterHash } from '../util/object'
 import { ReducerContext } from '../reducers/ReducerContext'
 
@@ -21,6 +15,7 @@ export interface EventStore {
   instances: EventInstanceHash
 }
 
+
 export function parseEvents(
   rawEvents: EventInput[],
   sourceId: string,
@@ -40,6 +35,7 @@ export function parseEvents(
   return eventStore
 }
 
+
 export function eventTupleToStore(tuple: EventTuple, eventStore: EventStore = createEmptyEventStore()) {
   eventStore.defs[tuple.def.defId] = tuple.def
 
@@ -50,6 +46,7 @@ export function eventTupleToStore(tuple: EventTuple, eventStore: EventStore = cr
   return eventStore
 }
 
+
 // retrieves events that have the same groupId as the instance specified by `instanceId`
 // or they are the same as the instance.
 // why might instanceId not be in the store? an event from another calendar?
@@ -75,14 +72,17 @@ export function getRelevantEvents(eventStore: EventStore, instanceId: string): E
   return createEmptyEventStore()
 }
 
+
 function isEventDefsGrouped(def0: EventDef, def1: EventDef): boolean {
   return Boolean(def0.groupId && def0.groupId === def1.groupId)
 }
 
+
 export function createEmptyEventStore(): EventStore {
   return { defs: {}, instances: {} }
 }
 
+
 export function mergeEventStores(store0: EventStore, store1: EventStore): EventStore {
   return {
     defs: { ...store0.defs, ...store1.defs },
@@ -90,6 +90,7 @@ export function mergeEventStores(store0: EventStore, store1: EventStore): EventS
   }
 }
 
+
 export function filterEventStoreDefs(eventStore: EventStore, filterFunc: (eventDef: EventDef) => boolean): EventStore {
   let defs = filterHash(eventStore.defs, filterFunc)
   let instances = filterHash(eventStore.instances, function(instance: EventInstance) {

+ 1 - 1
packages/core/src/structs/recurring-event-simple.ts

@@ -3,7 +3,7 @@ import { Duration, createDuration, subtractDurations } from '../datelib/duration
 import { arrayToHash } from '../util/object'
 import { refineProps } from '../util/misc'
 import { RecurringType, ParsedRecurring } from './recurring-event'
-import { EventInput } from './event'
+import { EventInput } from './event-parse'
 import { DateRange, intersectRanges } from '../datelib/date-range'
 import { DateEnv } from '../datelib/env'
 import { createPlugin } from '../plugin-system'

+ 4 - 4
packages/core/src/structs/recurring-event.ts

@@ -1,4 +1,5 @@
-import { EventInput, EventDef, EventInstance, createEventInstance } from './event'
+import { EventDef } from './event-def'
+import { EventInstance, createEventInstance } from './event-instance'
 import { DateRange } from '../datelib/date-range'
 import { DateEnv } from '../datelib/env'
 import { Duration } from '../datelib/duration'
@@ -19,13 +20,13 @@ export interface ParsedRecurring {
 }
 
 export interface RecurringType {
-  parse: (rawEvent: EventInput, leftoverProps: any, dateEnv: DateEnv) => ParsedRecurring | null
+  parse: (rawEvent: any, leftoverProps: any, dateEnv: DateEnv) => ParsedRecurring | null
   expand: (typeData: any, framingRange: DateRange, dateEnv: DateEnv) => DateMarker[]
 }
 
 
 export function parseRecurring(
-  eventInput: EventInput,
+  eventInput: any,
   defaultAllDay: boolean | null,
   dateEnv: DateEnv,
   recurringTypes: RecurringType[],
@@ -57,7 +58,6 @@ export function parseRecurring(
         typeData: parsed.typeData,
         typeId: i
       }
-
     }
   }
 

+ 1 - 1
packages/core/src/types/input-types.ts

@@ -5,7 +5,7 @@ https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/fullcalenda
 
 import { ViewApi } from '../ViewApi'
 import { EventSourceInput } from '../structs/event-source-parse'
-import { EventInputTransformer } from '../structs/event'
+import { EventInputTransformer } from '../structs/event-parse'
 import { Duration, DurationInput } from '../datelib/duration'
 import { DateInput } from '../datelib/env'
 import { FormatterInput } from '../datelib/formatting'

+ 30 - 2
scripts/lib/rollup-dts.js

@@ -18,7 +18,7 @@ module.exports = function() {
     plugins: [
       dts(),
       {
-        resolveId(id) {
+        resolveId(id, source) {
           if (isScssPath(id)) {
             return false
           }
@@ -26,13 +26,41 @@ module.exports = function() {
             return { id, external: true }
           }
           return null
+        },
+        renderChunk(code, chunk) {
+          if (chunk.fileName === 'packages/core/dist/main.d.ts') {
+            return fixCode(code)
+          }
+          return code
         }
       }
     ],
-    //// uncomment to see all circular dependency warnings
+    // // uncomment to see all circular dependency warnings
     // onwarn(warning, warn) {
     //   console.log('WARNING', warning)
     //   warn(warning)
     // }
   }
 }
+
+
+// for a problem like this: https://github.com/Swatinem/rollup-plugin-dts/issues/39
+function fixCode(code) {
+  let replacements = {}
+
+  code = code.replace(/import \{(.*?)\} from '@fullcalendar\/core';?/, function(m0, m1) {
+    let matches = m1.matchAll(/(\w+) as (\w+\$\d+)/g)
+    for (let match of matches) {
+      replacements[match[2]] = match[1]
+    }
+    return ''
+  })
+
+  for (let find in replacements) {
+    let replacement = replacements[find]
+    find = find.replace('$', '\\$') // escape for regexp
+    code = code.replace(new RegExp(find, 'g'), replacement)
+  }
+
+  return code
+}