mirror of
https://github.com/atom/atom.git
synced 2026-02-06 20:55:33 -05:00
☠☕ Decaffeinate src/theme-package.coffee
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
path = require 'path'
|
||||
Package = require './package'
|
||||
|
||||
module.exports =
|
||||
class ThemePackage extends Package
|
||||
getType: -> 'theme'
|
||||
|
||||
getStyleSheetPriority: -> 1
|
||||
|
||||
enable: ->
|
||||
@config.unshiftAtKeyPath('core.themes', @name)
|
||||
|
||||
disable: ->
|
||||
@config.removeAtKeyPath('core.themes', @name)
|
||||
|
||||
preload: ->
|
||||
@loadTime = 0
|
||||
@configSchemaRegisteredOnLoad = @registerConfigSchemaFromMetadata()
|
||||
|
||||
finishLoading: ->
|
||||
@path = path.join(@packageManager.resourcePath, @path)
|
||||
|
||||
load: ->
|
||||
@loadTime = 0
|
||||
@configSchemaRegisteredOnLoad = @registerConfigSchemaFromMetadata()
|
||||
this
|
||||
|
||||
activate: ->
|
||||
@activationPromise ?= new Promise (resolve, reject) =>
|
||||
@resolveActivationPromise = resolve
|
||||
@rejectActivationPromise = reject
|
||||
@measure 'activateTime', =>
|
||||
try
|
||||
@loadStylesheets()
|
||||
@activateNow()
|
||||
catch error
|
||||
@handleError("Failed to activate the #{@name} theme", error)
|
||||
55
src/theme-package.js
Normal file
55
src/theme-package.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const path = require('path')
|
||||
const Package = require('./package')
|
||||
|
||||
module.exports =
|
||||
class ThemePackage extends Package {
|
||||
getType () {
|
||||
return 'theme'
|
||||
}
|
||||
|
||||
getStyleSheetPriority () {
|
||||
return 1
|
||||
}
|
||||
|
||||
enable () {
|
||||
this.config.unshiftAtKeyPath('core.themes', this.name)
|
||||
}
|
||||
|
||||
disable () {
|
||||
this.config.removeAtKeyPath('core.themes', this.name)
|
||||
}
|
||||
|
||||
preload () {
|
||||
this.loadTime = 0
|
||||
this.configSchemaRegisteredOnLoad = this.registerConfigSchemaFromMetadata()
|
||||
}
|
||||
|
||||
finishLoading () {
|
||||
this.path = path.join(this.packageManager.resourcePath, this.path)
|
||||
}
|
||||
|
||||
load () {
|
||||
this.loadTime = 0
|
||||
this.configSchemaRegisteredOnLoad = this.registerConfigSchemaFromMetadata()
|
||||
return this
|
||||
}
|
||||
|
||||
activate () {
|
||||
if (this.activationPromise == null) {
|
||||
this.activationPromise = new Promise((resolve, reject) => {
|
||||
this.resolveActivationPromise = resolve
|
||||
this.rejectActivationPromise = reject
|
||||
this.measure('activateTime', () => {
|
||||
try {
|
||||
this.loadStylesheets()
|
||||
this.activateNow()
|
||||
} catch (error) {
|
||||
this.handleError(`Failed to activate the ${this.name} theme`, error)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return this.activationPromise
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user