mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 03:14:39 +08:00
Remove deprecations still supported by client
This commit is contained in:
parent
555681546d
commit
bd9983005c
47 changed files with 34 additions and 395 deletions
|
@ -1036,11 +1036,8 @@
|
||||||
3662409: src/nylas-spellchecker.js
|
3662409: src/nylas-spellchecker.js
|
||||||
3798011: src/global/nylas-exports.js
|
3798011: src/global/nylas-exports.js
|
||||||
3798011: src/global/nylas-exports.js
|
3798011: src/global/nylas-exports.js
|
||||||
5912469: src/deprecate-utils.js
|
|
||||||
3668481: src/config-schema.js
|
3668481: src/config-schema.js
|
||||||
5912469: src/deprecate-utils.js
|
|
||||||
3798011: src/global/nylas-exports.js
|
3798011: src/global/nylas-exports.js
|
||||||
5912469: src/deprecate-utils.js
|
|
||||||
3668481: src/config-schema.js
|
3668481: src/config-schema.js
|
||||||
4687050: src/global/nylas-observables.js
|
4687050: src/global/nylas-observables.js
|
||||||
4697858: node_modules/rx-lite/package.json
|
4697858: node_modules/rx-lite/package.json
|
||||||
|
|
|
@ -6,14 +6,11 @@ import {
|
||||||
DatabaseStore,
|
DatabaseStore,
|
||||||
SearchQueryParser,
|
SearchQueryParser,
|
||||||
ComponentRegistry,
|
ComponentRegistry,
|
||||||
NylasLongConnection,
|
|
||||||
FocusedContentStore,
|
FocusedContentStore,
|
||||||
MutableQuerySubscription,
|
MutableQuerySubscription,
|
||||||
} from 'nylas-exports'
|
} from 'nylas-exports'
|
||||||
import SearchActions from './search-actions'
|
import SearchActions from './search-actions'
|
||||||
|
|
||||||
const {LongConnectionStatus} = NylasAPI
|
|
||||||
|
|
||||||
class SearchQuerySubscription extends MutableQuerySubscription {
|
class SearchQuerySubscription extends MutableQuerySubscription {
|
||||||
|
|
||||||
constructor(searchQuery, accountIds) {
|
constructor(searchQuery, accountIds) {
|
||||||
|
@ -94,37 +91,37 @@ class SearchQuerySubscription extends MutableQuerySubscription {
|
||||||
}
|
}
|
||||||
|
|
||||||
performRemoteSearch() {
|
performRemoteSearch() {
|
||||||
const accountsSearched = new Set()
|
// const accountsSearched = new Set()
|
||||||
const allAccountsSearched = () => accountsSearched.size === this._accountIds.length
|
// const allAccountsSearched = () => accountsSearched.size === this._accountIds.length
|
||||||
this._connections = this._accountIds.map((accountId) => {
|
// this._connections = this._accountIds.map((accountId) => {
|
||||||
const conn = new NylasLongConnection({
|
// const conn = new NylasLongConnection({
|
||||||
accountId,
|
// accountId,
|
||||||
api: NylasAPI,
|
// api: NylasAPI,
|
||||||
path: `/threads/search/streaming?q=${encodeURIComponent(this._searchQuery)}`,
|
// path: `/threads/search/streaming?q=${encodeURIComponent(this._searchQuery)}`,
|
||||||
onResults: (results) => {
|
// onResults: (results) => {
|
||||||
if (!this._remoteResultsReceivedAt) {
|
// if (!this._remoteResultsReceivedAt) {
|
||||||
this._remoteResultsReceivedAt = Date.now();
|
// this._remoteResultsReceivedAt = Date.now();
|
||||||
}
|
// }
|
||||||
const threads = results[0];
|
// const threads = results[0];
|
||||||
this._remoteResultsCount += threads.length;
|
// this._remoteResultsCount += threads.length;
|
||||||
},
|
// },
|
||||||
onStatusChanged: (status) => {
|
// onStatusChanged: (status) => {
|
||||||
const hasClosed = [
|
// const hasClosed = [
|
||||||
LongConnectionStatus.Closed,
|
// LongConnectionStatus.Closed,
|
||||||
LongConnectionStatus.Ended,
|
// LongConnectionStatus.Ended,
|
||||||
].includes(status)
|
// ].includes(status)
|
||||||
|
|
||||||
if (hasClosed) {
|
// if (hasClosed) {
|
||||||
accountsSearched.add(accountId)
|
// accountsSearched.add(accountId)
|
||||||
if (allAccountsSearched()) {
|
// if (allAccountsSearched()) {
|
||||||
SearchActions.searchCompleted()
|
// SearchActions.searchCompleted()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
|
|
||||||
return conn.start()
|
// return conn.start()
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
performExtensionSearch() {
|
performExtensionSearch() {
|
||||||
|
|
|
@ -5,7 +5,6 @@ class TestExtension
|
||||||
|
|
||||||
describe 'ExtensionRegistry', ->
|
describe 'ExtensionRegistry', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@originalAdapters = ExtensionRegistry._deprecationAdapters
|
|
||||||
@registry = new ExtensionRegistry.Registry('Test')
|
@registry = new ExtensionRegistry.Registry('Test')
|
||||||
spyOn @registry, 'triggerDebounced'
|
spyOn @registry, 'triggerDebounced'
|
||||||
|
|
||||||
|
@ -43,13 +42,6 @@ describe 'ExtensionRegistry', ->
|
||||||
@registry.register({name: 'TestExtension'})
|
@registry.register({name: 'TestExtension'})
|
||||||
expect(@registry.extensions().length).toEqual 1
|
expect(@registry.extensions().length).toEqual 1
|
||||||
|
|
||||||
it 'calls deprecationAdapters if present for a role', ->
|
|
||||||
adapterSpy = jasmine.createSpy('adapterSpy').andCallFake (ext) -> ext
|
|
||||||
@registry = new ExtensionRegistry.Registry('Test', adapterSpy)
|
|
||||||
spyOn @registry, 'triggerDebounced'
|
|
||||||
@registry.register(TestExtension)
|
|
||||||
expect(adapterSpy.calls.length).toEqual 1
|
|
||||||
|
|
||||||
describe 'unregister', ->
|
describe 'unregister', ->
|
||||||
it 'unregisters the extension if it exists', ->
|
it 'unregisters the extension if it exists', ->
|
||||||
@registry.register(TestExtension)
|
@registry.register(TestExtension)
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
class DeprecateUtils
|
|
||||||
# See
|
|
||||||
# http://www.codeovertones.com/2011/08/how-to-print-stack-trace-anywhere-in.html
|
|
||||||
@parseStack: (stackString) ->
|
|
||||||
stack = stackString
|
|
||||||
.replace(/^[^\(]+?[\n$]/gm, '')
|
|
||||||
.replace(/^\s+at\s+/gm, '')
|
|
||||||
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
|
|
||||||
.split('\n')
|
|
||||||
return stack
|
|
||||||
|
|
||||||
@warn: (condition, message) ->
|
|
||||||
console.warn message if condition
|
|
||||||
|
|
||||||
@deprecate: (fnName, newName, ctx, fn) ->
|
|
||||||
if NylasEnv.inDevMode() and not NylasEnv.inSpecMode()
|
|
||||||
warn = true
|
|
||||||
newFn = =>
|
|
||||||
stack = DeprecateUtils.parseStack((new Error()).stack)
|
|
||||||
DeprecateUtils.warn(
|
|
||||||
warn,
|
|
||||||
"Deprecation warning! #{fnName} is deprecated and will be removed soon.
|
|
||||||
Use #{newName} instead.\nCheck your code at #{stack[1]}"
|
|
||||||
)
|
|
||||||
warn = false
|
|
||||||
return fn.apply(ctx, arguments)
|
|
||||||
return Object.assign(newFn, fn)
|
|
||||||
return fn
|
|
||||||
|
|
||||||
module.exports = DeprecateUtils
|
|
|
@ -1,5 +1,4 @@
|
||||||
import AccountStore from './stores/account-store'
|
import AccountStore from './stores/account-store'
|
||||||
import NylasLongConnection from './nylas-long-connection'
|
|
||||||
|
|
||||||
// A 0 code is when an error returns without a status code, like "ESOCKETTIMEDOUT"
|
// A 0 code is when an error returns without a status code, like "ESOCKETTIMEDOUT"
|
||||||
const TimeoutErrorCodes = [0, 408, "ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ENETDOWN", "ENETUNREACH"]
|
const TimeoutErrorCodes = [0, 408, "ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ENETDOWN", "ENETUNREACH"]
|
||||||
|
@ -52,7 +51,6 @@ class NylasAPI {
|
||||||
this.PermanentErrorCodes = PermanentErrorCodes
|
this.PermanentErrorCodes = PermanentErrorCodes
|
||||||
this.CanceledErrorCodes = CanceledErrorCodes
|
this.CanceledErrorCodes = CanceledErrorCodes
|
||||||
this.SampleTemporaryErrorCode = SampleTemporaryErrorCode
|
this.SampleTemporaryErrorCode = SampleTemporaryErrorCode
|
||||||
this.LongConnectionStatus = NylasLongConnection.Status
|
|
||||||
}
|
}
|
||||||
|
|
||||||
accessTokenForAccountId(aid) {
|
accessTokenForAccountId(aid) {
|
||||||
|
|
|
@ -1,246 +0,0 @@
|
||||||
/* eslint global-require: 0 */
|
|
||||||
import _ from 'underscore'
|
|
||||||
import url from 'url'
|
|
||||||
import {Emitter} from 'event-kit'
|
|
||||||
import {IdentityStore, APIError} from 'nylas-exports'
|
|
||||||
|
|
||||||
|
|
||||||
const CONNECTION_TIMEOUT = 60 * 60 * 1000
|
|
||||||
const PROCESS_BUFFER_THROTTLE = 400
|
|
||||||
const Status = {
|
|
||||||
None: 'none',
|
|
||||||
Connecting: 'connecting',
|
|
||||||
Connected: 'connected',
|
|
||||||
Closed: 'closed', // Socket has been closed for any reason
|
|
||||||
Ended: 'ended', // We have received 'end()' and will never open again.
|
|
||||||
}
|
|
||||||
|
|
||||||
class NylasLongConnection {
|
|
||||||
static Status = Status
|
|
||||||
|
|
||||||
constructor({api, accountId, ...opts} = {}) {
|
|
||||||
const {
|
|
||||||
path,
|
|
||||||
timeout,
|
|
||||||
onError,
|
|
||||||
onResults,
|
|
||||||
onStatusChanged,
|
|
||||||
throttleResultsInterval,
|
|
||||||
closeIfDataStopsInterval,
|
|
||||||
} = opts
|
|
||||||
|
|
||||||
this._api = api
|
|
||||||
this._accountId = accountId
|
|
||||||
this._status = Status.None
|
|
||||||
this._emitter = new Emitter()
|
|
||||||
this._req = null
|
|
||||||
this._buffer = ''
|
|
||||||
this._results = []
|
|
||||||
this._pingTimeout = null
|
|
||||||
this._httpStatusCode = null
|
|
||||||
|
|
||||||
// Options
|
|
||||||
this._path = path
|
|
||||||
this._timeout = timeout || CONNECTION_TIMEOUT
|
|
||||||
this._onError = onError || (() => {})
|
|
||||||
this._onResults = onResults || (() => {})
|
|
||||||
this._onStatusChanged = onStatusChanged || (() => {})
|
|
||||||
this._closeIfDataStopsInterval = closeIfDataStopsInterval
|
|
||||||
|
|
||||||
this._emitter.on('results-stopped-arriving', this._onResults)
|
|
||||||
this._processBufferThrottled = _.throttle(this._processBuffer, PROCESS_BUFFER_THROTTLE, {leading: false})
|
|
||||||
this._flushResultsSoon = () => {
|
|
||||||
if (this._results.length === 0) { return }
|
|
||||||
this._emitter.emit('results-stopped-arriving', this._results);
|
|
||||||
this._results = []
|
|
||||||
}
|
|
||||||
if (throttleResultsInterval != null) {
|
|
||||||
this._flushResultsSoon = _.throttle(this._flushResultsSoon, throttleResultsInterval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_processBuffer() {
|
|
||||||
const bufferJSONs = this._buffer.split('\n')
|
|
||||||
|
|
||||||
// We can't parse the last block - we don't know whether we've
|
|
||||||
// received the entire result or only part of it. Wait
|
|
||||||
// until we have more.
|
|
||||||
this._buffer = bufferJSONs.pop()
|
|
||||||
|
|
||||||
bufferJSONs.forEach((resultJSON) => {
|
|
||||||
if (resultJSON.length === 0) { return }
|
|
||||||
let result = null
|
|
||||||
try {
|
|
||||||
result = JSON.parse(resultJSON)
|
|
||||||
} catch (e) {
|
|
||||||
console.warn(`${resultJSON} could not be parsed as JSON.`, e)
|
|
||||||
}
|
|
||||||
if (result) {
|
|
||||||
this._results.push(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this._flushResultsSoon()
|
|
||||||
}
|
|
||||||
|
|
||||||
get accountId() {
|
|
||||||
return this._accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
get status() {
|
|
||||||
return this._status;
|
|
||||||
}
|
|
||||||
|
|
||||||
setStatus(status) {
|
|
||||||
if (this._status === status) { return }
|
|
||||||
this._status = status
|
|
||||||
this._onStatusChanged(this._status, this._httpStatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
onError(error) {
|
|
||||||
this._onError(error)
|
|
||||||
this.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
canStart() {
|
|
||||||
return [Status.None, Status.Closed].includes(this._status)
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
if (!this.canStart()) { return this }
|
|
||||||
if (this._req != null) { return this }
|
|
||||||
|
|
||||||
try {
|
|
||||||
const accountToken = this._api.accessTokenForAccountId(this._accountId)
|
|
||||||
const identityToken = (IdentityStore.identity() || {}).token || ''
|
|
||||||
if (!accountToken) {
|
|
||||||
throw new APIError({
|
|
||||||
statusCode: 401,
|
|
||||||
message: `Can't establish NylasLongConnection: No account token available for account ${this._accountId}`,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = url.parse(`${this._api.APIRoot}${this._path}`)
|
|
||||||
options.auth = `${accountToken}:${identityToken}`
|
|
||||||
|
|
||||||
let lib;
|
|
||||||
if (this._api.APIRoot.indexOf('https') === -1) {
|
|
||||||
lib = require('http')
|
|
||||||
} else {
|
|
||||||
lib = require('https')
|
|
||||||
}
|
|
||||||
|
|
||||||
this._req = lib.request(options, (responseStream) => {
|
|
||||||
this._req.responseStream = responseStream
|
|
||||||
this._httpStatusCode = responseStream.statusCode
|
|
||||||
if (responseStream.statusCode !== 200) {
|
|
||||||
responseStream.on('data', (chunk) => {
|
|
||||||
const error = new APIError({
|
|
||||||
response: responseStream,
|
|
||||||
message: chunk.toString('utf8'),
|
|
||||||
statusCode: responseStream.statusCode,
|
|
||||||
})
|
|
||||||
this.onError(error)
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
responseStream.setEncoding('utf8')
|
|
||||||
responseStream.on('error', (error) => {
|
|
||||||
this.onError(new APIError({error}))
|
|
||||||
})
|
|
||||||
responseStream.on('close', () => this.close())
|
|
||||||
responseStream.on('end', () => this.close())
|
|
||||||
responseStream.on('data', (chunk) => {
|
|
||||||
this.closeIfDataStops()
|
|
||||||
// Ignore redundant newlines sent as pings. Want to avoid
|
|
||||||
// calls to this.onProcessBuffer that contain no actual updates
|
|
||||||
if (chunk === '\n' && (this._buffer.length === 0 || _.last(this._buffer) === '\n')) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this._buffer += chunk
|
|
||||||
this._processBufferThrottled()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
this._req.setTimeout(60 * 60 * 1000)
|
|
||||||
this._req.setSocketKeepAlive(true)
|
|
||||||
this._req.on('error', (error) => {
|
|
||||||
this.onError(new APIError({error}))
|
|
||||||
})
|
|
||||||
this._req.on('socket', (socket) => {
|
|
||||||
this.setStatus(Status.Connecting)
|
|
||||||
socket.on('connect', () => {
|
|
||||||
this.setStatus(Status.Connected)
|
|
||||||
this.closeIfDataStops()
|
|
||||||
})
|
|
||||||
socket.on('error', (error) => {
|
|
||||||
this.onError(new APIError({error}))
|
|
||||||
})
|
|
||||||
socket.on('close', () => this.close())
|
|
||||||
socket.on('end', () => this.close())
|
|
||||||
})
|
|
||||||
// We `end` the request to start it.
|
|
||||||
// See https://github.com/nylas/nylas-mail/pull/2004
|
|
||||||
this._req.end()
|
|
||||||
return this
|
|
||||||
} catch (err) {
|
|
||||||
// start() should not throw any errors synchronously. Any errors should be
|
|
||||||
// asynchronously transmitted to the caller via `onError`
|
|
||||||
setTimeout(() => this.onError(err), 0)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closeIfDataStops() {
|
|
||||||
if (this._closeIfDataStopsInterval != null) {
|
|
||||||
clearTimeout(this._pingTimeout)
|
|
||||||
this._pingTimeout = setTimeout(() => {
|
|
||||||
this._pingTimeout = null
|
|
||||||
this.close()
|
|
||||||
}, this._closeIfDataStopsInterval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose(status) {
|
|
||||||
// Process the buffer one last time before disposing of the connection
|
|
||||||
// in case there is any data left that we haven't processed
|
|
||||||
this._processBuffer()
|
|
||||||
if (this._status !== status) {
|
|
||||||
this.setStatus(status)
|
|
||||||
}
|
|
||||||
clearTimeout(this._pingTimeout)
|
|
||||||
this._pingTimeout = null
|
|
||||||
this._httpStatusCode = null
|
|
||||||
this._buffer = ''
|
|
||||||
if (this._req) {
|
|
||||||
this._req.end()
|
|
||||||
this._req.abort()
|
|
||||||
this._req.removeAllListeners()
|
|
||||||
if (this._req.responseStream) {
|
|
||||||
this._req.responseStream.removeAllListeners()
|
|
||||||
}
|
|
||||||
if (this._req.socket) {
|
|
||||||
this._req.socket.removeAllListeners()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep an error handler to prevent from logging and reporting uncaught
|
|
||||||
// errors that may occur after aborting this current request.
|
|
||||||
// For example, if we manually close this connection before any data has
|
|
||||||
// been received (frequently happens when searching threads), this will
|
|
||||||
// throw an uncaught socket hang up error that will get unnecessarily
|
|
||||||
// reported to sentry
|
|
||||||
this._req.on('error', () => {})
|
|
||||||
this._req = null
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
close() {
|
|
||||||
return this.dispose(Status.Closed)
|
|
||||||
}
|
|
||||||
|
|
||||||
end() {
|
|
||||||
return this.dispose(Status.Ended)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NylasLongConnection
|
|
|
@ -9,7 +9,6 @@ FocusedPerspectiveStore = require('./focused-perspective-store').default
|
||||||
FocusedContentStore = require "./focused-content-store"
|
FocusedContentStore = require "./focused-content-store"
|
||||||
NylasAPIHelpers = require '../nylas-api-helpers'
|
NylasAPIHelpers = require '../nylas-api-helpers'
|
||||||
ExtensionRegistry = require('../../registries/extension-registry')
|
ExtensionRegistry = require('../../registries/extension-registry')
|
||||||
{deprecate} = require '../../deprecate-utils'
|
|
||||||
async = require 'async'
|
async = require 'async'
|
||||||
_ = require 'underscore'
|
_ = require 'underscore'
|
||||||
|
|
||||||
|
@ -67,24 +66,6 @@ class MessageStore extends NylasStore
|
||||||
extensions: =>
|
extensions: =>
|
||||||
ExtensionRegistry.MessageView.extensions()
|
ExtensionRegistry.MessageView.extensions()
|
||||||
|
|
||||||
# Public: Deprecated, use {ExtensionRegistry.MessageView.register} instead.
|
|
||||||
# Registers a new extension with the MessageStore. MessageStore extensions
|
|
||||||
# make it possible to customize message body parsing, and will do more in
|
|
||||||
# the future.
|
|
||||||
#
|
|
||||||
# - `ext` A {MessageViewExtension} instance.
|
|
||||||
#
|
|
||||||
registerExtension: (ext) =>
|
|
||||||
ExtensionRegistry.MessageView.register(ext)
|
|
||||||
|
|
||||||
# Public: Deprecated, use {ExtensionRegistry.MessageView.unregister} instead.
|
|
||||||
# Unregisters the extension provided from the MessageStore.
|
|
||||||
#
|
|
||||||
# - `ext` A {MessageViewExtension} instance.
|
|
||||||
#
|
|
||||||
unregisterExtension: (ext) =>
|
|
||||||
ExtensionRegistry.MessageView.unregister(ext)
|
|
||||||
|
|
||||||
_onExtensionsChanged: (role) ->
|
_onExtensionsChanged: (role) ->
|
||||||
MessageBodyProcessor = require('./message-body-processor').default
|
MessageBodyProcessor = require('./message-body-processor').default
|
||||||
MessageBodyProcessor.resetCache()
|
MessageBodyProcessor.resetCache()
|
||||||
|
@ -332,18 +313,6 @@ class MessageStore extends NylasStore
|
||||||
|
|
||||||
|
|
||||||
store = new MessageStore()
|
store = new MessageStore()
|
||||||
store.registerExtension = deprecate(
|
|
||||||
'MessageStore.registerExtension',
|
|
||||||
'ExtensionRegistry.MessageView.register',
|
|
||||||
store,
|
|
||||||
store.registerExtension
|
|
||||||
)
|
|
||||||
store.unregisterExtension = deprecate(
|
|
||||||
'MessageStore.unregisterExtension',
|
|
||||||
'ExtensionRegistry.MessageView.unregister',
|
|
||||||
store,
|
|
||||||
store.unregisterExtension
|
|
||||||
)
|
|
||||||
store.FolderNamesHiddenByDefault = FolderNamesHiddenByDefault
|
store.FolderNamesHiddenByDefault = FolderNamesHiddenByDefault
|
||||||
|
|
||||||
module.exports = store
|
module.exports = store
|
||||||
|
|
|
@ -30,19 +30,11 @@ class NylasComponentKit
|
||||||
exported = require "../components/#{path}"
|
exported = require "../components/#{path}"
|
||||||
return exported[prop]
|
return exported[prop]
|
||||||
|
|
||||||
@loadDeprecated = (prop, path, {instead} = {}) ->
|
|
||||||
{deprecate} = require '../deprecate-utils'
|
|
||||||
Object.defineProperty @prototype, prop,
|
|
||||||
get: deprecate prop, instead, @, ->
|
|
||||||
exported = NylasComponentKit.default(require "../components/#{path}")
|
|
||||||
return exported
|
|
||||||
enumerable: true
|
|
||||||
|
|
||||||
@load "Menu", 'menu'
|
@load "Menu", 'menu'
|
||||||
@load "DropZone", 'drop-zone'
|
@load "DropZone", 'drop-zone'
|
||||||
@load "Spinner", 'spinner'
|
@load "Spinner", 'spinner'
|
||||||
@load "Switch", 'switch'
|
@load "Switch", 'switch'
|
||||||
@loadDeprecated "Popover", 'popover', instead: 'Actions.openPopover'
|
|
||||||
@load "FixedPopover", 'fixed-popover'
|
@load "FixedPopover", 'fixed-popover'
|
||||||
@require "DatePickerPopover", 'date-picker-popover'
|
@require "DatePickerPopover", 'date-picker-popover'
|
||||||
@load "Modal", 'modal'
|
@load "Modal", 'modal'
|
||||||
|
@ -73,7 +65,6 @@ class NylasComponentKit
|
||||||
@load "InjectedComponent", 'injected-component'
|
@load "InjectedComponent", 'injected-component'
|
||||||
@load "TokenizingTextField", 'tokenizing-text-field'
|
@load "TokenizingTextField", 'tokenizing-text-field'
|
||||||
@load "ParticipantsTextField", 'participants-text-field'
|
@load "ParticipantsTextField", 'participants-text-field'
|
||||||
@loadDeprecated "MultiselectActionBar", 'multiselect-action-bar', instead: 'MultiselectToolbar'
|
|
||||||
@load "MultiselectToolbar", 'multiselect-toolbar'
|
@load "MultiselectToolbar", 'multiselect-toolbar'
|
||||||
@load "InjectedComponentSet", 'injected-component-set'
|
@load "InjectedComponentSet", 'injected-component-set'
|
||||||
@load "MetadataComposerToggleButton", 'metadata-composer-toggle-button'
|
@load "MetadataComposerToggleButton", 'metadata-composer-toggle-button'
|
||||||
|
|
|
@ -51,16 +51,6 @@ const lazyLoadAndRegisterTask = (klassName, path) => {
|
||||||
DatabaseObjectRegistry.register(klassName, () => exports[klassName]);
|
DatabaseObjectRegistry.register(klassName, () => exports[klassName]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const lazyLoadDeprecated = (prop, path, {instead} = {}) => {
|
|
||||||
const {deprecate} = require('../deprecate-utils');
|
|
||||||
Object.defineProperty(exports, prop, {
|
|
||||||
get: deprecate(prop, instead, exports, () => {
|
|
||||||
return resolveExport(require(`../${path}`));
|
|
||||||
}),
|
|
||||||
enumerable: true,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
lazyLoad(`Actions`, 'flux/actions');
|
lazyLoad(`Actions`, 'flux/actions');
|
||||||
|
|
||||||
|
@ -71,7 +61,6 @@ lazyLoad(`EdgehillAPI`, 'flux/edgehill-api');
|
||||||
lazyLoad(`LegacyEdgehillAPI`, 'flux/legacy-edgehill-api');
|
lazyLoad(`LegacyEdgehillAPI`, 'flux/legacy-edgehill-api');
|
||||||
lazyLoad(`NylasAPIHelpers`, 'flux/nylas-api-helpers');
|
lazyLoad(`NylasAPIHelpers`, 'flux/nylas-api-helpers');
|
||||||
lazyLoad(`NylasAPIRequest`, 'flux/nylas-api-request');
|
lazyLoad(`NylasAPIRequest`, 'flux/nylas-api-request');
|
||||||
lazyLoad(`NylasLongConnection`, 'flux/nylas-long-connection');
|
|
||||||
|
|
||||||
// The Database
|
// The Database
|
||||||
lazyLoad(`Matcher`, 'flux/attributes/matcher');
|
lazyLoad(`Matcher`, 'flux/attributes/matcher');
|
||||||
|
@ -196,7 +185,6 @@ lazyLoad(`FsUtils`, 'fs-utils');
|
||||||
lazyLoad(`CanvasUtils`, 'canvas-utils');
|
lazyLoad(`CanvasUtils`, 'canvas-utils');
|
||||||
lazyLoad(`RegExpUtils`, 'regexp-utils');
|
lazyLoad(`RegExpUtils`, 'regexp-utils');
|
||||||
lazyLoad(`MenuHelpers`, 'menu-helpers');
|
lazyLoad(`MenuHelpers`, 'menu-helpers');
|
||||||
lazyLoad(`DeprecateUtils`, 'deprecate-utils');
|
|
||||||
lazyLoad(`VirtualDOMUtils`, 'virtual-dom-utils');
|
lazyLoad(`VirtualDOMUtils`, 'virtual-dom-utils');
|
||||||
lazyLoad(`Spellchecker`, 'spellchecker');
|
lazyLoad(`Spellchecker`, 'spellchecker');
|
||||||
lazyLoad(`DraftHelpers`, 'flux/stores/draft-helpers');
|
lazyLoad(`DraftHelpers`, 'flux/stores/draft-helpers');
|
||||||
|
@ -231,14 +219,3 @@ lazyLoadWithGetter(`APMWrapper`, () => require('../apm-wrapper'));
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
lazyLoadWithGetter(`NylasTestUtils`, () => require('../../spec/nylas-test-utils'));
|
lazyLoadWithGetter(`NylasTestUtils`, () => require('../../spec/nylas-test-utils'));
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
lazyLoadDeprecated(`QuotedHTMLParser`, 'services/quoted-html-transformer', {
|
|
||||||
instead: 'QuotedHTMLTransformer',
|
|
||||||
});
|
|
||||||
lazyLoadDeprecated(`DraftStoreExtension`, 'flux/stores/draft-store-extension', {
|
|
||||||
instead: 'ComposerExtension',
|
|
||||||
});
|
|
||||||
lazyLoadDeprecated(`MessageStoreExtension`, 'flux/stores/message-store-extension', {
|
|
||||||
instead: 'MessageViewExtension',
|
|
||||||
});
|
|
||||||
|
|
|
@ -6,16 +6,14 @@ export class Registry {
|
||||||
|
|
||||||
static include = includeModule;
|
static include = includeModule;
|
||||||
|
|
||||||
constructor(name, deprecationAdapter = (ext) => ext) {
|
constructor(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this._deprecationAdapter = deprecationAdapter;
|
|
||||||
this._registry = new Map();
|
this._registry = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
register(ext, {priority = 0} = {}) {
|
register(extension, {priority = 0} = {}) {
|
||||||
this.validateExtension(ext, 'register');
|
this.validateExtension(extension, 'register');
|
||||||
const extension = this._deprecationAdapter(ext)
|
this._registry.set(extension.name, {extension, priority});
|
||||||
this._registry.set(ext.name, {extension, priority});
|
|
||||||
this.triggerDebounced();
|
this.triggerDebounced();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,10 +288,6 @@ class ThemeManager
|
||||||
themePaths = []
|
themePaths = []
|
||||||
for themeName in @getEnabledThemeNames()
|
for themeName in @getEnabledThemeNames()
|
||||||
if themePath = @packageManager.resolvePackagePath(themeName)
|
if themePath = @packageManager.resolvePackagePath(themeName)
|
||||||
deprecatedPath = path.join(themePath, 'stylesheets')
|
themePaths.push(path.join(themePath, 'styles'))
|
||||||
if fs.isDirectorySync(deprecatedPath)
|
|
||||||
themePaths.push(deprecatedPath)
|
|
||||||
else
|
|
||||||
themePaths.push(path.join(themePath, 'styles'))
|
|
||||||
|
|
||||||
themePaths.filter (themePath) -> fs.isDirectorySync(themePath)
|
themePaths.filter (themePath) -> fs.isDirectorySync(themePath)
|
||||||
|
|
Loading…
Add table
Reference in a new issue