-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 49ce6b7
Showing
136 changed files
with
5,141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
# editorconfig-tools is unable to ignore longs strings or urls | ||
max_line_length = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/node_modules | ||
**/dist | ||
**/coverage | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
// Use IntelliSense to learn about possible Node.js debug attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"program": "${file}" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "attach", | ||
"name": "Attach to Process", | ||
"address": "localhost", | ||
"port": 5858 | ||
}, | ||
{ | ||
"name" : "Run dx-react-core tests", | ||
"type": "node", | ||
"request": "launch", | ||
"program" : "${workspaceRoot}/packages/dx-react-core/node_modules/jest/bin/jest.js", | ||
"cwd": "${workspaceRoot}/packages/dx-react-core/", | ||
"args": [ | ||
"--runInBand" | ||
], | ||
"runtimeArgs": [ | ||
"--harmony" | ||
], | ||
"sourceMaps": true | ||
}, | ||
{ | ||
"name" : "Run dx-datagrid-core tests", | ||
"type": "node", | ||
"request": "launch", | ||
"program" : "${workspaceRoot}/packages/dx-datagrid-core/node_modules/jest/bin/jest.js", | ||
"cwd": "${workspaceRoot}/packages/dx-datagrid-core/", | ||
"args": [ | ||
"--runInBand" | ||
], | ||
"runtimeArgs": [ | ||
"--harmony" | ||
], | ||
"sourceMaps": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"search.exclude": { | ||
"**/node_modules": true, | ||
"**/dist": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"# devextreme-reactive" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"lerna": "2.0.0-beta.38", | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"private": true, | ||
"devDependencies": { | ||
"concurrently": "^3.4.0", | ||
"lerna": "2.0.0-beta.38" | ||
}, | ||
"scripts": { | ||
"postinstall": "lerna bootstrap", | ||
"build": "lerna run build", | ||
"watch:core": "lerna run build:watch --scope @devexpress/dx-core --stream", | ||
"watch:datagrid-core": "lerna run build:watch --scope @devexpress/dx-datagrid-core --stream", | ||
"watch:react-core": "lerna run build:watch --scope @devexpress/dx-react-core --stream", | ||
"watch:react-datagrid": "lerna run build:watch --scope @devexpress/dx-react-datagrid --stream", | ||
"watch:react-datagrid-bootstrap3": "lerna run build:watch --scope @devexpress/dx-react-datagrid-bootstrap3 --stream", | ||
"watch:react-demos": "lerna run watch --scope @devexpress/dx-react-demos --stream", | ||
"watch": "concurrently --kill-others \"npm run watch:core\" \"npm run watch:datagrid-core\" \"npm run watch:react-core\" \"npm run watch:react-datagrid\" \"npm run watch:react-datagrid-bootstrap3\" \"npm run watch:react-demos\"", | ||
"lint": "lerna run lint", | ||
"test": "lerna run test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "airbnb-base", | ||
"plugins": [ | ||
"import", | ||
"jest" | ||
], | ||
"rules": { | ||
"import/prefer-default-export": "off" | ||
}, | ||
"env": { | ||
"jest/globals": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@devexpress/dx-core", | ||
"version": "0.0.0", | ||
"description": "", | ||
"main": "dist/index", | ||
"scripts": { | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:coverage": "jest --coverage", | ||
"build": "webpack", | ||
"build:watch": "webpack --watch", | ||
"lint": "eslint src/**/*", | ||
"lint:fix": "eslint --fix src/**/*" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"babel-cli": "^6.18.0", | ||
"babel-core": "^6.21.0", | ||
"babel-jest": "^19.0.0", | ||
"babel-loader": "^6.2.10", | ||
"babel-plugin-transform-runtime": "^6.15.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-preset-react": "^6.16.0", | ||
"babel-runtime": "^6.20.0", | ||
"core-js": "^2.4.1", | ||
"eslint": "^3.18.0", | ||
"eslint-config-airbnb-base": "^11.1.2", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jest": "^19.0.1", | ||
"jest": "^19.0.2", | ||
"webpack": "^2.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './plugin-host'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
export class PluginHost { | ||
constructor() { | ||
this.plugins = []; | ||
this.subscriptions = []; | ||
this.gettersCache = {}; | ||
} | ||
registerPlugin(plugin) { | ||
this.plugins.push(plugin); | ||
this.cleanPluginsCache(); | ||
} | ||
unregisterPlugin(plugin) { | ||
this.plugins.splice(this.plugins.indexOf(plugin), 1); | ||
this.cleanPluginsCache(); | ||
} | ||
cleanPluginsCache() { | ||
this.gettersCache = {}; | ||
} | ||
collect(key, upTo) { | ||
if (!this.gettersCache[key]) { | ||
this.gettersCache[key] = this.plugins.map(plugin => plugin[key]).filter(plugin => !!plugin); | ||
} | ||
if (!upTo) return this.gettersCache[key]; | ||
|
||
const upToIndex = this.plugins.indexOf(upTo); | ||
return this.gettersCache[key].filter((getter) => { | ||
const pluginIndex = this.plugins.findIndex(plugin => plugin[key] === getter); | ||
return pluginIndex < upToIndex; | ||
}); | ||
} | ||
get(key, upTo) { | ||
const plugins = this.collect(key, upTo); | ||
|
||
let result = plugins[0](); | ||
plugins.slice(1).forEach((plugin) => { | ||
result = plugin(result); | ||
}); | ||
return result; | ||
} | ||
registerSubscription(subscription) { | ||
const index = this.subscriptions.indexOf(subscription); | ||
if (index === -1) { this.subscriptions.push(subscription); } | ||
} | ||
unregisterSubscription(subscription) { | ||
const index = this.subscriptions.indexOf(subscription); | ||
if (index !== -1) { this.subscriptions.splice(this.subscriptions.indexOf(subscription), 1); } | ||
} | ||
broadcast(event, message) { | ||
this.subscriptions.forEach(subscription => subscription[event] && subscription[event](message)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { PluginHost } from './plugin-host'; | ||
|
||
describe('PluginHost', () => { | ||
let host; | ||
|
||
beforeEach(() => { | ||
host = new PluginHost(); | ||
}); | ||
|
||
test('#get', () => { | ||
const plugin = { | ||
something: () => 123, | ||
}; | ||
|
||
host.registerPlugin(plugin); | ||
expect(host.get('something')).toBe(123); | ||
}); | ||
|
||
test('#get with extender', () => { | ||
const plugin1 = { | ||
something: () => '1', | ||
}; | ||
const plugin2 = { | ||
something: original => `${original}2`, | ||
}; | ||
const plugin3 = { | ||
something: original => `${original}3`, | ||
}; | ||
|
||
host.registerPlugin(plugin1); | ||
host.registerPlugin(plugin2); | ||
host.registerPlugin(plugin3); | ||
expect(host.get('something')).toBe('123'); | ||
}); | ||
|
||
test('#get clean cache', () => { | ||
const plugin1 = { | ||
something: () => '1', | ||
}; | ||
const plugin2 = { | ||
something: original => `${original}2`, | ||
}; | ||
|
||
host.registerPlugin(plugin1); | ||
host.registerPlugin(plugin2); | ||
host.get('something'); | ||
|
||
host.unregisterPlugin(plugin2); | ||
expect(host.get('something')).toBe('1'); | ||
|
||
host.registerPlugin(plugin2); | ||
expect(host.get('something')).toBe('12'); | ||
}); | ||
|
||
test('#collect', () => { | ||
const plugin1 = { | ||
something: 1, | ||
}; | ||
const plugin2 = { | ||
something: 2, | ||
}; | ||
const plugin3 = { | ||
something: 3, | ||
}; | ||
|
||
host.registerPlugin(plugin1); | ||
host.registerPlugin(plugin2); | ||
host.registerPlugin(plugin3); | ||
expect(host.collect('something')).toEqual([1, 2, 3]); | ||
}); | ||
|
||
test('#registerSubscription', () => { | ||
const subscription = { | ||
onMessage: jest.fn(), | ||
}; | ||
|
||
host.registerSubscription(subscription); | ||
host.broadcast('onMessage', 'update'); | ||
expect(subscription.onMessage.mock.calls.length).toBe(1); | ||
}); | ||
|
||
test('#registerSubscription several times', () => { | ||
const subscription = { | ||
onMessage: jest.fn(), | ||
}; | ||
|
||
host.registerSubscription(subscription); | ||
host.registerSubscription(subscription); | ||
host.broadcast('onMessage', 'update'); | ||
expect(subscription.onMessage.mock.calls.length).toBe(1); | ||
}); | ||
|
||
test('#unregisterSubscription', () => { | ||
const subscription = { | ||
onMessage: jest.fn(), | ||
}; | ||
|
||
host.registerSubscription(subscription); | ||
host.unregisterSubscription(subscription); | ||
host.broadcast('onMessage', 'update'); | ||
expect(subscription.onMessage.mock.calls.length).toBe(0); | ||
}); | ||
|
||
test('#unregisterSubscription without registration', () => { | ||
const subscription1 = { | ||
onMessage: jest.fn(), | ||
}; | ||
const subscription2 = { | ||
onMessage: jest.fn(), | ||
}; | ||
|
||
host.registerSubscription(subscription1); | ||
host.unregisterSubscription(subscription2); | ||
host.broadcast('onMessage', 'update'); | ||
expect(subscription1.onMessage.mock.calls.length).toBe(1); | ||
}); | ||
|
||
test('#registerSubscription', () => { | ||
const subscription = { | ||
onMessage: jest.fn(), | ||
}; | ||
|
||
host.registerSubscription(subscription); | ||
host.broadcast('onMessage', 'update'); | ||
expect(subscription.onMessage.mock.calls[0].length).toBe(1); | ||
expect(subscription.onMessage.mock.calls[0][0]).toBe('update'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable */ | ||
|
||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: { | ||
index: './src/index' | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: '[name].js', | ||
libraryTarget: 'umd' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.jsx?$/, | ||
exclude: /(node_modules|bower_components|public\/)/, | ||
use: ["babel-loader"] | ||
} | ||
] | ||
}, | ||
resolve: { | ||
extensions: [".webpack.js", ".web.js", ".js"] | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "airbnb-base", | ||
"plugins": [ | ||
"import", | ||
"jest" | ||
], | ||
"rules": { | ||
"import/prefer-default-export": "off", | ||
"no-underscore-dangle": "off" | ||
}, | ||
"env": { | ||
"jest/globals": true | ||
} | ||
} |
Oops, something went wrong.