This commit is contained in:
crusader 2017-12-26 19:09:30 +09:00
parent 944da03d1a
commit 5d268cfbf7
9 changed files with 226 additions and 60 deletions

View File

@ -26,18 +26,42 @@ module.exports = {
}, },
module: { module: {
loaders: [ rules:[
{ {
enforce: 'pre',
test: /\.tsx?$/, test: /\.tsx?$/,
exclude: [ exclude: [
Path.resolve(__dirname, '../../node_modules/') Path.resolve(__dirname, '../../node_modules/')
], ],
enforce: 'pre',
use: [ use: [
{ {
loader: 'tslint-loader' loader: 'tslint-loader'
} }
], ]
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader'
}
]
},
{
test: /\.png$/,
use: [
{
loader: 'url-loader?limit=10000'
}
]
},
{
test: /\.jpg$/,
use: [
{
loader: 'file-loader'
}
]
} }
] ]
}, },

View File

@ -34,41 +34,39 @@ module.exports = WebpackMerge(configBase, {
}, },
module: { module: {
loaders: [ rules: [
// source-map
{ {
enforce: 'pre',
test: /\.js$/, test: /\.js$/,
use: [
{
loader: 'source-map-loader'
}
],
exclude: [ exclude: [
Path.resolve(__dirname, '../../node_modules/') Path.resolve(__dirname, '../../node_modules/')
] ],
},
{
enforce: 'pre', enforce: 'pre',
test: /\.tsx?$/,
use: [ use: [
{ {
loader: 'source-map-loader' loader: 'source-map-loader'
} }
],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
] ]
}, },
// .ts, .tsx
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
exclude: [ exclude: [
Path.resolve(__dirname, '../../node_modules/') Path.resolve(__dirname, '../../node_modules/')
], ],
enforce: 'pre',
use: [
{
loader: 'source-map-loader'
}
]
},
{
test: /\.tsx?$/,
include: [ include: [
Path.resolve(__dirname, '../../src/') Path.resolve(__dirname, '../../src/')
], ],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
use: [ use: [
{ {
loader: 'react-hot-loader/webpack' loader: 'react-hot-loader/webpack'
@ -79,16 +77,11 @@ module.exports = WebpackMerge(configBase, {
transpileOnly: true, transpileOnly: true,
useTranspileModule: false, useTranspileModule: false,
sourceMap: true, sourceMap: true,
}, }
}, },
] ]
}, }
]
// static assets
{ test: /\.html$/, use: 'html-loader' },
{ test: /\.png$/, use: 'url-loader?limit=10000' },
{ test: /\.jpg$/, use: 'file-loader' },
],
}, },
plugins: [ plugins: [

View File

@ -16,29 +16,24 @@ module.exports = WebpackMerge(configBase, {
devtool: 'source-map', devtool: 'source-map',
module: { module: {
loaders: [ rules: [
// .ts, .tsx
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
include: [ include: [
Path.resolve(__dirname, '../../src/') Path.resolve(__dirname, '../../src/')
], ],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
use: [ use: [
{ {
loader: 'awesome-typescript-loader?module=es6' loader: 'awesome-typescript-loader?module=es6'
}, }
]
}
] ]
}, },
// static assets
{ test: /\.html$/, use: 'html-loader' },
{ test: /\.png$/, use: 'url-loader?limit=10000' },
{ test: /\.jpg$/, use: 'file-loader' },
],
},
plugins: [ plugins: [
new Webpack.DefinePlugin({ new Webpack.DefinePlugin({
'process.env': { 'process.env': {

View File

@ -0,0 +1,58 @@
import {
Annotation,
Decorator,
} from '@overflow/commons/core/reflect';
import {
MetadataKeyType,
PropertyKeyType,
TypeUtil,
} from '@overflow/commons/core/type';
export interface InjectAnnotationAttributes {
value: string[];
}
export class InjectAnnotation implements Annotation {
public readonly attributes: InjectAnnotationAttributes;
public constructor(value: string | string[] | InjectAnnotationAttributes) {
if (undefined === value) {
throw new Error(`value attribute must be specified.`);
}
if (TypeUtil.isString(value)) {
this.attributes = {
value: [<string>value],
};
} else if (TypeUtil.isArray(value)) {
this.attributes = {
value: <string[]>value,
};
} else {
this.attributes = <InjectAnnotationAttributes>value;
}
}
public classDecorator<TFunction extends Function>(target: TFunction): TFunction | void {
console.log('Inject');
}
public propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void {
console.log('Inject');
}
public methodDecorator<T>(target: Object, propertyKey: PropertyKeyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void {
console.log('Inject');
}
public parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void {
console.log('Inject');
}
}
export const Inject = Decorator.create(InjectAnnotation);

View File

@ -0,0 +1,46 @@
import {
Annotation,
Decorator,
} from '@overflow/commons/core/reflect';
import {
MetadataKeyType,
PropertyKeyType,
TypeUtil,
} from '@overflow/commons/core/type';
export interface InjectableAnnotationAttributes {
name?: string[];
}
export class InjectableAnnotation implements Annotation {
public readonly attributes: InjectableAnnotationAttributes;
public constructor(name: string | string[] | InjectableAnnotationAttributes) {
if (undefined === name) {
throw new Error(`value attribute must be specified.`);
}
if (TypeUtil.isString(name)) {
this.attributes = {
name: [<string>name],
};
} else {
this.attributes = <InjectableAnnotationAttributes>name;
}
}
public classDecorator<TFunction extends Function>(target: TFunction): TFunction | void {
console.log('Injectable');
}
public methodDecorator<T>(target: Object, propertyKey: PropertyKeyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void {
console.log('Injectable');
}
}
export const Injectable = Decorator.create(InjectableAnnotation);

View File

@ -0,0 +1,57 @@
import {
Annotation,
Decorator,
} from '@overflow/commons/core/reflect';
import {
MetadataKeyType,
PropertyKeyType,
TypeUtil,
} from '@overflow/commons/core/type';
export interface ResourceAnnotationAttributes {
value: string[];
}
export class ResourceAnnotation implements Annotation {
public readonly attributes: ResourceAnnotationAttributes;
public constructor(value: string | string[] | ResourceAnnotationAttributes) {
if (undefined === value) {
throw new Error(`value attribute must be specified.`);
}
if (TypeUtil.isString(value)) {
this.attributes = {
value: [<string>value],
};
} else if (TypeUtil.isArray(value)) {
this.attributes = {
value: <string[]>value,
};
} else {
this.attributes = <ResourceAnnotationAttributes>value;
}
}
public classDecorator<TFunction extends Function>(target: TFunction): TFunction | void {
console.log('Resource');
}
public propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void {
console.log('Resource');
}
public methodDecorator<T>(target: Object, propertyKey: PropertyKeyType,
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void {
console.log('Resource');
}
public parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void {
console.log('Resource');
}
}
export const Resource = Decorator.create(ResourceAnnotation);

View File

@ -17,11 +17,11 @@ import {
import { Class } from '@overflow/commons/core/reflect'; import { Class } from '@overflow/commons/core/reflect';
import { Action } from './action'; import { Action } from './action';
export default class LPCReducer { export default class DispatchReducer {
private reducerMap: Map<string, any[]>; private reducerMap: Map<string, any[]>;
protected constructor() { public constructor() {
this.reducerMap = new Map(); this.reducerMap = new Map();
} }

View File

@ -29,7 +29,7 @@ import {
} from 'react-hot-loader'; } from 'react-hot-loader';
import config from './config'; import config from './config';
import WebAppReducer from '@overflow/webapp/redux/webapp_reducer'; import DispatchReducer from '@overflow/commons/redux/dispatch_reducer';
import WebApp from './pages/webapp'; import WebApp from './pages/webapp';
// declare let module: { hot: any }; // declare let module: { hot: any };
@ -41,6 +41,8 @@ declare global {
const module: { hot: any }; const module: { hot: any };
} }
class WebAppApplication { class WebAppApplication {
private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false; private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false;
private static useReduxDevTools:boolean = window.devToolsExtension && !WebAppApplication.isProduction ? true : false; private static useReduxDevTools:boolean = window.devToolsExtension && !WebAppApplication.isProduction ? true : false;
@ -57,7 +59,7 @@ class WebAppApplication {
public async run(): Promise<void> { public async run(): Promise<void> {
try { try {
this.renderLoading(); this.renderLoading();
let reducer: WebAppReducer = WebAppReducer.getInstance(); let reducer: DispatchReducer = new DispatchReducer();
reducer.registerReducers(config.redux.reducers); reducer.registerReducers(config.redux.reducers);
this.store = createStore(reducer.reducer, config.redux.state); this.store = createStore(reducer.reducer, config.redux.state);

View File

@ -1,9 +0,0 @@
import LPCReducer from '@overflow/commons/redux/lpc_reducer';
export default class WebAppReducer extends LPCReducer {
private static readonly instance: WebAppReducer = new WebAppReducer();
public static getInstance(): WebAppReducer {
return WebAppReducer.instance;
}
}