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: {
loaders: [
rules:[
{
enforce: 'pre',
test: /\.tsx?$/,
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
enforce: 'pre',
use: [
{
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,61 +34,54 @@ module.exports = WebpackMerge(configBase, {
},
module: {
loaders: [
// source-map
rules: [
{
enforce: 'pre',
test: /\.js$/,
use: [
{
loader: 'source-map-loader'
}
],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
]
},
{
],
enforce: 'pre',
test: /\.tsx?$/,
use: [
{
loader: 'source-map-loader'
}
],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
]
},
// .ts, .tsx
{
test: /\.tsx?$/,
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
enforce: 'pre',
use: [
{
loader: 'source-map-loader'
}
]
},
{
test: /\.tsx?$/,
include: [
Path.resolve(__dirname, '../../src/')
Path.resolve(__dirname, '../../src/')
],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
use: [
{
loader: 'react-hot-loader/webpack'
},
{
loader: 'awesome-typescript-loader',
options: {
transpileOnly: true,
useTranspileModule: false,
sourceMap: true,
},
loader: 'awesome-typescript-loader',
options: {
transpileOnly: true,
useTranspileModule: false,
sourceMap: true,
}
},
]
},
// static assets
{ test: /\.html$/, use: 'html-loader' },
{ test: /\.png$/, use: 'url-loader?limit=10000' },
{ test: /\.jpg$/, use: 'file-loader' },
],
}
]
},
plugins: [

View File

@ -16,29 +16,24 @@ module.exports = WebpackMerge(configBase, {
devtool: 'source-map',
module: {
loaders: [
// .ts, .tsx
rules: [
{
test: /\.tsx?$/,
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
include: [
Path.resolve(__dirname, '../../src/')
],
exclude: [
Path.resolve(__dirname, '../../node_modules/')
],
use: [
{
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: [
new Webpack.DefinePlugin({
'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 { Action } from './action';
export default class LPCReducer {
export default class DispatchReducer {
private reducerMap: Map<string, any[]>;
protected constructor() {
public constructor() {
this.reducerMap = new Map();
}

View File

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