|
@@ -3,6 +3,7 @@ const electron = require('electron')
|
|
|
const bindings = process.atomBinding('session')
|
|
|
|
|
|
const PERSIST_PREFIX = 'persist:'
|
|
|
+const Session = new EventEmitter()
|
|
|
|
|
|
// Wrapper of binding.fromPartition that checks for ready event.
|
|
|
const fromPartition = function (partition, persist) {
|
|
@@ -14,7 +15,7 @@ const fromPartition = function (partition, persist) {
|
|
|
}
|
|
|
|
|
|
// Returns the Session from |partition| string.
|
|
|
-exports.fromPartition = function (partition = '') {
|
|
|
+Session.fromPartition = function (partition = '') {
|
|
|
if (partition === '') return exports.defaultSession
|
|
|
|
|
|
if (partition.startsWith(PERSIST_PREFIX)) {
|
|
@@ -25,7 +26,7 @@ exports.fromPartition = function (partition = '') {
|
|
|
}
|
|
|
|
|
|
// Returns the default session.
|
|
|
-Object.defineProperty(exports, 'defaultSession', {
|
|
|
+Object.defineProperty(Session, 'defaultSession', {
|
|
|
enumerable: true,
|
|
|
get: function () {
|
|
|
return fromPartition('', false)
|
|
@@ -35,7 +36,9 @@ Object.defineProperty(exports, 'defaultSession', {
|
|
|
const wrapSession = function (session) {
|
|
|
// Session is an EventEmitter.
|
|
|
Object.setPrototypeOf(session, EventEmitter.prototype)
|
|
|
- process.emit('session-created', session)
|
|
|
+ Session.emit('session-created', session)
|
|
|
}
|
|
|
|
|
|
bindings._setWrapSession(wrapSession)
|
|
|
+
|
|
|
+module.exports = Session
|