add internals file and use it to organize imports

This commit is contained in:
Kevin Jahns
2019-04-04 19:35:38 +02:00
parent 8dbd2c4696
commit 30bf3742c9
38 changed files with 378 additions and 260 deletions

View File

@@ -2,21 +2,26 @@
* @module structs
*/
import { Y } from '../utils/Y.js' // eslint-disable-line
import * as eventHandler from '../utils/EventHandler.js'
import { YEvent } from '../utils/YEvent.js' // eslint-disable-line
import { AbstractItem } from '../structs/AbstractItem.js' // eslint-disable-line
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
import { Encoder } from 'lib0/encoding.js' // eslint-disable-line
import { Transaction, nextID } from '../utils/Transaction.js' // eslint-disable-line
import {
removeEventHandlerListener,
callEventHandlerListeners,
addEventHandlerListener,
createEventHandler,
ItemType,
nextID,
isVisible,
ItemJSON,
ItemBinary,
createID,
getItemCleanStart,
getItemCleanEnd,
Y, Snapshot, Transaction, EventHandler, YEvent, AbstractItem, // eslint-disable-line
} from '../internals.js'
import * as map from 'lib0/map.js'
import { isVisible, Snapshot } from '../utils/Snapshot.js' // eslint-disable-line
import { ItemJSON } from '../structs/ItemJSON.js'
import { ItemBinary } from '../structs/ItemBinary.js'
import { ID, createID } from '../utils/ID.js' // eslint-disable-line
import { getItemCleanStart, getItemCleanEnd } from '../utils/StructStore.js'
import * as iterator from 'lib0/iterator.js'
import * as error from 'lib0/error.js'
import * as encoding from 'lib0/encoding.js' // eslint-disable-line
/**
* @template EventType
@@ -46,14 +51,14 @@ export class AbstractType {
this._length = 0
/**
* Event handlers
* @type {eventHandler.EventHandler<EventType,Transaction>}
* @type {EventHandler<EventType,Transaction>}
*/
this._eH = eventHandler.create()
this._eH = createEventHandler()
/**
* Deep event handlers
* @type {eventHandler.EventHandler<Array<YEvent>,Transaction>}
* @type {EventHandler<Array<YEvent>,Transaction>}
*/
this._dEH = eventHandler.create()
this._dEH = createEventHandler()
}
/**
@@ -80,7 +85,7 @@ export class AbstractType {
}
/**
* @param {Encoder} encoder
* @param {encoding.Encoder} encoder
*/
_write (encoder) {
throw new Error('unimplemented')
@@ -119,7 +124,7 @@ export class AbstractType {
* @param {any} event
*/
_callEventHandler (transaction, event) {
eventHandler.callEventListeners(this._eH, [event, transaction])
callEventHandlerListeners(this._eH, [event, transaction])
const changedParentTypes = transaction.changedParentTypes
/**
* @type {AbstractType<EventType>}
@@ -141,7 +146,7 @@ export class AbstractType {
* @param {function(EventType, Transaction):void} f Observer function
*/
observe (f) {
eventHandler.addEventListener(this._eH, f)
addEventHandlerListener(this._eH, f)
}
/**
@@ -150,7 +155,7 @@ export class AbstractType {
* @param {function(Array<YEvent>,Transaction):void} f Observer function
*/
observeDeep (f) {
eventHandler.addEventListener(this._dEH, f)
addEventHandlerListener(this._dEH, f)
}
/**
@@ -159,7 +164,7 @@ export class AbstractType {
* @param {function(EventType,Transaction):void} f Observer function
*/
unobserve (f) {
eventHandler.removeEventListener(this._eH, f)
removeEventHandlerListener(this._eH, f)
}
/**
@@ -168,7 +173,7 @@ export class AbstractType {
* @param {function(Array<YEvent>,Transaction):void} f Observer function
*/
unobserveDeep (f) {
eventHandler.removeEventListener(this._dEH, f)
removeEventHandlerListener(this._dEH, f)
}
/**

View File

@@ -2,11 +2,19 @@
* @module types
*/
import { AbstractItem } from '../structs/AbstractItem.js' // eslint-disable-line
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
import { AbstractType, typeArrayGet, typeArrayToArray, typeArrayForEach, typeArrayCreateIterator, typeArrayInsertGenerics, typeArrayDelete, typeArrayMap } from './AbstractType.js'
import { YEvent } from '../utils/YEvent.js'
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
import {
YEvent,
AbstractType,
typeArrayGet,
typeArrayToArray,
typeArrayForEach,
typeArrayCreateIterator,
typeArrayInsertGenerics,
typeArrayDelete,
typeArrayMap,
Transaction, ItemType, // eslint-disable-line
} from '../internals.js'
import * as decoding from 'lib0/decoding.js' // eslint-disable-line
/**

View File

@@ -2,11 +2,18 @@
* @module types
*/
import { AbstractType, typeMapDelete, typeMapSet, typeMapGet, typeMapHas, createMapIterator } from './AbstractType.js'
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
import { YEvent } from '../utils/YEvent.js'
import {
YEvent,
AbstractType,
typeMapDelete,
typeMapSet,
typeMapGet,
typeMapHas,
createMapIterator,
Transaction, ItemType, // eslint-disable-line
} from '../internals.js'
import * as decoding from 'lib0/decoding.js' // eslint-disable-line
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
import * as iterator from 'lib0/iterator.js'
/**

View File

@@ -2,17 +2,19 @@
* @module types
*/
import { ItemEmbed } from '../structs/ItemEmbed.js'
import { ItemString } from '../structs/ItemString.js'
import { ItemFormat } from '../structs/ItemFormat.js'
import { YEvent } from '../utils/YEvent.js'
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
import { AbstractType } from './AbstractType.js'
import { AbstractItem } from '../structs/AbstractItem.js' // eslint-disable-line
import { isVisible, Snapshot } from '../utils/Snapshot.js' // eslint-disable-line
import { getItemCleanStart, StructStore } from '../utils/StructStore.js' // eslint-disable-line
import { Transaction, nextID } from '../utils/Transaction.js' // eslint-disable-line
import { createID } from '../utils/ID.js'
import {
YEvent,
ItemEmbed,
ItemString,
ItemFormat,
AbstractType,
nextID,
createID,
getItemCleanStart,
isVisible,
ItemType, AbstractItem, Snapshot, StructStore, Transaction // eslint-disable-line
} from '../internals.js'
import * as decoding from 'lib0/decoding.js' // eslint-disable-line
/**

View File

@@ -2,15 +2,22 @@
* @module types
*/
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
import {
YXmlEvent,
AbstractType,
typeArrayMap,
typeArrayForEach,
typeMapGet,
typeMapGetAll,
typeArrayInsertGenerics,
typeArrayDelete,
typeMapSet,
typeMapDelete,
Transaction, ItemType, YXmlText, YXmlHook, Snapshot // eslint-disable-line
} from '../internals.js'
import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'
import { YXmlEvent } from './YXmlEvent.js'
import { ItemType } from '../structs/ItemType.js' // eslint-disable-line
import { YXmlText } from './YXmlText.js' // eslint-disable-line
import { YXmlHook } from './YXmlHook.js' // eslint-disable-line
import { AbstractType, typeArrayMap, typeArrayForEach, typeMapGet, typeMapGetAll, typeArrayInsertGenerics, typeArrayDelete, typeMapSet, typeMapDelete } from './AbstractType.js'
import { Snapshot } from '../utils/Snapshot.js' // eslint-disable-line
/**
* Define the elements to which a set of CSS queries apply.

View File

@@ -2,11 +2,10 @@
* @module types
*/
import { YEvent } from '../utils/YEvent.js'
import { AbstractType } from './AbstractType.js' // eslint-disable-line
import { Transaction } from '../utils/Transaction.js' // eslint-disable-line
import { YXmlElement, YXmlFragment } from './YXmlElement.js' // eslint-disable-line
import {
YEvent,
YXmlElement, YXmlFragment, Transaction // eslint-disable-line
} from '../internals.js'
/**
* An Event that describes changes on a YXml Element or Yxml Fragment

View File

@@ -2,7 +2,7 @@
* @module types
*/
import { YMap } from './YMap.js'
import { YMap } from '../internals.js'
import * as encoding from 'lib0/encoding.js'
import * as decoding from 'lib0/decoding.js'

View File

@@ -2,7 +2,8 @@
* @module types
*/
import { YText } from './YText.js'
import { YText } from '../internals.js'
import * as decoding from 'lib0/decoding.js' // eslint-disable-line
/**