Socket
Socket
Sign inDemoInstall

nuclide-commons-atom

Package Overview
Dependencies
Maintainers
3
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.4.0 to 0.5.0

dock-for-location.js

10

ActiveEditorRegistry.js

@@ -9,4 +9,2 @@ 'use strict';

var _atom = require('atom');
var _rxjsBundlesRxMinJs = require('rxjs/bundles/Rx.min.js');

@@ -20,2 +18,8 @@

var _UniversalDisposable;
function _load_UniversalDisposable() {
return _UniversalDisposable = _interopRequireDefault(require('nuclide-commons/UniversalDisposable'));
}
var _event;

@@ -89,3 +93,3 @@

this._newProviderEvents.next();
return new _atom.Disposable(() => {
return new (_UniversalDisposable || _load_UniversalDisposable()).default(() => {
this._providerRegistry.removeProvider(provider);

@@ -92,0 +96,0 @@ });

@@ -7,4 +7,10 @@ 'use strict';

var _atom = require('atom');
var _UniversalDisposable;
function _load_UniversalDisposable() {
return _UniversalDisposable = _interopRequireDefault(require('nuclide-commons/UniversalDisposable'));
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -32,3 +38,3 @@ * Copyright (c) 2017-present, Facebook, Inc.

trackEvents(events) {
return new _atom.Disposable();
return new (_UniversalDisposable || _load_UniversalDisposable()).default();
},

@@ -35,0 +41,0 @@ trackImmediate(eventName, values) {

@@ -7,4 +7,10 @@ 'use strict';

var _atom = require('atom');
var _UniversalDisposable;
function _load_UniversalDisposable() {
return _UniversalDisposable = _interopRequireDefault(require('nuclide-commons/UniversalDisposable'));
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -89,3 +95,3 @@ * This class represents a collection of context menu items that have been registered with Atom's

// disposed.
return new _atom.Disposable(() => {
return new (_UniversalDisposable || _load_UniversalDisposable()).default(() => {
const index = this._items.indexOf(value);

@@ -92,0 +98,0 @@ this._items.splice(index, 1);

@@ -12,2 +12,8 @@ 'use strict';

var _observable;
function _load_observable() {
return _observable = require('nuclide-commons/observable');
}
var _rxjsBundlesRxMinJs = require('rxjs/bundles/Rx.min.js');

@@ -27,13 +33,13 @@

const DEFAULT_PANE_DEBOUNCE_INTERVAL_MS = 100; /**
* 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
*/
/**
* 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
*/

@@ -49,2 +55,3 @@ /**

const DEFAULT_PANE_DEBOUNCE_INTERVAL_MS = 100;
const DEFAULT_EDITOR_DEBOUNCE_INTERVAL_MS = 300;

@@ -59,3 +66,3 @@ const DEFAULT_POSITION_DEBOUNCE_INTERVAL_MS = 300;

return atom.workspace.observeActivePaneItem(callback);
}).debounceTime(debounceInterval);
}).let((0, (_observable || _load_observable()).fastDebounce)(debounceInterval));
}

@@ -75,10 +82,10 @@

function editorChangesDebounced(editor, debounceInterval = DEFAULT_EDITOR_DEBOUNCE_INTERVAL_MS) {
return (0, (_event || _load_event()).observableFromSubscribeFunction)(callback => editor.onDidChange(callback))
return (0, (_event || _load_event()).observableFromSubscribeFunction)(callback => editor.getBuffer().onDidChangeText(() => callback()))
// Debounce manually rather than using editor.onDidStopChanging so that the debounce time is
// configurable.
.debounceTime(debounceInterval);
.let((0, (_observable || _load_observable()).fastDebounce)(debounceInterval));
}
function editorScrollTopDebounced(editor, debounceInterval = DEFAULT_EDITOR_DEBOUNCE_INTERVAL_MS) {
return (0, (_event || _load_event()).observableFromSubscribeFunction)(callback => atom.views.getView(editor).onDidChangeScrollTop(callback)).debounceTime(debounceInterval);
return (0, (_event || _load_event()).observableFromSubscribeFunction)(callback => atom.views.getView(editor).onDidChangeScrollTop(callback)).let((0, (_observable || _load_observable()).fastDebounce)(debounceInterval));
}

@@ -90,3 +97,3 @@

return observeActiveEditorsDebounced(editorDebounceInterval).switchMap(editor => {
return editor == null ? _rxjsBundlesRxMinJs.Observable.of(null) : (0, (_textEditor || _load_textEditor()).getCursorPositions)(editor).debounceTime(positionDebounceInterval).map(position => {
return editor == null ? _rxjsBundlesRxMinJs.Observable.of(null) : (0, (_textEditor || _load_textEditor()).getCursorPositions)(editor).let((0, (_observable || _load_observable()).fastDebounce)(positionDebounceInterval)).map(position => {
if (!(editor != null)) {

@@ -93,0 +100,0 @@ throw new Error('Invariant violation: "editor != null"');

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

exports.default = {
formatKeyPath,
setPackageName,

@@ -148,0 +149,0 @@ getPackageName,

@@ -19,24 +19,32 @@ 'use strict';

var _path2 = _interopRequireDefault(require('path'));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const { devMode } = atom.getLoadSettings(); /**
* 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
*/
// eslint-disable-line rulesdir/prefer-nuclide-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
*/
/* global localStorage */
const { devMode } = atom.getLoadSettings();
class FeatureLoader {
constructor({ config, features, pkgName }) {
constructor({ features, path: _path }) {
this._path = _path;
this._features = features;
this._loadDisposable = new (_UniversalDisposable || _load_UniversalDisposable()).default();
this._pkgName = pkgName;
this._pkgName = packageNameFromPath(this._path);
this._config = {

@@ -86,3 +94,3 @@ use: {

const featurePkg = feature.pkg;
const name = featurePkg.name;
const name = packageNameFromPath(feature.path);

@@ -152,6 +160,6 @@ // Sample packages are disabled by default. They are meant for development

const enabled = atom.config.get(this.useKeyPathForFeature(feature));
const shouldEnable = enabled == null ? this._config.use.properties[feature.pkg.name].default : enabled;
const shouldEnable = enabled == null ? this._config.use.properties[packageNameFromPath(feature.path)].default : enabled;
if (shouldEnable) {
atom.packages.loadPackage(feature.dirname);
atom.packages.loadPackage(feature.path);
}

@@ -191,3 +199,3 @@ });

if (atom.config.get(this.useKeyPathForFeature(feature))) {
atom.packages.activatePackage(feature.dirname);
atom.packages.activatePackage(feature.path);
}

@@ -199,3 +207,3 @@ });

if (event.newValue === true) {
atom.packages.activatePackage(feature.dirname);
atom.packages.activatePackage(feature.path);
} else if (event.newValue === false) {

@@ -241,3 +249,3 @@ safeDeactivate(feature);

useKeyPathForFeature(feature) {
return `${this._pkgName}.use.${feature.pkg.name}`;
return `${this._pkgName}.use.${packageNameFromPath(feature.path)}`;
}

@@ -248,3 +256,3 @@ }

function safeDeactivate(feature, suppressSerialization = false) {
const name = feature.pkg.name;
const name = packageNameFromPath(feature.path);
try {

@@ -262,3 +270,3 @@ const pack = atom.packages.getLoadedPackage(name);

function safeSerialize(feature) {
const name = feature.pkg.name;
const name = packageNameFromPath(feature.path);
try {

@@ -274,2 +282,8 @@ const pack = atom.packages.getActivePackage(name);

}
}
// this could be inlined into its use above, but this makes the intent more
// explicit, and unifies it in the case this ever needs to change.
function packageNameFromPath(pkgPath) {
return _path2.default.basename(pkgPath);
}

@@ -35,13 +35,15 @@ 'use strict';

let goToLocation = exports.goToLocation = (() => {
var _ref7 = (0, _asyncToGenerator.default)(function* (file, options) {
var _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
var _ref8 = (0, _asyncToGenerator.default)(function* (file, options) {
var _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
const center_ = (_ref = options) != null ? _ref.center : _ref;
const center = center_ == null ? true : center_;
const activatePane_ = (_ref2 = options) != null ? _ref2.activatePane : _ref2;
const moveCursor_ = (_ref2 = options) != null ? _ref2.moveCursor : _ref2;
const moveCursor = moveCursor_ == null ? true : moveCursor_;
const activatePane_ = (_ref3 = options) != null ? _ref3.activatePane : _ref3;
const activatePane = activatePane_ == null ? true : activatePane_;
const activateItem = (_ref3 = options) != null ? _ref3.activateItem : _ref3;
const line = (_ref4 = options) != null ? _ref4.line : _ref4;
const column = (_ref5 = options) != null ? _ref5.column : _ref5;
const pending = (_ref6 = options) != null ? _ref6.pending : _ref6;
const activateItem = (_ref4 = options) != null ? _ref4.activateItem : _ref4;
const line = (_ref5 = options) != null ? _ref5.line : _ref5;
const column = (_ref6 = options) != null ? _ref6.column : _ref6;
const pending = (_ref7 = options) != null ? _ref7.pending : _ref7;

@@ -64,3 +66,4 @@ // Prefer going to the current editor rather than the leftmost editor.

column: column == null ? 0 : column,
center
center,
moveCursor
});

@@ -93,3 +96,3 @@ } else {

return function goToLocation(_x, _x2) {
return _ref7.apply(this, arguments);
return _ref8.apply(this, arguments);
};

@@ -128,5 +131,8 @@ })(); /**

const center = options.center == null ? true : options.center;
const moveCursor = options.moveCursor == null ? true : options.moveCursor;
const { line, column } = options;
editor.setCursorBufferPosition([line, column]);
if (moveCursor) {
editor.setCursorBufferPosition([line, column]);
}
if (center) {

@@ -133,0 +139,0 @@ editor.scrollToBufferPosition([line, column], { center: true });

@@ -53,4 +53,5 @@ 'use strict';

// It's not in one of the project directories so return the full (normalized) path.
return normalized;
// It's not in one of the project directories so return the full (normalized)
// path run through nuclideUriToDisplayString to remove nuclide:// etc.
return (_nuclideUri || _load_nuclideUri()).default.nuclideUriToDisplayString(normalized);
} /**

@@ -69,4 +70,4 @@ * Copyright (c) 2017-present, Facebook, Inc.

function normalizePath(path, isDirectory_) {
const isDirectory = isDirectory_ == null ? path.endsWith('/') : isDirectory_;
const isDirectory = isDirectory_ == null ? (_nuclideUri || _load_nuclideUri()).default.endsWithSeparator(path) : isDirectory_;
return isDirectory ? (_nuclideUri || _load_nuclideUri()).default.normalizeDir(path) : (_nuclideUri || _load_nuclideUri()).default.normalize(path);
}
{
"name": "nuclide-commons-atom",
"version": "0.4.0",
"version": "0.5.0",
"description": "Common Nuclide node modules (for use with Atom only).",
"author": "NEEDS OWNER",
"license": "BSD-3-Clause",

@@ -18,5 +19,5 @@ "homepage": "https://nuclide.io/",

"log4js": "1.1.1",
"nuclide-commons": "0.4.0",
"nuclide-commons": "0.5.0",
"redux-logger": "3.0.6",
"rxjs": "5.3.1",
"rxjs": "5.5.5",
"semver": "5.3.0",

@@ -23,0 +24,0 @@ "shallowequal": "0.2.2"

@@ -117,9 +117,3 @@ 'use strict';

function applyTextEdits(path, ...edits) {
// Sort the edits to be in order (For every edit, the start of its range will
// be after the end of the previous edit's range.)
edits.sort((e1, e2) => e1.oldRange.compare(e2.oldRange));
if (editsOverlap(edits)) {
(0, (_log4js || _load_log4js()).getLogger)('text-edit').warn('applyTextEdits was called with overlapping edits.');
return false;
}
const sortedEdits = sortEdits(edits);
const editor = (0, (_textEditor || _load_textEditor()).existingEditorForUri)(path);

@@ -131,6 +125,16 @@

return applyTextEditsToBuffer(editor.getBuffer(), edits);
return applySortedTextEditsToBuffer(editor.getBuffer(), sortedEdits);
}
function applyTextEditsToBuffer(buffer, edits) {
return applySortedTextEditsToBuffer(buffer, sortEdits(edits));
}
function applySortedTextEditsToBuffer(buffer, edits) {
// For every edit, the start of its range will be after the end of the
// previous edit's range.
if (editsOverlap(edits)) {
(0, (_log4js || _load_log4js()).getLogger)('text-edit').warn('applyTextEdits was called with overlapping edits.');
return false;
}
// Special-case whole-buffer changes to minimize disruption.

@@ -185,3 +189,3 @@ if (edits.length === 1 && edits[0].oldRange.isEqual(buffer.getRange())) {

for (let i = 0; i < sortedEdits.length - 1; i++) {
if (sortedEdits[i].oldRange.intersectsWith(sortedEdits[i + 1].oldRange)) {
if (sortedEdits[i].oldRange.end.isGreaterThan(sortedEdits[i + 1].oldRange.start)) {
return true;

@@ -191,2 +195,7 @@ }

return false;
}
function sortEdits(edits) {
// stable sort (preserve order of edits starting in the same location)
return edits.map((edit, i) => [edit, i]).sort(([e1, i1], [e2, i2]) => e1.oldRange.compare(e2.oldRange) || i1 - i2).map(([edit]) => edit);
}

@@ -20,2 +20,8 @@ 'use strict';

var _UniversalDisposable;
function _load_UniversalDisposable() {
return _UniversalDisposable = _interopRequireDefault(require('nuclide-commons/UniversalDisposable'));
}
var _rxjsBundlesRxMinJs = require('rxjs/bundles/Rx.min.js');

@@ -41,2 +47,14 @@

*/
/**
* 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 existingEditorForUri(path) {

@@ -58,14 +76,2 @@ // This isn't ideal but realistically iterating through even a few hundred editors shouldn't be a

*/
/**
* 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 existingEditorForBuffer(buffer) {

@@ -108,11 +114,13 @@ // This isn't ideal but realistically iterating through even a few hundred editors shouldn't be a

function getCursorPositions(editor) {
// This will behave strangely in the face of multiple cursors. Consider supporting multiple
// cursors in the future.
const cursor = editor.getCursors()[0];
return _rxjsBundlesRxMinJs.Observable.defer(() => {
// This will behave strangely in the face of multiple cursors. Consider supporting multiple
// cursors in the future.
const cursor = editor.getCursors()[0];
if (!(cursor != null)) {
throw new Error('Invariant violation: "cursor != null"');
}
if (!(cursor != null)) {
throw new Error('Invariant violation: "cursor != null"');
}
return _rxjsBundlesRxMinJs.Observable.merge(_rxjsBundlesRxMinJs.Observable.of(cursor.getBufferPosition()), (0, (_event || _load_event()).observableFromSubscribeFunction)(cursor.onDidChangePosition.bind(cursor)).map(event => event.newBufferPosition));
return _rxjsBundlesRxMinJs.Observable.merge(_rxjsBundlesRxMinJs.Observable.of(cursor.getBufferPosition()), (0, (_event || _load_event()).observableFromSubscribeFunction)(cursor.onDidChangePosition.bind(cursor)).map(event => event.newBufferPosition));
});
}

@@ -131,7 +139,9 @@

// Cancel insert events to prevent typing in the text editor and disallow editing (read-only).
textEditor.onWillInsertText(event => {
const willInsertTextDisposable = textEditor.onWillInsertText(event => {
event.cancel();
});
return new (_UniversalDisposable || _load_UniversalDisposable()).default(willInsertTextDisposable,
// `setText` & `append` are the only exceptions that's used to set the read-only text.
enforceReadOnlyBuffer(textEditor.getBuffer(), readOnlyExceptions);
enforceReadOnlyBuffer(textEditor.getBuffer(), readOnlyExceptions));
}

@@ -143,2 +153,3 @@

const originalApplyChange = textBuffer.applyChange;
const originalReadOnlyExceptionFunctions = {};
textBuffer.applyChange = noop;

@@ -151,2 +162,3 @@

const originalFunction = buffer[functionName];
originalReadOnlyExceptionFunctions[functionName] = originalFunction;

@@ -160,2 +172,9 @@ buffer[functionName] = function () {

}
return new (_UniversalDisposable || _load_UniversalDisposable()).default(() => {
textBuffer.applyChange = originalApplyChange;
const buffer = textBuffer;
readOnlyExceptions.forEach(functionName => buffer[functionName] = originalReadOnlyExceptionFunctions[functionName]);
});
}

@@ -162,0 +181,0 @@

@@ -9,4 +9,2 @@ 'use strict';

var _atom = require('atom');
var _rxjsBundlesRxMinJs = require('rxjs/bundles/Rx.min.js');

@@ -32,2 +30,8 @@

var _UniversalDisposable;
function _load_UniversalDisposable() {
return _UniversalDisposable = _interopRequireDefault(require('nuclide-commons/UniversalDisposable'));
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -195,3 +199,3 @@

this._callbackContainer.addCallback(grammarScopes, events, debouncedCallback);
const disposables = new _atom.Disposable(() => {
const disposables = new (_UniversalDisposable || _load_UniversalDisposable()).default(() => {
this._callbackContainer.removeCallback(grammarScopes, events, debouncedCallback);

@@ -208,2 +212,3 @@ if (this._callbackContainer.isEmpty()) {

}
onAnyFileChange(callback) {

@@ -223,3 +228,3 @@ return this._onEvents('all', FILE_CHANGE_EVENTS, callback);

if (!this._editorListenerDisposable) {
this._editorListenerDisposable = new _atom.CompositeDisposable();
this._editorListenerDisposable = new (_UniversalDisposable || _load_UniversalDisposable()).default();
}

@@ -226,0 +231,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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