Socket
Socket
Sign inDemoInstall

nuclide-commons-atom

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuclide-commons-atom - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

destroyItemWhere.js

70

observePaneItemVisibility.js

@@ -7,2 +7,3 @@ 'use strict';

exports.default = observePaneItemVisibility;
exports.observeVisibleItems = observeVisibleItems;

@@ -21,2 +22,8 @@ var _event;

var _collection;
function _load_collection() {
return _collection = require('nuclide-commons/collection');
}
var _rxjsBundlesRxMinJs = require('rxjs/bundles/Rx.min.js');

@@ -34,32 +41,10 @@

// have some false positives when an item is its pane's active item but its dock is hidden.
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
* @format
*/
function observePaneItemVisibility(item) {
// If this is a version of Atom that doesn't have Docks, return an empty observable. Until they
// land, the functionality is provided by the workspace views package, which calls
// `didChangeVisibility()` on items automatically.
// TODO cleanup post Atom 1.17
if (atom.workspace.getPaneContainers == null) {
return _rxjsBundlesRxMinJs.Observable.empty();
}
patchDocks();
const workspaceEl = atom.workspace.getElement();
return _rxjsBundlesRxMinJs.Observable.combineLatest(
// atom.workspace.reset() (in tests) resets all the panes.
// Pass in atom.workspace.getElement() to act as a cache-breaker.
// $FlowFixMe: Add atom.workspace.getElement() after 1.17.
observeActiveItems(atom.workspace.getElement()),
// $FlowFixMe: Add atom.workspace.getElement() after 1.17.
observePaneContainerVisibilities(atom.workspace.getElement())).map(([activeItems, locationVisibilities]) => {
// Pass in the workspace dom element to act as a cache-breaker.
observeActiveItems(workspaceEl), observePaneContainerVisibilities(workspaceEl)).map(([activeItems, locationVisibilities]) => {
// If it's not active, it's not visible.

@@ -70,7 +55,30 @@ if (!activeItems.has(item)) {

// If it's active, it's only visible if its container is.
// $FlowFixMe: Add atom.workspace.paneContainerForItem() after 1.17.
const paneContainer = atom.workspace.paneContainerForItem(item);
const location = paneContainer && paneContainer.getLocation();
return Boolean(locationVisibilities[location]);
return paneContainer == null ? false : locationVisibilities[paneContainer.getLocation()];
}).distinctUntilChanged();
} /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
* @format
*/
function observeVisibleItems() {
patchDocks();
const workspaceEl = atom.workspace.getElement();
return _rxjsBundlesRxMinJs.Observable.combineLatest(observeActiveItems(workspaceEl), observePaneContainerVisibilities(workspaceEl)).map(([activeItems, locationVisibilities]) => {
// If it's not active, it's not visible.
// If it's active, it's only visible if its container is.
return (0, (_collection || _load_collection()).setFilter)(activeItems, item => {
const paneContainer = atom.workspace.paneContainerForItem(item);
const location = paneContainer && paneContainer.getLocation();
return location ? Boolean(locationVisibilities[location]) : false;
});
});
}

@@ -80,5 +88,3 @@

// An observable that emits `{pane, item}` whenever the active item of a pane changes.
const itemActivations = _rxjsBundlesRxMinJs.Observable.merge(
// $FlowFixMe: Add `getPaneContainers()` to the type defs once Atom 1.17 lands.
...atom.workspace.getPaneContainers().map(paneContainer => {
const itemActivations = _rxjsBundlesRxMinJs.Observable.merge(...atom.workspace.getPaneContainers().map(paneContainer => {
const observePanes = paneContainer.observePanes.bind(paneContainer);

@@ -134,3 +140,3 @@ return (0, (_event || _load_event()).observableFromSubscribeFunction)(observePanes).flatMap(pane => {

// HACK: Monkey-patch Docks in order to observe visibility toggling.
// TODO: Get a `Dock::observeVisibility()` upstreamed and use that API instead.
// TODO: Use `Dock::observeVisibility` once atom/atom#14736 is in our lowest-supported version
let docksPatched = false;

@@ -137,0 +143,0 @@ const dockStateChanges = new _rxjsBundlesRxMinJs.Subject();

{
"name": "nuclide-commons-atom",
"version": "0.1.8",
"version": "0.1.9",
"description": "Common Nuclide node modules (for use with Atom only).",

@@ -16,3 +16,3 @@ "license": "BSD-3-Clause",

"log4js": "1.1.1",
"nuclide-commons": "0.1.8",
"nuclide-commons": "0.1.9",
"rxjs": "5.3.1",

@@ -19,0 +19,0 @@ "semver": "5.3.0",

@@ -11,10 +11,2 @@ 'use strict';

var _semver;
function _load_semver() {
return _semver = _interopRequireDefault(require('semver'));
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -32,34 +24,5 @@ * The object used as items in locations. This is based on the supported interface for items in Atom

*/
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
* @format
*/
/**
* A small compatibilty stub for interop with Nuclide, which still supports Atom 1.16.
* For Atom 1.17+ this just uses the native Atom APIs.
* TODO(matthewwithanm): Delete this and refactor to workspace
* API once Nuclide uses 1.17.
*/
function getDocksWorkspaceViewsService() {
return {
registerLocation: () => new _atom.Disposable(() => {}),
addOpener: opener => atom.workspace.addOpener(opener),
destroyWhere(predicate) {
atom.workspace.getPanes().forEach(pane => {
pane.getItems().forEach(item => {
if (predicate(item)) {
pane.destroyItem(item, true);
}
});
});
},
open(uri, options) {

@@ -71,34 +34,37 @@ // eslint-disable-next-line nuclide-internal/atom-apis

const visible = options && options.visible;
if (visible === true) {
// eslint-disable-next-line nuclide-internal/atom-apis
atom.workspace.open(uri, { searchAllPanes: true });
} else if (visible === false) {
// TODO(jxg) remove this once Atom 1.17 lands.
if (typeof atom.workspace.hide === 'function') {
// Atom version >=1.17
switch (visible) {
case true:
// eslint-disable-next-line nuclide-internal/atom-apis
atom.workspace.open(uri, { searchAllPanes: true });
break;
case false:
atom.workspace.hide(uri);
} else {
// Atom version <1.17
const hasItem = atom.workspace.getPaneItems().some(item => typeof item.getURI === 'function' && item.getURI() === uri);
if (hasItem) {
// TODO(matthewwithanm): Add this to the Flow defs once docks land
// $FlowIgnore
atom.workspace.toggle(uri);
}
}
} else {
// TODO(matthewwithanm): Add this to the Flow defs once docks land
// $FlowIgnore
atom.workspace.toggle(uri);
break;
default:
atom.workspace.toggle(uri);
}
}
};
}
} /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
* @format
*/
/**
* A small compatibilty stub for interop with Nuclide, which still supports Atom 1.16.
* For Atom 1.17+ this just uses the native Atom APIs.
* TODO(matthewwithanm): Delete this and refactor to workspace
* API once Nuclide uses 1.17.
*/
function consumeWorkspaceViewsCompat(callback) {
if ((_semver || _load_semver()).default.gte(atom.getVersion(), '1.17.0')) {
callback(getDocksWorkspaceViewsService());
return new _atom.Disposable();
}
return atom.packages.serviceHub.consume('nuclide.workspace-views', '0.0.0', callback);
callback(getDocksWorkspaceViewsService());
return new _atom.Disposable();
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc