mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #12350 from atom/mq-js-exports
Rewrite exports/atom.coffee as JS
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
TextBuffer = require 'text-buffer'
|
||||
{Point, Range} = TextBuffer
|
||||
{File, Directory} = require 'pathwatcher'
|
||||
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
|
||||
Grim = require 'grim'
|
||||
|
||||
module.exports =
|
||||
BufferedNodeProcess: require '../src/buffered-node-process'
|
||||
BufferedProcess: require '../src/buffered-process'
|
||||
GitRepository: require '../src/git-repository'
|
||||
Notification: require '../src/notification'
|
||||
TextBuffer: TextBuffer
|
||||
Point: Point
|
||||
Range: Range
|
||||
File: File
|
||||
Directory: Directory
|
||||
Emitter: Emitter
|
||||
Disposable: Disposable
|
||||
CompositeDisposable: CompositeDisposable
|
||||
|
||||
# Shell integration is required by both Squirrel and Settings-View
|
||||
if process.platform is 'win32'
|
||||
module.exports.WinShell = require '../src/main-process/win-shell'
|
||||
|
||||
# The following classes can't be used from a Task handler and should therefore
|
||||
# only be exported when not running as a child node process
|
||||
unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
|
||||
module.exports.Task = require '../src/task'
|
||||
|
||||
TextEditor = (params) ->
|
||||
atom.workspace.buildTextEditor(params)
|
||||
|
||||
TextEditor.prototype = require('../src/text-editor').prototype
|
||||
|
||||
Object.defineProperty module.exports, 'TextEditor',
|
||||
enumerable: true
|
||||
get: ->
|
||||
Grim.deprecate """
|
||||
The `TextEditor` constructor is no longer public.
|
||||
|
||||
To construct a text editor, use `atom.workspace.buildTextEditor()`.
|
||||
To check if an object is a text editor, use `atom.workspace.isTextEditor(object)`.
|
||||
"""
|
||||
TextEditor
|
||||
58
exports/atom.js
Normal file
58
exports/atom.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/** @babel */
|
||||
|
||||
import TextBuffer, {Point, Range} from 'text-buffer'
|
||||
import {File, Directory} from 'pathwatcher'
|
||||
import {Emitter, Disposable, CompositeDisposable} from 'event-kit'
|
||||
import Grim from 'grim'
|
||||
import dedent from 'dedent'
|
||||
import BufferedNodeProcess from '../src/buffered-node-process'
|
||||
import BufferedProcess from '../src/buffered-process'
|
||||
import GitRepository from '../src/git-repository'
|
||||
import Notification from '../src/notification'
|
||||
|
||||
const atomExport = {
|
||||
BufferedNodeProcess,
|
||||
BufferedProcess,
|
||||
GitRepository,
|
||||
Notification,
|
||||
TextBuffer,
|
||||
Point,
|
||||
Range,
|
||||
File,
|
||||
Directory,
|
||||
Emitter,
|
||||
Disposable,
|
||||
CompositeDisposable
|
||||
}
|
||||
|
||||
// Shell integration is required by both Squirrel and Settings-View
|
||||
if (process.platform === 'win32') {
|
||||
atomExport.WinShell = require('../src/main-process/win-shell')
|
||||
}
|
||||
|
||||
// The following classes can't be used from a Task handler and should therefore
|
||||
// only be exported when not running as a child node process
|
||||
if (!process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE) {
|
||||
atomExport.Task = require('../src/task')
|
||||
|
||||
const TextEditor = (params) => {
|
||||
return atom.workspace.buildTextEditor(params)
|
||||
}
|
||||
|
||||
TextEditor.prototype = require('../src/text-editor').prototype
|
||||
|
||||
Object.defineProperty(atomExport, 'TextEditor', {
|
||||
enumerable: true,
|
||||
get () {
|
||||
Grim.deprecate(dedent`
|
||||
The \`TextEditor\` constructor is no longer public.
|
||||
|
||||
To construct a text editor, use \`atom.workspace.buildTextEditor()\`.
|
||||
To check if an object is a text editor, use \`atom.workspace.isTextEditor(object)\`.
|
||||
`)
|
||||
return TextEditor
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default atomExport
|
||||
@@ -196,8 +196,8 @@ resolveModulePath = (relativePath, parentModule) ->
|
||||
registerBuiltins = (devMode) ->
|
||||
if devMode or not cache.resourcePath.startsWith("#{process.resourcesPath}#{path.sep}")
|
||||
fs = require 'fs-plus'
|
||||
atomCoffeePath = path.join(cache.resourcePath, 'exports', 'atom.coffee')
|
||||
cache.builtins.atom = atomCoffeePath if fs.isFileSync(atomCoffeePath)
|
||||
atomJsPath = path.join(cache.resourcePath, 'exports', 'atom.js')
|
||||
cache.builtins.atom = atomJsPath if fs.isFileSync(atomJsPath)
|
||||
cache.builtins.atom ?= path.join(cache.resourcePath, 'exports', 'atom.js')
|
||||
|
||||
electronAsarRoot = path.join(process.resourcesPath, 'electron.asar')
|
||||
|
||||
Reference in New Issue
Block a user