Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
htmlhero committed Sep 23, 2019
1 parent 56f9e27 commit de9462c
Show file tree
Hide file tree
Showing 42 changed files with 1,893 additions and 2,338 deletions.
79 changes: 30 additions & 49 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,35 @@
const {join, dirname} = require('path');

function resolveModulePath(packageName) {
const packageInfoPath = require.resolve(`${packageName}/package.json`);
return join(dirname(packageInfoPath), require(packageInfoPath).module);
}

module.exports = {
extends: 'interfaced',
overrides: [
Object.assign(
{
files: ['lib/**/*.js', 'test/components/**/*.js'],
settings: {
'import/resolver': {
alias: [
['zb', resolveModulePath('zombiebox')],
['cutejs', resolveModulePath('zombiebox-extension-cutejs')],
['ui', join(__dirname, 'lib')]
]
}
}
},
require('eslint-config-interfaced/overrides/esm')
),
{
files: ['lib/**/*.js', 'test/components/**/*.js'],
rules: {
'no-else-return': 'off',
'padded-blocks': 'off',
'import/extensions': ['error', 'never', {jst: 'always'}],
'import/no-unresolved': ['error', {ignore: ['^generated/']}]
}
overrides: [{
files: ['lib/**/*.js', 'test/components/**/*.js'],
extends: 'interfaced/esm',
rules: {
'no-else-return': 'off',
'padded-blocks': 'off',
'import/extensions': ['error', 'never', {jst: 'always'}],
'import/no-unresolved': ['error', {
ignore: [
'^generated/',
'^cutejs/',
],
}],
},
Object.assign(
{
files: ['test/karma.*.conf.js', 'index.js']
},
require('eslint-config-interfaced/overrides/node')
),
{
files: ['test/components/**/*.js'],
env: {
mocha: true
},
globals: {
expect: true,
chai: true,
sinon: true,
mochaTestSteps: true
}
settings: {
'import/resolver': 'zombiebox',
}
],
}, {
files: ['test/karma.*.conf.js', 'index.js'],
extends: 'interfaced/node',
}, {
files: ['test/components/**/*.js'],
extends: 'interfaced/mocha-chai',
rules: {
'no-else-return': 'off',
'import/no-unused-modules': 'off',
},
globals: {
sinon: true,
mochaTestSteps: true,
}
}],
};
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
История изменений
-----------------------

## Версия 2.1.0

* Обновлены зависимости проекта;
* Исправлен код-стайл в соответствии с `eslint-config-interfaced` версии 2.0.0-beta.2;
* Вместо `IThenable` используется `Promise`.

## Версия 2.0.0

* Обновлены зависимости проекта.
Expand Down
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Руководство по миграции
-----------------------

## С версии 2.0.0 на версию 2.1.0

Вместо `IThenable` теперь используется `Promise`. Достаточно заменить `IThenable` на `Promise` в местах использования компонент из `ui`.

## С версии 2.0.0-alpha.3 на версию 2.0.0

Миграция не подразумевает каких-либо изменений.
Expand Down
8 changes: 1 addition & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ class Extension extends AbstractExtension {
* @override
*/
getConfig() {
return {
postcss: {
presetEnv: {
stage: 1
}
}
};
return {};
}

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/data/cyclical-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export default class CyclicalDataList extends List {
/**
* @override
*/
selectNextItem(opt_step) {
const step = isNaN(opt_step) ? 1 : (opt_step < 1 ? 1 : opt_step);
let index = this.currentIndex() + step;
selectNextItem(step) {
const fixedStep = isNaN(step) ? 1 : (step < 1 ? 1 : step);
let index = this.currentIndex() + fixedStep;
if (index > this.size() - 1) {
index = index - this.size();
}
Expand All @@ -32,9 +32,9 @@ export default class CyclicalDataList extends List {
/**
* @override
*/
selectPrevItem(opt_step) {
const step = isNaN(opt_step) ? 1 : (opt_step < 1 ? 1 : opt_step);
let index = this.currentIndex() - step;
selectPrevItem(step) {
const fixedStep = isNaN(step) ? 1 : (step < 1 ? 1 : step);
let index = this.currentIndex() - fixedStep;
if (index < 0) {
index = this.size() + index;
}
Expand Down
48 changes: 24 additions & 24 deletions lib/data/dynamic-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import List from './list';
*/
export default class DynamicList extends List {
/**
* @param {function(number, number): IThenable} queryFunction Take from, to numbers and return IThenable.
* IThenable will be resolved with array of data. On data end resolved with empty array.
* @param {Options=} opt_options
* @param {function(number, number): Promise} queryFunction Take from, to numbers and return Promise.
* Promise will be resolved with array of data. On data end resolved with empty array.
* @param {Options=} options
* @throws {Error}
*/
constructor(queryFunction, opt_options) {
constructor(queryFunction, options) {
super();

this._queryFunction = queryFunction;
Expand All @@ -28,7 +28,7 @@ export default class DynamicList extends List {
frameSize: 10
};

this._configure(opt_options);
this._configure(options);
}

/**
Expand All @@ -49,7 +49,7 @@ export default class DynamicList extends List {
this._preloadQuery = this.loadItems(from, to, false);
}

return /** @type {IThenable<IList>} */ (this._preloadQuery);
return /** @type {Promise<IList>} */ (this._preloadQuery);
}

/**
Expand Down Expand Up @@ -85,10 +85,10 @@ export default class DynamicList extends List {
/**
* @param {number} from
* @param {number} to
* @param {boolean=} opt_prepend
* @return {IThenable<!DynamicList>}
* @param {boolean=} prepend
* @return {Promise<!DynamicList>}
*/
loadItems(from, to, opt_prepend) {
loadItems(from, to, prepend) {
this._query = this
._queryFunction(from, to)
.then((items) => {
Expand All @@ -102,11 +102,11 @@ export default class DynamicList extends List {
const bufferOverflow = currentSize + newItemsSize - bufferSize;
const isNotEnoughData = newItemsSize === 0 || newItemsSize < to - from + 1;

this.addItemsAt(items, opt_prepend ? 0 : currentSize);
this.addItemsAt(items, prepend ? 0 : currentSize);

if (bufferOverflow > 0) {
const newBufferStart = bufferStart + (!opt_prepend ? 1 : -1) * bufferOverflow;
const removeFrom = !opt_prepend ? 0 : bufferSize;
const newBufferStart = bufferStart + (!prepend ? 1 : -1) * bufferOverflow;
const removeFrom = !prepend ? 0 : bufferSize;
const removeTo = removeFrom + bufferOverflow;

const itemsToRemove = this._items.slice(removeFrom, removeTo);
Expand All @@ -117,7 +117,7 @@ export default class DynamicList extends List {
this._bufferStart = bufferStart;
}

if (!opt_prepend) {
if (!prepend) {
this._isEndReached = isNotEnoughData;

if (bufferOverflow > 0) {
Expand Down Expand Up @@ -148,7 +148,7 @@ export default class DynamicList extends List {
}

/**
* @return {IThenable<!DynamicList>}
* @return {Promise<!DynamicList>}
*/
loadNextFrame() {
if (this._query) {
Expand All @@ -169,7 +169,7 @@ export default class DynamicList extends List {
}

/**
* @return {IThenable<!DynamicList>}
* @return {Promise<!DynamicList>}
*/
loadPrevFrame() {
if (this._query) {
Expand Down Expand Up @@ -198,17 +198,17 @@ export default class DynamicList extends List {
}

/**
* @param {Options=} opt_options
* @param {Options=} options
* @throws {Error}
* @protected
*/
_configure(opt_options) {
_configure(options) {
this._dlOptions = /** @type {Options} */ ({});

for (const p in this._dlDefaultOptions) {
if (this._dlDefaultOptions.hasOwnProperty(p)) {
if (opt_options && typeof opt_options[p] !== 'undefined') {
this._dlOptions[p] = opt_options[p];
if (options && typeof options[p] !== 'undefined') {
this._dlOptions[p] = options[p];
} else {
this._dlOptions[p] = this._dlDefaultOptions[p];
}
Expand Down Expand Up @@ -290,7 +290,7 @@ export default class DynamicList extends List {
}

/**
* @return {IThenable<!DynamicList>}
* @return {Promise<!DynamicList>}
* @protected
*/
_maybeLoadMoreItems() {
Expand All @@ -310,21 +310,21 @@ export default class DynamicList extends List {


/**
* @type {IThenable<!DynamicList>}
* @type {Promise<!DynamicList>}
* @protected
*/
DynamicList.prototype._query;


/**
* @type {IThenable<!DynamicList>}
* @type {Promise<!DynamicList>}
* @protected
*/
DynamicList.prototype._preloadQuery;


/**
* @type {function(number, number): IThenable}
* @type {function(number, number): Promise}
* @protected
*/
DynamicList.prototype._queryFunction;
Expand Down Expand Up @@ -366,7 +366,7 @@ DynamicList.prototype._isStartReached;


/**
* Fired with: IThenable
* Fired with: Promise
* @const {string}
*/
DynamicList.prototype.EVENT_LOADING_DATA = 'loading-data';
Expand Down
10 changes: 5 additions & 5 deletions lib/data/i-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class IList {
isLoading() {}

/**
* @return {IThenable<IList>}
* @return {Promise<IList>}
*/
preload() {}

Expand Down Expand Up @@ -123,16 +123,16 @@ export default class IList {
itemAt(index) {}

/**
* @param {number=} opt_step Default 1.
* @param {number=} step Default 1.
* @return {boolean}
*/
selectNextItem(opt_step) {}
selectNextItem(step) {}

/**
* @param {number=} opt_step Default 1.
* @param {number=} step Default 1.
* @return {boolean}
*/
selectPrevItem(opt_step) {}
selectPrevItem(step) {}

/**
* @return {Array<ItemType>}
Expand Down
22 changes: 11 additions & 11 deletions lib/data/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import IList from './i-list';
*/
export default class List extends EventPublisher {
/**
* @param {Array<!ItemType>=} opt_items
* @param {Array<!ItemType>=} items
*/
constructor(opt_items) {
constructor(items) {
super();

this._items = [];
this._currentIndex = NaN;
this._autoSelect = true;
if (opt_items) {
this.setItems(opt_items);
if (items) {
this.setItems(items);
}
}

Expand All @@ -32,7 +32,7 @@ export default class List extends EventPublisher {
* @override
*/
preload() {
return /** @type {IThenable<IList>} */ (Promise.resolve(this));
return /** @type {Promise<IList>} */ (Promise.resolve(this));
}

/**
Expand Down Expand Up @@ -202,17 +202,17 @@ export default class List extends EventPublisher {
/**
* @override
*/
selectNextItem(opt_step) {
const step = isNaN(opt_step) ? 1 : (opt_step < 1 ? 1 : opt_step);
return this.selectAt(this.currentIndex() + step);
selectNextItem(step) {
const fixedStep = isNaN(step) ? 1 : (step < 1 ? 1 : step);
return this.selectAt(this.currentIndex() + fixedStep);
}

/**
* @override
*/
selectPrevItem(opt_step) {
const step = isNaN(opt_step) ? 1 : (opt_step < 1 ? 1 : opt_step);
return this.selectAt(this.currentIndex() - step);
selectPrevItem(step) {
const fixedStep = isNaN(step) ? 1 : (step < 1 ? 1 : step);
return this.selectAt(this.currentIndex() - fixedStep);
}

/**
Expand Down
Loading

0 comments on commit de9462c

Please sign in to comment.