├── .gitignore ├── LICENSE ├── README.md ├── dist ├── src │ ├── backend │ │ ├── api.d.ts │ │ ├── api.js │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── models │ │ │ ├── model.d.ts │ │ │ └── model.js │ │ ├── sample.d.ts │ │ └── sample.js │ ├── bug.d.ts │ ├── bug.js │ ├── cli.d.ts │ ├── cli.js │ ├── frontend │ │ ├── TestModel.d.ts │ │ ├── TestModel.js │ │ ├── UserState.d.ts │ │ ├── UserState.js │ │ ├── api │ │ │ ├── actions │ │ │ │ ├── actions.d.ts │ │ │ │ └── actions.js │ │ │ ├── common │ │ │ │ ├── actionEnums.d.ts │ │ │ │ └── actionEnums.js │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── reducer.d.ts │ │ │ ├── reducer.js │ │ │ └── reducers │ │ │ │ ├── reducers.d.ts │ │ │ │ └── reducers.js │ │ ├── components │ │ │ ├── GenericComp.d.ts │ │ │ ├── GenericComp.js │ │ │ ├── PureList.d.ts │ │ │ ├── PureList.js │ │ │ ├── ReduxInc.d.ts │ │ │ ├── ReduxInc.js │ │ │ ├── TetrisComponent.d.ts │ │ │ ├── TetrisComponent.js │ │ │ ├── WaspComponent.d.ts │ │ │ ├── WaspComponent.js │ │ │ ├── WaspContextComponent.d.ts │ │ │ ├── WaspContextComponent.js │ │ │ ├── WaspUseContext.d.ts │ │ │ ├── WaspUseContext.js │ │ │ ├── combinedState.d.ts │ │ │ ├── combinedState.js │ │ │ ├── memberArea.d.ts │ │ │ ├── memberArea.js │ │ │ ├── memberAreaContainer.d.ts │ │ │ ├── memberAreaContainer.js │ │ │ ├── todoList.d.ts │ │ │ └── todoList.js │ │ ├── generated │ │ │ ├── TestModel.d.ts │ │ │ ├── TestModel.js │ │ │ ├── UserState.d.ts │ │ │ └── UserState.js │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── main.d.ts │ │ ├── main.js │ │ ├── models │ │ │ ├── IncModel.d.ts │ │ │ ├── IncModel.js │ │ │ ├── SimpleModel.d.ts │ │ │ ├── SimpleModel.js │ │ │ ├── TestModel.d.ts │ │ │ ├── TestModel.js │ │ │ ├── TetrisModel.d.ts │ │ │ ├── TetrisModel.js │ │ │ ├── TodoList.d.ts │ │ │ ├── TodoList.js │ │ │ ├── UIHelper.d.ts │ │ │ ├── UIHelper.js │ │ │ ├── UserState.d.ts │ │ │ ├── UserState.js │ │ │ ├── WaspModel.d.ts │ │ │ ├── WaspModel.js │ │ │ ├── genericModel.d.ts │ │ │ ├── genericModel.js │ │ │ ├── interfaces.d.ts │ │ │ ├── interfaces.js │ │ │ ├── red │ │ │ │ ├── TestModel.d.ts │ │ │ │ ├── TestModel.js │ │ │ │ ├── TodoList.d.ts │ │ │ │ ├── TodoList.js │ │ │ │ ├── UserState.d.ts │ │ │ │ ├── UserState.js │ │ │ │ ├── index.d.ts │ │ │ │ └── index.js │ │ │ ├── reducers │ │ │ │ ├── IncModel.d.ts │ │ │ │ ├── IncModel.js │ │ │ │ ├── SimpleModel.d.ts │ │ │ │ ├── SimpleModel.js │ │ │ │ ├── TestModel.d.ts │ │ │ │ ├── TestModel.js │ │ │ │ ├── TestModelCtx.d.ts │ │ │ │ ├── TestModelCtx.js │ │ │ │ ├── TetrisModel.d.ts │ │ │ │ ├── TetrisModel.js │ │ │ │ ├── TodoList.d.ts │ │ │ │ ├── TodoList.js │ │ │ │ ├── TodoListCtx.d.ts │ │ │ │ ├── TodoListCtx.js │ │ │ │ ├── UIHelperModel.d.ts │ │ │ │ ├── UIHelperModel.js │ │ │ │ ├── UserState.d.ts │ │ │ │ ├── UserState.js │ │ │ │ ├── UserStateCtx.d.ts │ │ │ │ ├── UserStateCtx.js │ │ │ │ ├── WaspModel.d.ts │ │ │ │ ├── WaspModel.js │ │ │ │ ├── genericModel.d.ts │ │ │ │ ├── genericModel.js │ │ │ │ ├── index.d.ts │ │ │ │ └── index.js │ │ │ ├── testModels.d.ts │ │ │ └── testModels.js │ │ ├── ng.d.ts │ │ ├── ng.js │ │ ├── reducers │ │ │ ├── TestModel.d.ts │ │ │ ├── TestModel.js │ │ │ ├── UserState.d.ts │ │ │ ├── UserState.js │ │ │ ├── index.d.ts │ │ │ └── index.js │ │ ├── redux.d.ts │ │ ├── redux.js │ │ ├── state.d.ts │ │ ├── state.js │ │ ├── state2.d.ts │ │ └── state2.js │ ├── index.d.ts │ ├── index.js │ ├── programmer │ │ ├── service.d.ts │ │ └── service.js │ ├── tssimplec.d.ts │ ├── tssimplec.js │ └── utils │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── oldcode.d.ts │ │ └── oldcode.js ├── swagger │ ├── api.json │ ├── sample.json │ └── server2.json └── test │ ├── test_base.d.ts │ └── test_base.js ├── package-lock.json ├── package.json ├── public ├── index.html └── index.js ├── src ├── backend │ └── index.ts ├── cli.ts ├── frontend │ ├── components │ │ ├── GenericComp.tsx │ │ ├── PureList.tsx │ │ ├── ReduxInc.tsx │ │ ├── TetrisComponent.tsx │ │ ├── WaspComponent.tsx │ │ ├── WaspContextComponent.tsx │ │ ├── combinedState.tsx │ │ ├── memberArea.tsx │ │ └── todoList.tsx │ ├── index.ts │ ├── main.tsx │ └── models │ │ ├── IncModel.ts │ │ ├── SimpleModel.ts │ │ ├── TestModel.ts │ │ ├── TetrisModel.ts │ │ ├── TodoList.ts │ │ ├── UIHelper.ts │ │ ├── UserState.ts │ │ ├── WaspModel.ts │ │ ├── genericModel.ts │ │ ├── interfaces.ts │ │ └── reducers │ │ ├── IncModel.tsx │ │ ├── SimpleModel.tsx │ │ ├── TestModel.tsx │ │ ├── TetrisModel.tsx │ │ ├── TodoList.tsx │ │ ├── UIHelperModel.tsx │ │ ├── UserState.tsx │ │ ├── WaspModel.tsx │ │ ├── genericModel.tsx │ │ └── index.ts ├── index.ts ├── tssimplec.ts └── utils │ └── index.ts ├── test └── test_base.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Dependency directories 3 | node_modules/ 4 | 5 | # folder files 6 | data_folder/ 7 | 8 | # Image files 9 | *.jpg 10 | *.png 11 | 12 | # MacOS 13 | .DS_Store 14 | .idea/ 15 | 16 | # TypeScript compiled .map files 17 | *.map 18 | 19 | # Seems to work ok... 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Tero Tolonen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /dist/src/backend/api.d.ts: -------------------------------------------------------------------------------- 1 | import { SomeReturnValue, TestUser, Device, CreateDevice, CreateUser } from './models/model'; 2 | import * as express from 'express'; 3 | /** 4 | * APIn kuvaus jne. 5 | * 6 | * @swagger /src/swagger/server2.json 7 | * @title JeeJee 8 | * @service service2 9 | * @endpoint /sometest/v1/ 10 | * @version 1.0.1 11 | */ 12 | export declare class Server2 { 13 | hello(id: string): string; 14 | } 15 | /** 16 | * APIn kuvaus jne. 17 | * 18 | * @swagger /src/swagger/api.json 19 | * @title First service 20 | * @service service1 21 | * @endpoint /sometest2/v1/ 22 | * @version 1.0.1 23 | * 24 | */ 25 | export declare class ServerInterface { 26 | private req; 27 | private res; 28 | constructor(req: express.Request, res: express.Response); 29 | /** 30 | * 31 | * @alias user 32 | * @method put 33 | * @param id set user to some value 34 | * @param user 35 | * @tag user 36 | * @tagdescription System users 37 | */ 38 | putUser(id: string, overwrite: boolean, user: TestUser): TestUser; 39 | /** 40 | * 41 | * @alias users 42 | * @method get 43 | * @param id set user to some value 44 | * @param user 45 | * @tag user 46 | * @tagdescription System users 47 | */ 48 | getUser(id: string): TestUser; 49 | /** 50 | * Etsi dokumentaatiosta tietoja hakusanalla 51 | * @method get 52 | * @alias searchByKeyword 53 | * @query searchKeyword 54 | * @tag document 55 | * @tagdescription 56 | */ 57 | searchByKeyword(searchKeyword: string): string[]; 58 | /** 59 | * 60 | * @alias users/friends 61 | * @method get 62 | * @param id set user to some value 63 | * @param user 64 | * @tag user 65 | * @tagdescription System users 66 | */ 67 | getUserFriends(userId: number, friendId: number, filter?: string): TestUser[]; 68 | /** 69 | * 70 | * @alias user 71 | * @method delete 72 | * @param id set user to some value 73 | * @param user 74 | * @tag user 75 | * @tagdescription System users 76 | */ 77 | deleteUser(id: string): TestUser; 78 | newfn(s: string): string; 79 | /** 80 | * List all devices in the system 81 | * @param {string} id here could be the documentation of the ID value 82 | */ 83 | getDevices(id: string): Device[]; 84 | allUsers(): TestUser[]; 85 | /** 86 | * Fetch all users 87 | * @param id of course the user id 88 | */ 89 | users(id: string): TestUser[]; 90 | createUser(u: CreateUser): TestUser; 91 | /** 92 | * Will set the device data 93 | * @description ok, looks good 94 | */ 95 | setDeviceData(createNewDevice: CreateDevice): SomeReturnValue; 96 | obj(v: number): SomeReturnValue; 97 | /** 98 | * @nogenerate true 99 | */ 100 | test2(id: number): SomeReturnValue; 101 | /** 102 | * Foobar... 103 | * @param id 104 | */ 105 | test3(id: number): Promise; 106 | HelloWorld(name: string): string; 107 | /** 108 | * Async function returning stuff... 109 | * @error 404 ErrorNotFound 110 | */ 111 | hello(name: string): Promise; 112 | /** 113 | * Custom endpoint behaviour, not well defined at this point 114 | * @param name 115 | * @custom true 116 | */ 117 | custom(name: string): Promise; 118 | } 119 | -------------------------------------------------------------------------------- /dist/src/backend/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/backend/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var express = require("express"); 4 | var app = express(); 5 | var bodyParser = require("body-parser"); 6 | app.use(bodyParser.json()); 7 | app.use(express.static("public")); 8 | if (!module.parent) { 9 | app.listen(1337); 10 | console.log("listening on port 1337"); 11 | } 12 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/backend/models/model.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @model true 3 | */ 4 | export declare class SomeKeyWord { 5 | name: string; 6 | } 7 | /** 8 | * @model true 9 | */ 10 | export declare class ErrorNotFound { 11 | statusCode: number; 12 | message?: string; 13 | } 14 | /** 15 | * @model true 16 | */ 17 | export declare class ErrorForbidden { 18 | statusCode: number; 19 | message?: string; 20 | } 21 | /** 22 | * @model true 23 | */ 24 | export declare class SomeReturnValue { 25 | myValue: number; 26 | response: string; 27 | someList: string[]; 28 | keys: SomeKeyWord[]; 29 | } 30 | /** 31 | * @model true 32 | */ 33 | export declare class CreateDevice { 34 | name: string; 35 | description: string; 36 | } 37 | /** 38 | * @model true 39 | */ 40 | export declare class CreateUser { 41 | name: string; 42 | address: string; 43 | age: number; 44 | } 45 | /** 46 | * @model true 47 | */ 48 | export interface TestUser { 49 | name: string; 50 | isHidden?: boolean; 51 | } 52 | /** 53 | * @model true 54 | */ 55 | export declare class Device { 56 | id: number; 57 | name: string; 58 | } 59 | -------------------------------------------------------------------------------- /dist/src/backend/models/model.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | /** 4 | * @model true 5 | */ 6 | var SomeKeyWord = /** @class */ (function () { 7 | function SomeKeyWord() { 8 | this.name = ''; 9 | } 10 | return SomeKeyWord; 11 | }()); 12 | exports.SomeKeyWord = SomeKeyWord; 13 | /** 14 | * @model true 15 | */ 16 | var ErrorNotFound = /** @class */ (function () { 17 | function ErrorNotFound() { 18 | this.statusCode = 404; 19 | } 20 | return ErrorNotFound; 21 | }()); 22 | exports.ErrorNotFound = ErrorNotFound; 23 | /** 24 | * @model true 25 | */ 26 | var ErrorForbidden = /** @class */ (function () { 27 | function ErrorForbidden() { 28 | this.statusCode = 403; 29 | } 30 | return ErrorForbidden; 31 | }()); 32 | exports.ErrorForbidden = ErrorForbidden; 33 | /** 34 | * @model true 35 | */ 36 | var SomeReturnValue = /** @class */ (function () { 37 | function SomeReturnValue() { 38 | this.myValue = 100; 39 | this.response = ''; 40 | } 41 | return SomeReturnValue; 42 | }()); 43 | exports.SomeReturnValue = SomeReturnValue; 44 | /** 45 | * @model true 46 | */ 47 | var CreateDevice = /** @class */ (function () { 48 | function CreateDevice() { 49 | } 50 | return CreateDevice; 51 | }()); 52 | exports.CreateDevice = CreateDevice; 53 | /** 54 | * @model true 55 | */ 56 | var CreateUser = /** @class */ (function () { 57 | function CreateUser() { 58 | } 59 | return CreateUser; 60 | }()); 61 | exports.CreateUser = CreateUser; 62 | /** 63 | * @model true 64 | */ 65 | var Device = /** @class */ (function () { 66 | function Device() { 67 | } 68 | return Device; 69 | }()); 70 | exports.Device = Device; 71 | //# sourceMappingURL=model.js.map -------------------------------------------------------------------------------- /dist/src/backend/sample.d.ts: -------------------------------------------------------------------------------- 1 | import * as express from 'express'; 2 | /** 3 | * Freeform test of the API comes here 4 | * 5 | * @swagger /src/swagger/sample.json 6 | * @title The title of the Doc 7 | * @service myserviceid 8 | * @endpoint /sometest/v1/ 9 | * @version 1.0.1 10 | */ 11 | export declare class MyService { 12 | private req; 13 | private res; 14 | constructor(req: express.Request, res: express.Response); 15 | private getUserName; 16 | ping(message: string): string; 17 | /** 18 | * @alias hello 19 | */ 20 | sayHello(name: string): Promise; 21 | getDevices(): Device[]; 22 | /** 23 | * @method post 24 | */ 25 | upload(): number; 26 | } 27 | /** 28 | * @model true 29 | */ 30 | export declare class Device { 31 | id: number; 32 | name: string; 33 | description?: string; 34 | } 35 | -------------------------------------------------------------------------------- /dist/src/backend/sample.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | return new (P || (P = Promise))(function (resolve, reject) { 4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 7 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 8 | }); 9 | }; 10 | var __generator = (this && this.__generator) || function (thisArg, body) { 11 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 12 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 13 | function verb(n) { return function (v) { return step([n, v]); }; } 14 | function step(op) { 15 | if (f) throw new TypeError("Generator is already executing."); 16 | while (_) try { 17 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 18 | if (y = 0, t) op = [op[0] & 2, t.value]; 19 | switch (op[0]) { 20 | case 0: case 1: t = op; break; 21 | case 4: _.label++; return { value: op[1], done: false }; 22 | case 5: _.label++; y = op[1]; op = [0]; continue; 23 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 24 | default: 25 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 26 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 27 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 28 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 29 | if (t[2]) _.ops.pop(); 30 | _.trys.pop(); continue; 31 | } 32 | op = body.call(thisArg, _); 33 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 34 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 35 | } 36 | }; 37 | Object.defineProperty(exports, "__esModule", { value: true }); 38 | var express = require("express"); 39 | var fs_1 = require("fs"); 40 | var app = express(); 41 | /** 42 | * Freeform test of the API comes here 43 | * 44 | * @swagger /src/swagger/sample.json 45 | * @title The title of the Doc 46 | * @service myserviceid 47 | * @endpoint /sometest/v1/ 48 | * @version 1.0.1 49 | */ 50 | var MyService = /** @class */ (function () { 51 | function MyService(req, res) { 52 | this.req = req; 53 | this.res = res; 54 | } 55 | MyService.prototype.getUserName = function () { 56 | }; 57 | MyService.prototype.ping = function (message) { 58 | return "you sent " + message; 59 | }; 60 | /** 61 | * @alias hello 62 | */ 63 | MyService.prototype.sayHello = function (name) { 64 | return __awaiter(this, void 0, void 0, function () { 65 | return __generator(this, function (_a) { 66 | if (name === 'foo') 67 | throw { errorCode: 404, message: 'User not found' }; 68 | return [2 /*return*/, "Hello " + name + "!!!"]; 69 | }); 70 | }); 71 | }; 72 | MyService.prototype.getDevices = function () { 73 | return [{ id: 1, name: 'iPhone' }]; 74 | }; 75 | /** 76 | * @method post 77 | */ 78 | MyService.prototype.upload = function () { 79 | // output results to some file... 80 | // this.req.pipe( ) 81 | this.req.pipe(fs_1.default.createWriteStream(__dirname + '/uploadedFile.bin')); 82 | return 0; 83 | }; 84 | return MyService; 85 | }()); 86 | exports.MyService = MyService; 87 | /** 88 | * @model true 89 | */ 90 | var Device = /** @class */ (function () { 91 | function Device() { 92 | } 93 | return Device; 94 | }()); 95 | exports.Device = Device; 96 | //# sourceMappingURL=sample.js.map -------------------------------------------------------------------------------- /dist/src/bug.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/bug.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var ts_simple_ast_1 = require("ts-simple-ast"); 4 | var project = new ts_simple_ast_1.default(); 5 | var sourceFile = project.createSourceFile("test.ts", "\nfunction test() {\n return 555\n}\n"); 6 | sourceFile.getFunctions().forEach(function (f) { 7 | console.log(f.print()); 8 | }); 9 | //# sourceMappingURL=bug.js.map -------------------------------------------------------------------------------- /dist/src/cli.d.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | export {}; 3 | -------------------------------------------------------------------------------- /dist/src/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (_) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var _this = this; 39 | Object.defineProperty(exports, "__esModule", { value: true }); 40 | var index_1 = require("./index"); 41 | var chokidar = require("chokidar"); 42 | var path = require('path'); 43 | var argv = require('yargs') 44 | .demandCommand(1) 45 | .describe('reducers', 'Directory for reducers') 46 | .alias('r', 'reducers') 47 | .nargs('r', 1) 48 | .describe('nodevtools', 'Disable Redux Devtools integration from the React Context API components') 49 | .alias('n', 'nodevtools') 50 | .describe('watch', 'Watch directory for changes') 51 | .alias('w', 'watch') 52 | .argv; 53 | var args = process.argv.slice(2); 54 | if (args.length === 0) { 55 | console.log('ts2redux '); 56 | process.exit(); 57 | } 58 | var state = { 59 | is_running: false 60 | }; 61 | var compileProject = function (eventArgs) { return __awaiter(_this, void 0, void 0, function () { 62 | return __generator(this, function (_a) { 63 | switch (_a.label) { 64 | case 0: 65 | if (state.is_running) 66 | return [2 /*return*/]; 67 | console.log('ts2redux: compiling path: ', args[0]); 68 | state.is_running = true; 69 | return [4 /*yield*/, index_1.createProject({ 70 | path: args[0], 71 | reducerPath: argv.reducers || 'reducers', 72 | disableDevtoolsFromContext: argv.n, 73 | onlyFile: eventArgs ? path.basename(eventArgs) : undefined 74 | })]; 75 | case 1: 76 | _a.sent(); 77 | setTimeout(function () { 78 | state.is_running = false; 79 | }, 100); 80 | return [2 /*return*/]; 81 | } 82 | }); 83 | }); }; 84 | var start = function () { return __awaiter(_this, void 0, void 0, function () { 85 | var watcher; 86 | return __generator(this, function (_a) { 87 | switch (_a.label) { 88 | case 0: return [4 /*yield*/, compileProject(null)]; 89 | case 1: 90 | _a.sent(); 91 | if (argv.watch) { 92 | watcher = chokidar.watch(args[0], { 93 | ignored: '*.tsx' 94 | }); 95 | watcher 96 | .on('add', compileProject) 97 | .on('change', compileProject) 98 | .on('unlink', compileProject); 99 | } 100 | return [2 /*return*/]; 101 | } 102 | }); 103 | }); }; 104 | start(); 105 | //# sourceMappingURL=cli.js.map -------------------------------------------------------------------------------- /dist/src/frontend/TestModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | items: ShopCartItem[]; 10 | } 11 | export declare enum TaskState { 12 | UNDEFINED = 0, 13 | RUNNING = 1, 14 | ERROR = 2, 15 | SUCCESS = 3 16 | } 17 | -------------------------------------------------------------------------------- /dist/src/frontend/UserState.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @simpleredux true 3 | */ 4 | declare class UserState { 5 | logged: boolean; 6 | username: string; 7 | firstName: string; 8 | lastName: string; 9 | login(loginInfo: { 10 | username: string; 11 | password: string; 12 | }): Promise; 13 | } 14 | -------------------------------------------------------------------------------- /dist/src/frontend/UserState.js: -------------------------------------------------------------------------------- 1 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 2 | return new (P || (P = Promise))(function (resolve, reject) { 3 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 4 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 5 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 6 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 7 | }); 8 | }; 9 | var __generator = (this && this.__generator) || function (thisArg, body) { 10 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 11 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 12 | function verb(n) { return function (v) { return step([n, v]); }; } 13 | function step(op) { 14 | if (f) throw new TypeError("Generator is already executing."); 15 | while (_) try { 16 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 17 | if (y = 0, t) op = [op[0] & 2, t.value]; 18 | switch (op[0]) { 19 | case 0: case 1: t = op; break; 20 | case 4: _.label++; return { value: op[1], done: false }; 21 | case 5: _.label++; y = op[1]; op = [0]; continue; 22 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 23 | default: 24 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 25 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 26 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 27 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 28 | if (t[2]) _.ops.pop(); 29 | _.trys.pop(); continue; 30 | } 31 | op = body.call(thisArg, _); 32 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 33 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 34 | } 35 | }; 36 | /** 37 | * @simpleredux true 38 | */ 39 | var UserState = /** @class */ (function () { 40 | function UserState() { 41 | this.logged = false; 42 | } 43 | UserState.prototype.login = function (loginInfo) { 44 | return __awaiter(this, void 0, void 0, function () { 45 | return __generator(this, function (_a) { 46 | return [2 /*return*/]; 47 | }); 48 | }); 49 | }; 50 | return UserState; 51 | }()); 52 | //# sourceMappingURL=UserState.js.map -------------------------------------------------------------------------------- /dist/src/frontend/api/actions/actions.d.ts: -------------------------------------------------------------------------------- 1 | export declare const action_SHOPCARTMODEL_UPDATEITEMS: (payload: any[]) => { 2 | type: string; 3 | payload: any[]; 4 | }; 5 | export declare const fetchAllDispatcher: () => (dispatch: any) => Promise; 6 | export declare const getItemsFromCategoryDispatcher: (id: number) => (dispatch: any) => Promise; 7 | export declare const action_SHOPCARTMODEL_ADDITEM: (payload: any) => { 8 | type: string; 9 | payload: any; 10 | }; 11 | export declare const RequstAddNewItemDispatcher: (itemName: string) => (dispatch: any) => Promise; 12 | export declare const AnyFnDispatcher: (itemName: string) => (dispatch: any) => Promise; 13 | export declare const action_USERINFOMODEL_SETUSER: (payload: any) => { 14 | type: string; 15 | payload: any; 16 | }; 17 | export declare const loginUserDispatcher: (username: string, password: string) => (dispatch: any) => Promise; 18 | -------------------------------------------------------------------------------- /dist/src/frontend/api/common/actionEnums.d.ts: -------------------------------------------------------------------------------- 1 | export declare const actionsEnums: { 2 | ACTION_SHOPCARTMODEL_UPDATEITEMS: string; 3 | ACTION_SHOPCARTMODEL_FN: string; 4 | RUNNING_FETCHALL: string; 5 | ERROR_FETCHALL: string; 6 | SUCCESS_FETCHALL: string; 7 | ACTION_SHOPCARTMODEL_ADDITEM: string; 8 | RUNNING_REQUSTADDNEWITEM: string; 9 | ERROR_REQUSTADDNEWITEM: string; 10 | SUCCESS_REQUSTADDNEWITEM: string; 11 | RUNNING_ANYFN: string; 12 | ERROR_ANYFN: string; 13 | SUCCESS_ANYFN: string; 14 | ACTION_USERINFOMODEL_SETUSER: string; 15 | ACTION_USERINFOMODEL_FN: string; 16 | }; 17 | -------------------------------------------------------------------------------- /dist/src/frontend/api/common/actionEnums.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.actionsEnums = { 4 | ACTION_SHOPCARTMODEL_UPDATEITEMS: "ACTION_SHOPCARTMODEL_UPDATEITEMS", 5 | ACTION_SHOPCARTMODEL_FN: "ACTION_SHOPCARTMODEL_FN", 6 | RUNNING_FETCHALL: "RUNNING_FETCHALL", 7 | ERROR_FETCHALL: "ERROR_FETCHALL", 8 | SUCCESS_FETCHALL: "SUCCESS_FETCHALL", 9 | ACTION_SHOPCARTMODEL_ADDITEM: "ACTION_SHOPCARTMODEL_ADDITEM", 10 | RUNNING_REQUSTADDNEWITEM: "RUNNING_REQUSTADDNEWITEM", 11 | ERROR_REQUSTADDNEWITEM: "ERROR_REQUSTADDNEWITEM", 12 | SUCCESS_REQUSTADDNEWITEM: "SUCCESS_REQUSTADDNEWITEM", 13 | RUNNING_ANYFN: "RUNNING_ANYFN", 14 | ERROR_ANYFN: "ERROR_ANYFN", 15 | SUCCESS_ANYFN: "SUCCESS_ANYFN", 16 | ACTION_USERINFOMODEL_SETUSER: "ACTION_USERINFOMODEL_SETUSER", 17 | ACTION_USERINFOMODEL_FN: "ACTION_USERINFOMODEL_FN", 18 | }; 19 | //# sourceMappingURL=actionEnums.js.map -------------------------------------------------------------------------------- /dist/src/frontend/api/index.d.ts: -------------------------------------------------------------------------------- 1 | declare function clientCodeSomeHereSomeDay(): void; 2 | -------------------------------------------------------------------------------- /dist/src/frontend/api/index.js: -------------------------------------------------------------------------------- 1 | function clientCodeSomeHereSomeDay() { 2 | } 3 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/frontend/api/reducer.d.ts: -------------------------------------------------------------------------------- 1 | declare class ReduxUIState { 2 | private _isLoading; 3 | private _userRole; 4 | private _userName; 5 | isLoading: boolean; 6 | userRole: string; 7 | userName: string; 8 | } 9 | -------------------------------------------------------------------------------- /dist/src/frontend/api/reducer.js: -------------------------------------------------------------------------------- 1 | var ReduxUIState = /** @class */ (function () { 2 | function ReduxUIState() { 3 | } 4 | Object.defineProperty(ReduxUIState.prototype, "isLoading", { 5 | get: function () { 6 | return this._isLoading; 7 | }, 8 | set: function (value) { 9 | // Action updateisLoading 10 | this._isLoading = value; 11 | }, 12 | enumerable: true, 13 | configurable: true 14 | }); 15 | Object.defineProperty(ReduxUIState.prototype, "userRole", { 16 | get: function () { 17 | return this._userRole; 18 | }, 19 | set: function (value) { 20 | // Action updateuserRole 21 | this._userRole = value; 22 | }, 23 | enumerable: true, 24 | configurable: true 25 | }); 26 | Object.defineProperty(ReduxUIState.prototype, "userName", { 27 | get: function () { 28 | return this._userName; 29 | }, 30 | set: function (value) { 31 | // Action updateuserName 32 | this._userName = value; 33 | }, 34 | enumerable: true, 35 | configurable: true 36 | }); 37 | return ReduxUIState; 38 | }()); 39 | //# sourceMappingURL=reducer.js.map -------------------------------------------------------------------------------- /dist/src/frontend/api/reducers/reducers.d.ts: -------------------------------------------------------------------------------- 1 | export declare const ShopCartModelReducer: (state: any, action: any) => any; 2 | export declare const UserInfoModelReducer: (state: any, action: any) => any; 3 | -------------------------------------------------------------------------------- /dist/src/frontend/api/reducers/reducers.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var actionEnums_1 = require("../common/actionEnums"); 4 | var state_1 = require("../../state"); 5 | var state_2 = require("../../state"); 6 | var state_3 = require("../../state"); 7 | var state_4 = require("../../state"); 8 | var state_5 = require("../../state"); 9 | exports.ShopCartModelReducer = function (state, action) { 10 | if (state === void 0) { state = state_1.initializeShopCart(); } 11 | switch (action.type) { 12 | case actionEnums_1.actionsEnums.ACTION_SHOPCARTMODEL_FN: 13 | return action.payload(state); 14 | case actionEnums_1.actionsEnums.ACTION_SHOPCARTMODEL_UPDATEITEMS: 15 | return state_2.updateItems(state, action.payload); 16 | case actionEnums_1.actionsEnums.ACTION_SHOPCARTMODEL_ADDITEM: 17 | return state_3.AddItem(state, action.payload); 18 | } 19 | return state; 20 | }; 21 | exports.UserInfoModelReducer = function (state, action) { 22 | if (state === void 0) { state = state_4.initUserModel(); } 23 | switch (action.type) { 24 | case actionEnums_1.actionsEnums.ACTION_USERINFOMODEL_FN: 25 | return action.payload(state); 26 | case actionEnums_1.actionsEnums.ACTION_USERINFOMODEL_SETUSER: 27 | return state_5.setUser(state, action.payload); 28 | } 29 | return state; 30 | }; 31 | //# sourceMappingURL=reducers.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/GenericComp.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import * as container from '../models/reducers/GenericModel'; 3 | export interface Props extends container.IProps { 4 | } 5 | export declare const AbstractGeneric: (props: Props) => JSX.Element; 6 | export declare const GenericRedux: any; 7 | -------------------------------------------------------------------------------- /dist/src/frontend/components/GenericComp.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var React = require("react"); 4 | var container = require("../models/reducers/GenericModel"); 5 | var Nro = /** @class */ (function () { 6 | function Nro(n) { 7 | this.val = 0; 8 | this.val = n; 9 | } 10 | Nro.prototype.value = function () { 11 | return this.val; 12 | }; 13 | return Nro; 14 | }()); 15 | var OtherNro = /** @class */ (function () { 16 | function OtherNro(n) { 17 | this.val = 0; 18 | this.val = n; 19 | } 20 | OtherNro.prototype.value = function () { 21 | return this.val; 22 | }; 23 | return OtherNro; 24 | }()); 25 | // this component can be re-used 26 | exports.AbstractGeneric = function (props) { 27 | return (React.createElement("div", null, 28 | "Redux Sum : ", 29 | props.sum, 30 | React.createElement("div", null, 31 | React.createElement("button", { onClick: function () { 32 | props.addItems([new Nro(Math.random()), new OtherNro(2)]); 33 | } }, "Sum some")))); 34 | }; 35 | // This is the specialized version of the component 36 | exports.GenericRedux = container.StateConnector(exports.AbstractGeneric); 37 | //# sourceMappingURL=GenericComp.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/PureList.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { TodoListItem } from '../models/interfaces'; 3 | export interface IPureList { 4 | items: TodoListItem[]; 5 | } 6 | export declare class PureList extends React.PureComponent { 7 | render(): JSX.Element; 8 | } 9 | -------------------------------------------------------------------------------- /dist/src/frontend/components/PureList.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = function (d, b) { 4 | extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return extendStatics(d, b); 8 | }; 9 | return function (d, b) { 10 | extendStatics(d, b); 11 | function __() { this.constructor = d; } 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 13 | }; 14 | })(); 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | var React = require("react"); 17 | var PureList = /** @class */ (function (_super) { 18 | __extends(PureList, _super); 19 | function PureList() { 20 | return _super !== null && _super.apply(this, arguments) || this; 21 | } 22 | PureList.prototype.render = function () { 23 | return React.createElement("table", null, 24 | React.createElement("tbody", null, this.props.items.map(function (m) { 25 | return React.createElement("tr", { key: m.id }, 26 | React.createElement("td", null, m.id), 27 | React.createElement("td", null, m.title), 28 | React.createElement("td", null, m.completed ? 'Completed' : 'In Progress')); 29 | }))); 30 | }; 31 | return PureList; 32 | }(React.PureComponent)); 33 | exports.PureList = PureList; 34 | //# sourceMappingURL=PureList.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/ReduxInc.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import * as container from "../models/reducers/IncModel"; 3 | export interface Props extends container.IProps { 4 | } 5 | export declare const AbstractInc: (props: Props) => JSX.Element; 6 | export declare const ReduxInc: any; 7 | -------------------------------------------------------------------------------- /dist/src/frontend/components/ReduxInc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var React = require("react"); 4 | var container = require("../models/reducers/IncModel"); 5 | // this component can be re-used 6 | exports.AbstractInc = function (props) { 7 | return (React.createElement("div", null, 8 | React.createElement("div", null, props.cnt), 9 | React.createElement("button", { onClick: props.increment }, "+"), 10 | React.createElement("button", { onClick: props.decrement }, "-"))); 11 | }; 12 | // ConnectKeys can be used to map specific functions and properties 13 | // to the target object 14 | exports.ReduxInc = container.ConnectKeys(["cnt"], ["increment", "decrement"])(exports.AbstractInc); 15 | //# sourceMappingURL=ReduxInc.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/TetrisComponent.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as container from '../models/reducers/TetrisModel'; 3 | export interface Props extends container.IProps { 4 | } 5 | export declare class TetrisC extends React.PureComponent { 6 | interval: any; 7 | keyFunction: (event: KeyboardEvent) => void; 8 | componentDidMount(): void; 9 | componentWillUnmount(): void; 10 | render(): JSX.Element; 11 | } 12 | export declare const TetrisComponent: any; 13 | -------------------------------------------------------------------------------- /dist/src/frontend/components/TetrisComponent.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = function (d, b) { 4 | extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return extendStatics(d, b); 8 | }; 9 | return function (d, b) { 10 | extendStatics(d, b); 11 | function __() { this.constructor = d; } 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 13 | }; 14 | })(); 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | var React = require("react"); 17 | var container = require("../models/reducers/TetrisModel"); 18 | var TetrisModel_1 = require("../models/TetrisModel"); 19 | // this component can be re-used 20 | var TetrisC = /** @class */ (function (_super) { 21 | __extends(TetrisC, _super); 22 | function TetrisC() { 23 | var _this = _super !== null && _super.apply(this, arguments) || this; 24 | _this.keyFunction = function (event) { 25 | if (_this.props.gameOn) { 26 | if (event.keyCode == 37) { 27 | _this.props.left(); 28 | } 29 | if (event.keyCode == 38) { 30 | _this.props.rotate(); 31 | } 32 | if (event.keyCode == 39) { 33 | _this.props.right(); 34 | } 35 | if (event.keyCode == 40) { 36 | _this.props.step(); 37 | } 38 | } 39 | event.preventDefault(); 40 | }; 41 | return _this; 42 | } 43 | TetrisC.prototype.componentDidMount = function () { 44 | var _this = this; 45 | this.interval = setInterval(function () { 46 | if (_this.props.gameOn) 47 | _this.props.tick(); 48 | }, 100); 49 | document.addEventListener("keydown", this.keyFunction, false); 50 | }; 51 | TetrisC.prototype.componentWillUnmount = function () { 52 | clearInterval(this.interval); 53 | document.removeEventListener("keydown", this.keyFunction, false); 54 | }; 55 | TetrisC.prototype.render = function () { 56 | var _this = this; 57 | return (React.createElement("div", { style: { margin: 20, 58 | fontFamily: 'Arial', fontSize: '10px', color: '#333333', 59 | padding: 20, backgroundColor: 'white', borderRadius: '5px', display: 'inline-block' } }, 60 | !this.props.gameOn ? 61 | React.createElement("div", null, 62 | React.createElement("button", { onClick: this.props.start }, "Start Game")) 63 | : '', 64 | React.createElement("div", null, 65 | "Points:", 66 | this.props.points, 67 | " ", 68 | this.props.gameEnded ? 'Game Over' : ''), 69 | React.createElement("div", { style: { overflow: 'hidden', width: this.props.cols * 20, height: this.props.rows * 20, position: 'relative', backgroundColor: '#222222' } }, 70 | this.props.cells.map(function (row, y) { return React.createElement("div", { style: { width: _this.props.cols * 20, height: 21 }, key: 'row_' + y }, row.map(function (cell, x) { 71 | /* 72 | const active = this.props.activePiece 73 | let color = cell.color 74 | active.cells.forEach( (arow, ay)=>{ 75 | arow.forEach( (acell, ax) => { 76 | if( ((active.x + ax) == x) && ((active.y + ay) == y)) { 77 | if(acell.color !== Colors.EMPTY) color = acell.color 78 | } 79 | }) 80 | }) 81 | */ 82 | var color = cell.color; 83 | return React.createElement("div", { key: 'cell' + y + '_' + x, style: { backgroundColor: color, 84 | boxShadow: color !== TetrisModel_1.Colors.EMPTY ? 'inset 0 0 3px rgba(0,0,0,0.6)' : '', 85 | position: 'absolute', left: x * 20, top: 20 * y, width: 20, height: 20 } }); 86 | })); }), 87 | this.props.activePiece ? this.props.activePiece.cells.map(function (arow, y) { 88 | return arow.map(function (cell, x) { 89 | var active = _this.props.activePiece; 90 | var color = cell.color; 91 | var ax = active.x + x; 92 | var ay = active.y + y - (1 - _this.props.tickCnt / _this.props.ticksPerMove); 93 | return (React.createElement("div", { key: 'cell' + y + '_' + x, style: { backgroundColor: color, 94 | boxShadow: color !== TetrisModel_1.Colors.EMPTY ? 'inset 0 0 3px rgba(0,0,0,0.6)' : '', 95 | position: 'absolute', left: ax * 20, top: 20 * ay, width: 20, height: 20 } })); 96 | }); 97 | }) : '', 98 | " ) })}"))); 99 | }; 100 | return TetrisC; 101 | }(React.PureComponent)); 102 | exports.TetrisC = TetrisC; 103 | // This is the specialized version of the component 104 | exports.TetrisComponent = container.StateConnector(TetrisC); 105 | //# sourceMappingURL=TetrisComponent.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/WaspComponent.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as container from '../models/reducers/WaspModel'; 3 | export interface Props extends container.IProps { 4 | } 5 | export declare class WaspC extends React.PureComponent { 6 | interval: any; 7 | componentDidMount(): void; 8 | componentWillUnmount(): void; 9 | render(): JSX.Element; 10 | } 11 | export declare const WaspComponent: any; 12 | -------------------------------------------------------------------------------- /dist/src/frontend/components/WaspComponent.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = function (d, b) { 4 | extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return extendStatics(d, b); 8 | }; 9 | return function (d, b) { 10 | extendStatics(d, b); 11 | function __() { this.constructor = d; } 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 13 | }; 14 | })(); 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | var React = require("react"); 17 | var container = require("../models/reducers/WaspModel"); 18 | // this component can be re-used 19 | var WaspC = /** @class */ (function (_super) { 20 | __extends(WaspC, _super); 21 | function WaspC() { 22 | return _super !== null && _super.apply(this, arguments) || this; 23 | } 24 | WaspC.prototype.componentDidMount = function () { 25 | var _this = this; 26 | this.interval = setInterval(function () { 27 | _this.props.step(); 28 | }, 20); 29 | }; 30 | WaspC.prototype.componentWillUnmount = function () { 31 | clearInterval(this.interval); 32 | }; 33 | WaspC.prototype.render = function () { 34 | var _this = this; 35 | return (React.createElement("div", null, 36 | React.createElement("div", null, "Wasps using Redux"), 37 | React.createElement("button", { onClick: function (_) { 38 | _this.props.addWasp({ x: 50 + Math.random() * 150, y: 50 + Math.random() * 150 }); 39 | } }, "+ Wasp"), 40 | React.createElement("div", null, 41 | React.createElement("svg", { width: 300, height: 300 }, Object.keys(this.props.wasps).map(function (key) { 42 | var wasp = _this.props.wasps[parseInt(key)]; 43 | return React.createElement("circle", { cx: wasp.x, cy: wasp.y, key: key, r: 10, fill: "red" }); 44 | }))))); 45 | }; 46 | return WaspC; 47 | }(React.PureComponent)); 48 | exports.WaspC = WaspC; 49 | // This is the specialized version of the component 50 | exports.WaspComponent = container.StateConnector(WaspC); 51 | //# sourceMappingURL=WaspComponent.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/WaspContextComponent.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | export interface IInterval { 3 | time: number; 4 | fn: () => void; 5 | } 6 | export declare class Interval extends React.PureComponent { 7 | interval: any; 8 | componentDidMount(): void; 9 | componentWillUnmount(): void; 10 | render(): JSX.Element; 11 | } 12 | export declare class WaspContextComponent extends React.PureComponent { 13 | render(): JSX.Element; 14 | } 15 | -------------------------------------------------------------------------------- /dist/src/frontend/components/WaspContextComponent.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = function (d, b) { 4 | extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return extendStatics(d, b); 8 | }; 9 | return function (d, b) { 10 | extendStatics(d, b); 11 | function __() { this.constructor = d; } 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 13 | }; 14 | })(); 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | var React = require("react"); 17 | var WaspModel_1 = require("../models/reducers/WaspModel"); 18 | var Interval = /** @class */ (function (_super) { 19 | __extends(Interval, _super); 20 | function Interval() { 21 | return _super !== null && _super.apply(this, arguments) || this; 22 | } 23 | Interval.prototype.componentDidMount = function () { 24 | var _this = this; 25 | this.interval = setInterval(function () { 26 | _this.props.fn(); 27 | }, this.props.time); 28 | }; 29 | Interval.prototype.componentWillUnmount = function () { 30 | clearInterval(this.interval); 31 | }; 32 | Interval.prototype.render = function () { 33 | return React.createElement("span", null); 34 | }; 35 | return Interval; 36 | }(React.PureComponent)); 37 | exports.Interval = Interval; 38 | // this component can be re-used 39 | var WaspContextComponent = /** @class */ (function (_super) { 40 | __extends(WaspContextComponent, _super); 41 | function WaspContextComponent() { 42 | return _super !== null && _super.apply(this, arguments) || this; 43 | } 44 | WaspContextComponent.prototype.render = function () { 45 | return (React.createElement(WaspModel_1.WaspModelConsumer, null, function (state) { return React.createElement("div", null, 46 | React.createElement("div", null, "Wasps using React Context API"), 47 | React.createElement(Interval, { fn: state.step, time: 20 }), 48 | React.createElement("button", { onClick: function (_) { 49 | state.addWasp({ x: 50 + Math.random() * 150, y: 50 + Math.random() * 150 }); 50 | } }, "+ Wasp"), 51 | React.createElement("div", null, 52 | React.createElement("svg", { width: 300, height: 300 }, Object.keys(state.wasps).map(function (key) { 53 | var wasp = state.wasps[parseInt(key)]; 54 | return React.createElement("circle", { onClick: function (_) { 55 | state.setColor({ waspId: parseInt(key), colorValue: 'green' }); 56 | }, cx: wasp.x, cy: wasp.y, key: key, r: 10, fill: wasp.color }); 57 | })))); })); 58 | }; 59 | return WaspContextComponent; 60 | }(React.PureComponent)); 61 | exports.WaspContextComponent = WaspContextComponent; 62 | //# sourceMappingURL=WaspContextComponent.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/WaspUseContext.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | export interface IInterval { 3 | time: number; 4 | fn: () => void; 5 | } 6 | export declare class Interval extends React.Component { 7 | interval: any; 8 | componentDidMount(): void; 9 | componentWillUnmount(): void; 10 | render(): JSX.Element; 11 | } 12 | export declare const WaspUseContest: () => JSX.Element; 13 | -------------------------------------------------------------------------------- /dist/src/frontend/components/WaspUseContext.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = function (d, b) { 4 | extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return extendStatics(d, b); 8 | } 9 | return function (d, b) { 10 | extendStatics(d, b); 11 | function __() { this.constructor = d; } 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 13 | }; 14 | })(); 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | var React = require("react"); 17 | var WaspModel_1 = require("../models/reducers/WaspModel"); 18 | var Interval = /** @class */ (function (_super) { 19 | __extends(Interval, _super); 20 | function Interval() { 21 | return _super !== null && _super.apply(this, arguments) || this; 22 | } 23 | Interval.prototype.componentDidMount = function () { 24 | var _this = this; 25 | this.interval = setInterval(function () { 26 | _this.props.fn(); 27 | }, this.props.time); 28 | }; 29 | Interval.prototype.componentWillUnmount = function () { 30 | clearInterval(this.interval); 31 | }; 32 | Interval.prototype.render = function () { 33 | return React.createElement("span", null); 34 | }; 35 | return Interval; 36 | }(React.Component)); 37 | exports.Interval = Interval; 38 | // this component can be re-used 39 | exports.WaspUseContest = function () { 40 | var state = React.useContext(WaspModel_1.WaspModelContext); 41 | return (React.createElement("div", null, 42 | React.createElement("div", null, "Wasps using React Context API"), 43 | React.createElement(Interval, { fn: state.step, time: 20 }), 44 | React.createElement("button", { onClick: function (_) { 45 | state.addWasp({ x: 50 + Math.random() * 150, y: 50 + Math.random() * 150 }); 46 | } }, "+ Wasp"), 47 | React.createElement("div", null, 48 | React.createElement("svg", { width: 300, height: 300 }, Object.keys(state.wasps).map(function (key) { 49 | var wasp = state.wasps[parseInt(key)]; 50 | return React.createElement("circle", { onClick: function (_) { 51 | state.setColor({ waspId: parseInt(key), colorValue: 'green' }); 52 | }, cx: wasp.x, cy: wasp.y, key: key, r: 10, fill: wasp.color }); 53 | }))))); 54 | }; 55 | //# sourceMappingURL=WaspUseContext.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/combinedState.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import * as todoContainer from '../models/reducers/TodoList'; 3 | import * as userContainer from '../models/reducers/UserState'; 4 | export interface Props extends todoContainer.IProps, userContainer.IProps { 5 | } 6 | export declare const AbstractCombinedStates: (props: Props) => JSX.Element; 7 | export declare const StateConnector: any; 8 | export declare const CombinedStates: any; 9 | -------------------------------------------------------------------------------- /dist/src/frontend/components/combinedState.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __assign = (this && this.__assign) || function () { 3 | __assign = Object.assign || function(t) { 4 | for (var s, i = 1, n = arguments.length; i < n; i++) { 5 | s = arguments[i]; 6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 7 | t[p] = s[p]; 8 | } 9 | return t; 10 | }; 11 | return __assign.apply(this, arguments); 12 | }; 13 | Object.defineProperty(exports, "__esModule", { value: true }); 14 | var React = require("react"); 15 | var react_redux_1 = require("react-redux"); 16 | var todoContainer = require("../models/reducers/TodoList"); 17 | var userContainer = require("../models/reducers/UserState"); 18 | // this component can be re-used 19 | exports.AbstractCombinedStates = function (props) { 20 | return (React.createElement("div", null, 21 | React.createElement("div", null, "Combined States Component"), 22 | React.createElement("div", null, 23 | React.createElement("div", null, 24 | "User Name Now: ", 25 | props.username), 26 | React.createElement("div", null, 27 | "Items length Now: ", 28 | props.items.length), 29 | React.createElement("button", { onClick: function () { props.getItems(); } }, "Try Loading"), 30 | React.createElement("button", { onClick: function () { props.clearTodoList(); } }, "Clear List"), 31 | React.createElement("button", { onClick: function () { props.fakeLogin(); } }, "Test Login")))); 32 | }; 33 | exports.StateConnector = react_redux_1.connect(function (state) { return (__assign({}, todoContainer.mapStateToProps(state), userContainer.mapStateToProps(state))); }, function (dispatch) { return (__assign({}, todoContainer.mapDispatchToProps(dispatch), userContainer.mapDispatchToProps(dispatch))); }); 34 | // This is the specialized version of the component 35 | exports.CombinedStates = exports.StateConnector(exports.AbstractCombinedStates); 36 | //# sourceMappingURL=combinedState.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/memberArea.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import * as container from '../models/reducers/TestModel'; 3 | export interface Props extends container.IProps { 4 | } 5 | export declare const AbstractMemberArea: (props: Props) => JSX.Element; 6 | export declare const MemberArea: any; 7 | -------------------------------------------------------------------------------- /dist/src/frontend/components/memberArea.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var React = require("react"); 4 | var container = require("../models/reducers/TestModel"); 5 | // this component can be re-used 6 | exports.AbstractMemberArea = function (props) { 7 | return (React.createElement("div", null, 8 | React.createElement("div", null, "Member Area Component"), 9 | React.createElement("input", { type: "submit", value: "load", className: "btn btn-default", onClick: function () { return props.addOneFriend('Teppo'); } }), 10 | React.createElement("input", { type: "submit", value: "Fill Friends", className: "btn btn-default", onClick: function () { return props.fillSomeFriends(); } }), 11 | React.createElement("input", { type: "submit", value: "John Smith", className: "btn btn-default", onClick: function () { return props.createItem('John Smith'); } }), 12 | React.createElement("input", { type: "submit", value: "Change the last", className: "btn btn-default", onClick: function () { return props.ChangeLastItem(); } }), 13 | React.createElement("input", { type: "submit", value: "Remove First", className: "btn btn-default", onClick: function () { return props.removeFirst(); } }), 14 | React.createElement("input", { type: "submit", value: "Sort", className: "btn btn-default", onClick: function () { return props.sort(); } }), 15 | React.createElement("input", { type: "submit", value: "+ Cart Sync", className: "btn btn-default", onClick: function () { return props.addCartSync(); } }), 16 | React.createElement("input", { type: "submit", value: "+ Cart", className: "btn btn-default", onClick: function () { return props.addCart(); } }), 17 | React.createElement("input", { type: "submit", value: "+ Cart Item", className: "btn btn-default", onClick: function () { return props.addToCartRandom(); } }), 18 | React.createElement("input", { type: "submit", value: "user message", className: "btn btn-default", onClick: function () { return props.setUserMessage('Hello WOrld!!!!'); } }), 19 | React.createElement("div", null, 20 | React.createElement("div", null, props.userMessage), 21 | React.createElement("div", null, props.shopState), 22 | props.items.map(function (m) { 23 | return React.createElement("div", { key: m.id }, m.name); 24 | }), 25 | React.createElement("h1", null, "Shopping Carts"), 26 | Object.keys(props.carts).map(function (cartId) { 27 | var cart = props.carts[cartId]; 28 | return React.createElement("div", { key: cartId }, 29 | React.createElement("h4", null, cartId), 30 | React.createElement("button", { onClick: function () { 31 | props.addToCart({ cartId: cartId, item: { id: (new Date()).getTime(), name: "Some New Item" } }); 32 | } }, "+ item"), 33 | React.createElement("ul", null, cart.items.map(function (item) { return React.createElement("li", { key: item.id }, item.name); }))); 34 | })))); 35 | }; 36 | // This is the specialized version of the component 37 | exports.MemberArea = container.StateConnector(exports.AbstractMemberArea); 38 | //# sourceMappingURL=memberArea.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/memberAreaContainer.d.ts: -------------------------------------------------------------------------------- 1 | import { ShopCartItem } from '../ng'; 2 | export interface ContainerPropsState { 3 | taskState: number; 4 | members: Array; 5 | } 6 | export interface ContainerPropsMethods { 7 | loadMembers?: () => any; 8 | fillSomeFriends?: () => any; 9 | createItem?: (name: string) => any; 10 | ChangeLastItem?: () => any; 11 | addToCartRandom?: () => any; 12 | addCart?: () => any; 13 | } 14 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 15 | } 16 | export declare const StateConnector: any; 17 | -------------------------------------------------------------------------------- /dist/src/frontend/components/memberAreaContainer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var react_redux_1 = require("react-redux"); 4 | var ng_1 = require("../ng"); 5 | var mapStateToProps = function (state) { 6 | return { 7 | taskState: state.TestModelReducer.shopState, 8 | members: state.TestModelReducer.items 9 | }; 10 | }; 11 | var mapDispatchToProps = function (dispatch) { 12 | return { 13 | loadMembers: function () { 14 | return dispatch(ng_1.RTestModel.createItem('Jeee!!!')); 15 | }, 16 | fillSomeFriends: function () { 17 | return dispatch(ng_1.RTestModel.fillSomeFriends()); 18 | }, 19 | createItem: function (name) { 20 | return dispatch(ng_1.RTestModel.createItem(name)); 21 | }, 22 | ChangeLastItem: function () { 23 | return dispatch(ng_1.RTestModel.ChangeLastItem()); 24 | }, 25 | addToCartRandom: function () { 26 | return dispatch(ng_1.RTestModel.addToCartRandom()); 27 | }, 28 | addCart: function () { 29 | return dispatch(ng_1.RTestModel.addCart()); 30 | } 31 | }; 32 | }; 33 | exports.StateConnector = react_redux_1.connect(mapStateToProps, mapDispatchToProps); 34 | //# sourceMappingURL=memberAreaContainer.js.map -------------------------------------------------------------------------------- /dist/src/frontend/components/todoList.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import * as container from "../models/reducers/TodoList"; 3 | export interface Props extends container.IProps { 4 | } 5 | export declare const AbstractTodoList: (props: Props) => JSX.Element; 6 | export declare const TodoList: any; 7 | -------------------------------------------------------------------------------- /dist/src/frontend/components/todoList.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var React = require("react"); 4 | var container = require("../models/reducers/TodoList"); 5 | var PureList_1 = require("./PureList"); 6 | // this component can be re-used 7 | exports.AbstractTodoList = function (props) { 8 | return (React.createElement("div", null, 9 | React.createElement("h2", null, "TodoList Component, with memoization"), 10 | React.createElement("div", null, 11 | "Title: ", 12 | props.listTitle), 13 | React.createElement("button", { onClick: function () { return props.getItems(); } }, "Load"), 14 | React.createElement("button", { onClick: function () { return props.toggleSortOrder(); } }, "Toggle Order"), 15 | React.createElement("button", { onClick: function () { return props.prevPage(); } }, "Prev"), 16 | React.createElement("button", { onClick: function () { return props.nextPage(); } }, "Next"), 17 | React.createElement("button", { onClick: function () { return props.addLotOfItems(10000); } }, "Add 10000 items"), 18 | React.createElement("button", { onClick: function () { return props.setTitle("Jee" + Date.now()); } }, "Set Title of List"), 19 | React.createElement("div", null, 20 | React.createElement("div", null, props.state), 21 | React.createElement("div", null, props.state === "ERROR" ? new String(props.stateError) : ""), 22 | React.createElement(PureList_1.PureList, { items: props.listToDisplay })))); 23 | }; 24 | // This is the specialized version of the component 25 | exports.TodoList = container.StateConnector(exports.AbstractTodoList); 26 | //# sourceMappingURL=todoList.js.map -------------------------------------------------------------------------------- /dist/src/frontend/generated/TestModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | items: ShopCartItem[]; 10 | } 11 | export declare enum TaskState { 12 | UNDEFINED = 0, 13 | RUNNING = 1, 14 | ERROR = 2, 15 | SUCCESS = 3 16 | } 17 | export interface ITestModel { 18 | items: ShopCartItem[]; 19 | maxId: number; 20 | cartId: number; 21 | shopState: TaskState; 22 | carts: { 23 | [key: string]: ShopCart; 24 | }; 25 | } 26 | /** 27 | * @generated true 28 | */ 29 | export declare class RTestModel { 30 | private _state?; 31 | private _dispatch?; 32 | private _getState?; 33 | constructor(state?: ITestModel, dispatch?: (action: any) => void, getState?: () => ITestModel); 34 | items: ShopCartItem[]; 35 | maxId: number; 36 | cartId: number; 37 | shopState: TaskState; 38 | carts: { 39 | [key: string]: ShopCart; 40 | }; 41 | add(item: ShopCartItem): void; 42 | addCart(): Promise; 43 | static addCart(): (dispatcher: any, getState: any) => void; 44 | addToCart(adding: { 45 | cartId: string; 46 | item: ShopCartItem; 47 | }): Promise; 48 | static addToCart(adding: { 49 | cartId: string; 50 | item: ShopCartItem; 51 | }): (dispatcher: any, getState: any) => void; 52 | addToCartRandom(): Promise; 53 | static addToCartRandom(): (dispatcher: any, getState: any) => void; 54 | renameLast(newName: string): void; 55 | createItem(someName: string): Promise; 56 | static createItem(someName: string): (dispatcher: any, getState: any) => void; 57 | fillSomeFriends(): Promise; 58 | static fillSomeFriends(): (dispatcher: any, getState: any) => void; 59 | ChangeLastItem(): Promise; 60 | static ChangeLastItem(): (dispatcher: any, getState: any) => void; 61 | } 62 | export declare const TestModelEnums: { 63 | TestModel_items: string; 64 | TestModel_maxId: string; 65 | TestModel_cartId: string; 66 | TestModel_shopState: string; 67 | TestModel_carts: string; 68 | TestModel_add: string; 69 | TestModel_renameLast: string; 70 | }; 71 | export declare const TestModelReducer: (state: ITestModel, action: any) => ITestModel; 72 | -------------------------------------------------------------------------------- /dist/src/frontend/generated/UserState.d.ts: -------------------------------------------------------------------------------- 1 | export interface IUserState { 2 | logged: boolean; 3 | username: string; 4 | firstName: string; 5 | lastName: string; 6 | } 7 | /** 8 | * @generated true 9 | */ 10 | export declare class RUserState { 11 | private _state?; 12 | private _dispatch?; 13 | private _getState?; 14 | constructor(state?: IUserState, dispatch?: (action: any) => void, getState?: () => IUserState); 15 | logged: boolean; 16 | username: string; 17 | firstName: string; 18 | lastName: string; 19 | login(loginInfo: { 20 | username: string; 21 | password: string; 22 | }): Promise; 23 | static login(loginInfo: { 24 | username: string; 25 | password: string; 26 | }): (dispatcher: any, getState: any) => void; 27 | } 28 | export declare const UserStateEnums: { 29 | UserState_logged: string; 30 | UserState_username: string; 31 | UserState_firstName: string; 32 | UserState_lastName: string; 33 | }; 34 | export declare const UserStateReducer: (state: IUserState, action: any) => IUserState; 35 | -------------------------------------------------------------------------------- /dist/src/frontend/index.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terotests/ts2redux/74da23a74cdc698f982a765b2675968be68b8812/dist/src/frontend/index.d.ts -------------------------------------------------------------------------------- /dist/src/frontend/index.js: -------------------------------------------------------------------------------- 1 | console.log('frontend sample'); 2 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/frontend/main.d.ts: -------------------------------------------------------------------------------- 1 | import { AnyAction, Store } from "redux"; 2 | import { IState } from "./models/reducers/"; 3 | import { TodoListItem } from "./models/interfaces"; 4 | export declare class TodoStoreController { 5 | private _store; 6 | constructor(store: Store); 7 | items: TodoListItem[]; 8 | getItems(): Promise; 9 | } 10 | -------------------------------------------------------------------------------- /dist/src/frontend/models/IncModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | export declare class IncModel { 5 | cnt: number; 6 | increment(): void; 7 | decrement(): void; 8 | readonly incValue: number; 9 | } 10 | -------------------------------------------------------------------------------- /dist/src/frontend/models/IncModel.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @redux true 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | var IncModel = /** @class */ (function () { 7 | function IncModel() { 8 | this.cnt = 0; 9 | } 10 | IncModel.prototype.increment = function () { 11 | this.cnt++; 12 | }; 13 | IncModel.prototype.decrement = function () { 14 | this.cnt--; 15 | }; 16 | Object.defineProperty(IncModel.prototype, "incValue", { 17 | get: function () { 18 | return this.cnt; 19 | }, 20 | enumerable: true, 21 | configurable: true 22 | }); 23 | return IncModel; 24 | }()); 25 | exports.IncModel = IncModel; 26 | //# sourceMappingURL=IncModel.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/SimpleModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | export declare class SimpleModel { 5 | items: any[]; 6 | /** 7 | * @dispatch true 8 | * @param action 9 | */ 10 | SimpleDispatch(action: any): Promise; 11 | getItems(): Promise; 12 | readonly myItems: any[]; 13 | } 14 | -------------------------------------------------------------------------------- /dist/src/frontend/models/SimpleModel.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | return new (P || (P = Promise))(function (resolve, reject) { 4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 7 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 8 | }); 9 | }; 10 | var __generator = (this && this.__generator) || function (thisArg, body) { 11 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 12 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 13 | function verb(n) { return function (v) { return step([n, v]); }; } 14 | function step(op) { 15 | if (f) throw new TypeError("Generator is already executing."); 16 | while (_) try { 17 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 18 | if (y = 0, t) op = [op[0] & 2, t.value]; 19 | switch (op[0]) { 20 | case 0: case 1: t = op; break; 21 | case 4: _.label++; return { value: op[1], done: false }; 22 | case 5: _.label++; y = op[1]; op = [0]; continue; 23 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 24 | default: 25 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 26 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 27 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 28 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 29 | if (t[2]) _.ops.pop(); 30 | _.trys.pop(); continue; 31 | } 32 | op = body.call(thisArg, _); 33 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 34 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 35 | } 36 | }; 37 | Object.defineProperty(exports, "__esModule", { value: true }); 38 | var axios_1 = require("axios"); 39 | /** 40 | * @redux true 41 | */ 42 | var SimpleModel = /** @class */ (function () { 43 | function SimpleModel() { 44 | this.items = []; 45 | } 46 | /** 47 | * @dispatch true 48 | * @param action 49 | */ 50 | SimpleModel.prototype.SimpleDispatch = function (action) { 51 | return __awaiter(this, void 0, void 0, function () { 52 | return __generator(this, function (_a) { 53 | return [2 /*return*/]; 54 | }); 55 | }); 56 | }; 57 | SimpleModel.prototype.getItems = function () { 58 | return __awaiter(this, void 0, void 0, function () { 59 | var _a; 60 | return __generator(this, function (_b) { 61 | switch (_b.label) { 62 | case 0: 63 | _a = this; 64 | return [4 /*yield*/, axios_1.default.get("https://jsonplaceholder.typicode.com/todos")]; 65 | case 1: 66 | _a.items = (_b.sent()).data; 67 | return [2 /*return*/]; 68 | } 69 | }); 70 | }); 71 | }; 72 | Object.defineProperty(SimpleModel.prototype, "myItems", { 73 | get: function () { 74 | return this.items; 75 | }, 76 | enumerable: true, 77 | configurable: true 78 | }); 79 | return SimpleModel; 80 | }()); 81 | exports.SimpleModel = SimpleModel; 82 | //# sourceMappingURL=SimpleModel.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/TestModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | newItemName?: string; 10 | items: ShopCartItem[]; 11 | } 12 | export declare enum TaskState { 13 | UNDEFINED = 0, 14 | RUNNING = 1, 15 | ERROR = 2, 16 | SUCCESS = 3 17 | } 18 | export interface TestObj { 19 | name: string; 20 | } 21 | -------------------------------------------------------------------------------- /dist/src/frontend/models/TetrisModel.d.ts: -------------------------------------------------------------------------------- 1 | export interface Cell { 2 | color: string; 3 | } 4 | export declare enum Colors { 5 | EMPTY = "" 6 | } 7 | export interface ActivePiece { 8 | x: number; 9 | y: number; 10 | width: number; 11 | height: number; 12 | cells: Cell[][]; 13 | } 14 | /** 15 | * [' O '], 16 | * ['OOO'], 17 | * [' O '] 18 | */ 19 | export declare const createNewPiece: (usingColor: string) => ActivePiece; 20 | /** 21 | * @redux true 22 | */ 23 | export declare class TetrisModel { 24 | useColors: string[]; 25 | lastUsedColor: number; 26 | points: number; 27 | rows: number; 28 | cols: number; 29 | cells: Cell[][]; 30 | activePiece?: ActivePiece; 31 | gameOn: boolean; 32 | gameEnded: boolean; 33 | ticksPerMove: number; 34 | tickCnt: number; 35 | dx: number; 36 | dy: number; 37 | private doesCollide; 38 | tick(): void; 39 | left(): void; 40 | right(): void; 41 | rotate(): void; 42 | private rotateCells; 43 | step(): void; 44 | private pickNextColor; 45 | masonPiece(): void; 46 | dropRows(): void; 47 | clearCells(): void; 48 | resetGame(): void; 49 | start(): void; 50 | } 51 | -------------------------------------------------------------------------------- /dist/src/frontend/models/TodoList.d.ts: -------------------------------------------------------------------------------- 1 | import { TodoListItem } from "./interfaces"; 2 | export declare type TaskState = "UNDEFINED" | "RUNNING" | "LOADED" | "ERROR"; 3 | export declare enum SortOrder { 4 | ASC = "asc", 5 | DESC = "desc" 6 | } 7 | /** 8 | * @redux true 9 | */ 10 | export declare class TodoList { 11 | items: TodoListItem[]; 12 | state: TaskState; 13 | stateError: any; 14 | sortOrder: SortOrder; 15 | listStart: number; 16 | listPageLength: number; 17 | listTitle: string; 18 | customMessage: string; 19 | readonly listToDisplay: TodoListItem[]; 20 | private findMaxId; 21 | nextPage(): void; 22 | prevPage(): void; 23 | toggleSortOrder(): void; 24 | clearTodoList(): void; 25 | reverse(): void; 26 | sortById(): void; 27 | sortByTitle(): void; 28 | sortByCompletion(): void; 29 | setTitle(value: string): void; 30 | addLotOfItems(cnt: number): void; 31 | /** 32 | * Fetch items from json placeholder service 33 | */ 34 | getItems(): Promise; 35 | getShortList(makeError: boolean): Promise; 36 | } 37 | -------------------------------------------------------------------------------- /dist/src/frontend/models/UIHelper.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | declare class UIHelperModel { 5 | showWasps: boolean; 6 | toggle(): void; 7 | } 8 | -------------------------------------------------------------------------------- /dist/src/frontend/models/UIHelper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | var UIHelperModel = /** @class */ (function () { 5 | function UIHelperModel() { 6 | this.showWasps = false; 7 | } 8 | UIHelperModel.prototype.toggle = function () { 9 | this.showWasps = !this.showWasps; 10 | }; 11 | return UIHelperModel; 12 | }()); 13 | //# sourceMappingURL=UIHelper.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/UserState.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | declare class UserState { 5 | logged: boolean; 6 | username: string; 7 | firstName: string; 8 | lastName: string; 9 | lastLogin: number; 10 | login(loginInfo: { 11 | username: string; 12 | password: string; 13 | }): Promise; 14 | logout(): Promise; 15 | fakeLogin(): void; 16 | } 17 | -------------------------------------------------------------------------------- /dist/src/frontend/models/UserState.js: -------------------------------------------------------------------------------- 1 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 2 | return new (P || (P = Promise))(function (resolve, reject) { 3 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 4 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 5 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 6 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 7 | }); 8 | }; 9 | var __generator = (this && this.__generator) || function (thisArg, body) { 10 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 11 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 12 | function verb(n) { return function (v) { return step([n, v]); }; } 13 | function step(op) { 14 | if (f) throw new TypeError("Generator is already executing."); 15 | while (_) try { 16 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 17 | if (y = 0, t) op = [op[0] & 2, t.value]; 18 | switch (op[0]) { 19 | case 0: case 1: t = op; break; 20 | case 4: _.label++; return { value: op[1], done: false }; 21 | case 5: _.label++; y = op[1]; op = [0]; continue; 22 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 23 | default: 24 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 25 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 26 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 27 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 28 | if (t[2]) _.ops.pop(); 29 | _.trys.pop(); continue; 30 | } 31 | op = body.call(thisArg, _); 32 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 33 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 34 | } 35 | }; 36 | /** 37 | * @redux true 38 | */ 39 | var UserState = /** @class */ (function () { 40 | function UserState() { 41 | this.logged = false; 42 | this.username = "anonymous"; 43 | } 44 | UserState.prototype.login = function (loginInfo) { 45 | return __awaiter(this, void 0, void 0, function () { 46 | return __generator(this, function (_a) { 47 | console.log("Login called with ", loginInfo); 48 | return [2 /*return*/]; 49 | }); 50 | }); 51 | }; 52 | UserState.prototype.logout = function () { 53 | return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { 54 | return [2 /*return*/]; 55 | }); }); 56 | }; 57 | UserState.prototype.fakeLogin = function () { 58 | this.username = "Fake Login"; 59 | }; 60 | return UserState; 61 | }()); 62 | //# sourceMappingURL=UserState.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/WaspModel.d.ts: -------------------------------------------------------------------------------- 1 | export interface Wasp { 2 | id?: number; 3 | x: number; 4 | y: number; 5 | dx?: number; 6 | dy?: number; 7 | steps?: number; 8 | color?: string; 9 | } 10 | -------------------------------------------------------------------------------- /dist/src/frontend/models/WaspModel.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | /** 4 | * @redux true 5 | */ 6 | var WaspModel = /** @class */ (function () { 7 | function WaspModel() { 8 | this.speed = 10; 9 | this.lastId = 1; 10 | this.wasps = {}; 11 | } 12 | WaspModel.prototype.addWasp = function (pos) { 13 | var o = { x: 0, y: 0 }; 14 | o.id = this.lastId++; 15 | o.x = pos.x; 16 | o.y = pos.y; 17 | o.dx = 1 - 2 * Math.random(); 18 | o.dy = 1 - 2 * Math.random(); 19 | o.color = "red"; 20 | this.wasps[o.id] = o; 21 | }; 22 | WaspModel.prototype.incSpeed = function (value) { 23 | this.speed = this.speed + value; 24 | }; 25 | WaspModel.prototype.setColor = function (value) { 26 | if (this.wasps[value.waspId]) 27 | this.wasps[value.waspId].color = value.colorValue; 28 | }; 29 | WaspModel.prototype.step = function () { 30 | var _this = this; 31 | var list = Object.keys(this.wasps).map(function (i) { return _this.wasps[i]; }); 32 | if (list.length === 0) { 33 | return; 34 | } 35 | var center = list.reduce(function (prev, curr) { 36 | return { 37 | x: prev.x + curr.x, 38 | y: prev.y + curr.y 39 | }; 40 | }, { x: 0, y: 0 }); 41 | center.x = center.x / list.length; 42 | center.y = center.y / list.length; 43 | for (var _i = 0, _a = Object.keys(this.wasps); _i < _a.length; _i++) { 44 | var key = _a[_i]; 45 | var wasp = this.wasps[key]; 46 | var x = center.x - wasp.x; 47 | var y = center.y - wasp.y; 48 | var len = Math.sqrt(x * x + y * y); 49 | if (len > 20) { 50 | wasp.dx += x / len; 51 | wasp.dy += y / len; 52 | } 53 | wasp.steps = 0; 54 | wasp.x += wasp.dx; 55 | wasp.y += wasp.dy; 56 | if (wasp.x < 0 || wasp.x > 300) 57 | wasp.dx = wasp.dx * -1; 58 | if (wasp.y < 0 || wasp.y > 300) 59 | wasp.dy = wasp.dy * -1; 60 | wasp.steps++; 61 | } 62 | }; 63 | return WaspModel; 64 | }()); 65 | //# sourceMappingURL=WaspModel.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/genericModel.d.ts: -------------------------------------------------------------------------------- 1 | export interface Summable { 2 | value: () => number; 3 | } 4 | export declare class SomeList { 5 | items: T[]; 6 | forItems(fn: (item: T) => void): void; 7 | addItems(items: T[]): void; 8 | } 9 | /** 10 | * @redux true 11 | */ 12 | export declare class GenericModel { 13 | sum: number; 14 | isLoading: { 15 | [key: string]: boolean; 16 | }; 17 | list: SomeList; 18 | refreshSum(): void; 19 | addItems(items: T[]): void; 20 | inc(): void; 21 | testLoading(): Promise; 22 | } 23 | -------------------------------------------------------------------------------- /dist/src/frontend/models/genericModel.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | return new (P || (P = Promise))(function (resolve, reject) { 4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 7 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 8 | }); 9 | }; 10 | var __generator = (this && this.__generator) || function (thisArg, body) { 11 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 12 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 13 | function verb(n) { return function (v) { return step([n, v]); }; } 14 | function step(op) { 15 | if (f) throw new TypeError("Generator is already executing."); 16 | while (_) try { 17 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 18 | if (y = 0, t) op = [op[0] & 2, t.value]; 19 | switch (op[0]) { 20 | case 0: case 1: t = op; break; 21 | case 4: _.label++; return { value: op[1], done: false }; 22 | case 5: _.label++; y = op[1]; op = [0]; continue; 23 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 24 | default: 25 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 26 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 27 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 28 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 29 | if (t[2]) _.ops.pop(); 30 | _.trys.pop(); continue; 31 | } 32 | op = body.call(thisArg, _); 33 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 34 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 35 | } 36 | }; 37 | Object.defineProperty(exports, "__esModule", { value: true }); 38 | var SomeList = /** @class */ (function () { 39 | function SomeList() { 40 | this.items = []; 41 | } 42 | SomeList.prototype.forItems = function (fn) { 43 | this.items.forEach(fn); 44 | }; 45 | SomeList.prototype.addItems = function (items) { 46 | console.log("Generic SomeList::addItems was called..."); 47 | console.log(this); 48 | this.items = this.items.concat(items); 49 | }; 50 | return SomeList; 51 | }()); 52 | exports.SomeList = SomeList; 53 | /** 54 | * @redux true 55 | */ 56 | var GenericModel = /** @class */ (function () { 57 | function GenericModel() { 58 | this.sum = 0; 59 | this.isLoading = {}; 60 | // This is not a good idea with Immer... 61 | this.list = new SomeList(); 62 | } 63 | GenericModel.prototype.refreshSum = function () { 64 | this.sum = this.list.items.reduce(function (prev, curr) { return prev + curr.value(); }, 0); 65 | }; 66 | GenericModel.prototype.addItems = function (items) { 67 | console.log(this); 68 | this.list.addItems(items); 69 | this.refreshSum(); 70 | }; 71 | GenericModel.prototype.inc = function () { 72 | this.sum++; 73 | }; 74 | GenericModel.prototype.testLoading = function () { 75 | return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { 76 | return [2 /*return*/]; 77 | }); }); 78 | }; 79 | return GenericModel; 80 | }()); 81 | exports.GenericModel = GenericModel; 82 | //# sourceMappingURL=genericModel.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/interfaces.d.ts: -------------------------------------------------------------------------------- 1 | export interface TodoListItem { 2 | userId: number; 3 | id: number; 4 | title: string; 5 | completed: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /dist/src/frontend/models/interfaces.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | //# sourceMappingURL=interfaces.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/red/TestModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | newItemName?: string; 10 | items: ShopCartItem[]; 11 | } 12 | export declare enum TaskState { 13 | UNDEFINED = 0, 14 | RUNNING = 1, 15 | ERROR = 2, 16 | SUCCESS = 3 17 | } 18 | import { State } from './index'; 19 | import * as React from 'react'; 20 | export interface ContainerPropsMethods { 21 | setUserMessage?: (value: string) => any; 22 | add?: (item: ShopCartItem) => any; 23 | removeFirst?: () => any; 24 | sort?: () => any; 25 | addCart?: () => any; 26 | addCartSync?: () => any; 27 | addToCart?: (adding: { 28 | cartId: string; 29 | item: ShopCartItem; 30 | }) => any; 31 | setCartNewItem?: (adding: { 32 | cartId: string; 33 | name: string; 34 | }) => any; 35 | addToCartRandom?: () => any; 36 | renameLast?: (newName: string) => any; 37 | createItem?: (someName: string) => any; 38 | addOneFriend?: (name: any) => any; 39 | fillSomeFriends?: () => any; 40 | ChangeLastItem?: () => any; 41 | } 42 | export interface ITestModel { 43 | items: ShopCartItem[]; 44 | maxId: number; 45 | cartId: number; 46 | shopState: TaskState; 47 | carts: { 48 | [key: string]: ShopCart; 49 | }; 50 | userMessage: string; 51 | } 52 | export interface ContainerPropsState extends ITestModel { 53 | } 54 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 55 | } 56 | export declare const mapStateToProps: (state: State) => ContainerPropsState; 57 | export declare const mapDispatchToProps: (dispatch: any) => ContainerPropsMethods; 58 | export declare const StateConnector: any; 59 | /** 60 | * @generated true 61 | */ 62 | export declare class RTestModel { 63 | private _state?; 64 | private _dispatch?; 65 | private _getState?; 66 | constructor(state?: ITestModel, dispatch?: (action: any) => void, getState?: () => any); 67 | items: ShopCartItem[]; 68 | maxId: number; 69 | cartId: number; 70 | shopState: TaskState; 71 | carts: { 72 | [key: string]: ShopCart; 73 | }; 74 | userMessage: string; 75 | setUserMessage(value: string): void; 76 | static setUserMessage(value: string): (dispatcher: any, getState: any) => void; 77 | add(item: ShopCartItem): void; 78 | static add(item: ShopCartItem): (dispatcher: any, getState: any) => void; 79 | removeFirst(): void; 80 | static removeFirst(): (dispatcher: any, getState: any) => void; 81 | sort(): void; 82 | static sort(): (dispatcher: any, getState: any) => void; 83 | addCart(): void; 84 | static addCart(): (dispatcher: any, getState: any) => void; 85 | addCartSync(): void; 86 | static addCartSync(): (dispatcher: any, getState: any) => void; 87 | addToCart(adding: { 88 | cartId: string; 89 | item: ShopCartItem; 90 | }): void; 91 | static addToCart(adding: { 92 | cartId: string; 93 | item: ShopCartItem; 94 | }): (dispatcher: any, getState: any) => void; 95 | setCartNewItem(adding: { 96 | cartId: string; 97 | name: string; 98 | }): void; 99 | static setCartNewItem(adding: { 100 | cartId: string; 101 | name: string; 102 | }): (dispatcher: any, getState: any) => void; 103 | addToCartRandom(): void; 104 | static addToCartRandom(): (dispatcher: any, getState: any) => void; 105 | renameLast(newName: string): void; 106 | static renameLast(newName: string): (dispatcher: any, getState: any) => void; 107 | createItem(someName: string): Promise; 108 | static createItem(someName: string): (dispatcher: any, getState: any) => void; 109 | addOneFriend(name: any): Promise; 110 | static addOneFriend(name: any): (dispatcher: any, getState: any) => void; 111 | fillSomeFriends(): Promise; 112 | static fillSomeFriends(): (dispatcher: any, getState: any) => void; 113 | ChangeLastItem(): Promise; 114 | static ChangeLastItem(): (dispatcher: any, getState: any) => void; 115 | } 116 | export declare const TestModelEnums: { 117 | TestModel_items: string; 118 | TestModel_maxId: string; 119 | TestModel_cartId: string; 120 | TestModel_shopState: string; 121 | TestModel_carts: string; 122 | TestModel_userMessage: string; 123 | TestModel_setUserMessage: string; 124 | TestModel_add: string; 125 | TestModel_removeFirst: string; 126 | TestModel_sort: string; 127 | TestModel_addCart: string; 128 | TestModel_addCartSync: string; 129 | TestModel_addToCart: string; 130 | TestModel_setCartNewItem: string; 131 | TestModel_addToCartRandom: string; 132 | TestModel_renameLast: string; 133 | }; 134 | export declare const TestModelReducer: (state: ITestModel, action: any) => ITestModel; 135 | /*************************** 136 | * React Context API test * 137 | ***************************/ 138 | export declare const TestModelContext: React.Context; 139 | export declare const TestModelConsumer: React.ComponentType>; 140 | export declare class TestModelProvider extends React.Component { 141 | state: ITestModel; 142 | __devTools: any; 143 | constructor(props: any); 144 | componentWillUnmount(): void; 145 | setUserMessage(value: string): void; 146 | add(item: ShopCartItem): void; 147 | removeFirst(): void; 148 | sort(): void; 149 | addCart(): void; 150 | addCartSync(): void; 151 | addToCart(adding: { 152 | cartId: string; 153 | item: ShopCartItem; 154 | }): void; 155 | setCartNewItem(adding: { 156 | cartId: string; 157 | name: string; 158 | }): void; 159 | addToCartRandom(): void; 160 | renameLast(newName: string): void; 161 | createItem(someName: string): Promise; 162 | addOneFriend(name: any): Promise; 163 | fillSomeFriends(): Promise; 164 | ChangeLastItem(): Promise; 165 | render(): JSX.Element; 166 | } 167 | -------------------------------------------------------------------------------- /dist/src/frontend/models/red/TodoList.d.ts: -------------------------------------------------------------------------------- 1 | export interface TodoListItem { 2 | userId: number; 3 | id: number; 4 | title: string; 5 | completed: boolean; 6 | } 7 | export declare type TaskState = 'UNDEFINED' | 'RUNNING' | 'LOADED' | 'ERROR'; 8 | /** 9 | * @redux true 10 | */ 11 | export declare class TodoList { 12 | items: TodoListItem[]; 13 | state: TaskState; 14 | stateError: any; 15 | clearTodoList(): void; 16 | reverse(): void; 17 | sortById(): void; 18 | sortByTitle(): void; 19 | sortByCompletion(): void; 20 | getItems(): Promise; 21 | } 22 | import { State } from './index'; 23 | import * as React from 'react'; 24 | export interface ContainerPropsMethods { 25 | clearTodoList?: () => any; 26 | reverse?: () => any; 27 | sortById?: () => any; 28 | sortByTitle?: () => any; 29 | sortByCompletion?: () => any; 30 | getItems?: () => any; 31 | } 32 | export interface ITodoList { 33 | items: TodoListItem[]; 34 | state: TaskState; 35 | stateError: any; 36 | } 37 | export interface ContainerPropsState extends ITodoList { 38 | } 39 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 40 | } 41 | export declare const mapStateToProps: (state: State) => ContainerPropsState; 42 | export declare const mapDispatchToProps: (dispatch: any) => ContainerPropsMethods; 43 | export declare const StateConnector: any; 44 | /** 45 | * @generated true 46 | */ 47 | export declare class RTodoList { 48 | private _state?; 49 | private _dispatch?; 50 | private _getState?; 51 | constructor(state?: ITodoList, dispatch?: (action: any) => void, getState?: () => any); 52 | items: TodoListItem[]; 53 | state: TaskState; 54 | stateError: any; 55 | clearTodoList(): void; 56 | static clearTodoList(): (dispatcher: any, getState: any) => void; 57 | reverse(): void; 58 | static reverse(): (dispatcher: any, getState: any) => void; 59 | sortById(): void; 60 | static sortById(): (dispatcher: any, getState: any) => void; 61 | sortByTitle(): void; 62 | static sortByTitle(): (dispatcher: any, getState: any) => void; 63 | sortByCompletion(): void; 64 | static sortByCompletion(): (dispatcher: any, getState: any) => void; 65 | getItems(): Promise; 66 | static getItems(): (dispatcher: any, getState: any) => void; 67 | } 68 | export declare const TodoListEnums: { 69 | TodoList_items: string; 70 | TodoList_state: string; 71 | TodoList_stateError: string; 72 | TodoList_clearTodoList: string; 73 | TodoList_reverse: string; 74 | TodoList_sortById: string; 75 | TodoList_sortByTitle: string; 76 | TodoList_sortByCompletion: string; 77 | }; 78 | export declare const TodoListReducer: (state: ITodoList, action: any) => ITodoList; 79 | /*************************** 80 | * React Context API test * 81 | ***************************/ 82 | export declare const TodoListContext: React.Context; 83 | export declare const TodoListConsumer: React.ComponentType>; 84 | export declare class TodoListProvider extends React.Component { 85 | state: ITodoList; 86 | __devTools: any; 87 | constructor(props: any); 88 | componentWillUnmount(): void; 89 | clearTodoList(): void; 90 | reverse(): void; 91 | sortById(): void; 92 | sortByTitle(): void; 93 | sortByCompletion(): void; 94 | getItems(): Promise; 95 | render(): JSX.Element; 96 | } 97 | -------------------------------------------------------------------------------- /dist/src/frontend/models/red/UserState.d.ts: -------------------------------------------------------------------------------- 1 | import { State } from './index'; 2 | import * as React from 'react'; 3 | export interface ContainerPropsMethods { 4 | login?: (loginInfo: { 5 | username: string; 6 | password: string; 7 | }) => any; 8 | logout?: () => any; 9 | fakeLogin?: () => any; 10 | } 11 | export interface IUserState { 12 | logged: boolean; 13 | username: string; 14 | firstName: string; 15 | lastName: string; 16 | lastLogin: number; 17 | } 18 | export interface ContainerPropsState extends IUserState { 19 | } 20 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 21 | } 22 | export declare const mapStateToProps: (state: State) => ContainerPropsState; 23 | export declare const mapDispatchToProps: (dispatch: any) => ContainerPropsMethods; 24 | export declare const StateConnector: any; 25 | /** 26 | * @generated true 27 | */ 28 | export declare class RUserState { 29 | private _state?; 30 | private _dispatch?; 31 | private _getState?; 32 | constructor(state?: IUserState, dispatch?: (action: any) => void, getState?: () => any); 33 | logged: boolean; 34 | username: string; 35 | firstName: string; 36 | lastName: string; 37 | lastLogin: number; 38 | login(loginInfo: { 39 | username: string; 40 | password: string; 41 | }): Promise; 42 | static login(loginInfo: { 43 | username: string; 44 | password: string; 45 | }): (dispatcher: any, getState: any) => void; 46 | logout(): Promise; 47 | static logout(): (dispatcher: any, getState: any) => void; 48 | fakeLogin(): void; 49 | static fakeLogin(): (dispatcher: any, getState: any) => void; 50 | } 51 | export declare const UserStateEnums: { 52 | UserState_logged: string; 53 | UserState_username: string; 54 | UserState_firstName: string; 55 | UserState_lastName: string; 56 | UserState_lastLogin: string; 57 | UserState_fakeLogin: string; 58 | }; 59 | export declare const UserStateReducer: (state: IUserState, action: any) => IUserState; 60 | /*************************** 61 | * React Context API test * 62 | ***************************/ 63 | export declare const UserStateContext: React.Context; 64 | export declare const UserStateConsumer: React.ComponentType>; 65 | export declare class UserStateProvider extends React.Component { 66 | state: IUserState; 67 | __devTools: any; 68 | constructor(props: any); 69 | componentWillUnmount(): void; 70 | login(loginInfo: { 71 | username: string; 72 | password: string; 73 | }): Promise; 74 | logout(): Promise; 75 | fakeLogin(): void; 76 | render(): JSX.Element; 77 | } 78 | -------------------------------------------------------------------------------- /dist/src/frontend/models/red/index.d.ts: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * * 3 | * Combined Reducers for main application * 4 | * Generated by ts2redux at 2018-10-20T09:52:23.782Z * 5 | * * 6 | **********************************************************/ 7 | import * as redux from 'redux'; 8 | import { ITestModel } from './TestModel'; 9 | import { ITodoList } from './TodoList'; 10 | import { IUserState } from './UserState'; 11 | export interface State { 12 | TestModel: ITestModel; 13 | TodoList: ITodoList; 14 | UserState: IUserState; 15 | } 16 | export declare const reducers: redux.Reducer; 17 | -------------------------------------------------------------------------------- /dist/src/frontend/models/red/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | /********************************************************** 4 | * * 5 | * Combined Reducers for main application * 6 | * Generated by ts2redux at 2018-10-20T09:52:23.782Z * 7 | * * 8 | **********************************************************/ 9 | var redux = require("redux"); 10 | var TestModel_1 = require("./TestModel"); 11 | var TodoList_1 = require("./TodoList"); 12 | var UserState_1 = require("./UserState"); 13 | exports.reducers = redux.combineReducers({ 14 | TestModel: TestModel_1.TestModelReducer, 15 | TodoList: TodoList_1.TodoListReducer, 16 | UserState: UserState_1.UserStateReducer, 17 | }); 18 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/IncModel.d.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state IncModel * 4 | * Generated by ts2redux from Source file ../IncModel.ts * 5 | * * 6 | ********************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | export declare class IncModel { 10 | cnt: number; 11 | increment(): void; 12 | decrement(): void; 13 | readonly incValue: number; 14 | } 15 | export interface IContainerPropsMethods { 16 | increment: () => any; 17 | decrement: () => any; 18 | } 19 | export interface IIncModel { 20 | cnt: number; 21 | } 22 | export declare type IContainerPropsState = IIncModel; 23 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 24 | } 25 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 26 | export declare const mapStateToProps: (state: IState) => IIncModel; 27 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 28 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 29 | export declare const StateConnector: any; 30 | /** 31 | * @generated true 32 | */ 33 | export declare class RIncModel { 34 | private _state?; 35 | private _dispatch?; 36 | private _getState?; 37 | constructor(state?: IIncModel, dispatch?: (action: any) => any, getState?: () => any); 38 | cnt: number; 39 | increment(): void; 40 | static increment(): (dispatcher: any, getState: any) => void; 41 | decrement(): void; 42 | static decrement(): (dispatcher: any, getState: any) => void; 43 | } 44 | export declare const IncModelEnums: { 45 | IncModel_cnt: string; 46 | IncModel_increment: string; 47 | IncModel_decrement: string; 48 | }; 49 | export declare const IncModelReducer: (state: IIncModel, action: any) => IIncModel; 50 | /******************************** 51 | * React Context API component * 52 | ********************************/ 53 | export declare const IncModelContext: React.Context; 54 | export declare const IncModelConsumer: React.ComponentType>; 55 | export declare class IncModelProvider extends React.Component { 56 | state: IIncModel; 57 | lastSetState: IIncModel; 58 | private __devTools; 59 | constructor(props: any); 60 | componentWillUnmount(): void; 61 | setStateSync(state: IIncModel): void; 62 | increment(): void; 63 | decrement(): void; 64 | render(): JSX.Element; 65 | } 66 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/SimpleModel.d.ts: -------------------------------------------------------------------------------- 1 | /*********************************************************************************** 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state SimpleModel * 4 | * Generated by ts2redux from Source file ../SimpleModel.ts * 5 | * * 6 | ***********************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | /** 10 | * @redux true 11 | */ 12 | export declare class SimpleModel { 13 | items: any[]; 14 | /** 15 | * @dispatch true 16 | * @param action 17 | */ 18 | SimpleDispatch(action: any): Promise; 19 | getItems(): Promise; 20 | readonly myItems: any[]; 21 | } 22 | export interface IContainerPropsMethods { 23 | SimpleDispatch: (action: any) => any; 24 | getItems: () => any; 25 | } 26 | export interface ISimpleModel { 27 | items: any[]; 28 | } 29 | export declare const itemsSelectorFn: (state: ISimpleModel) => any[]; 30 | export declare const myItemsSelectorFnCreator: () => import("reselect").OutputSelector any[]>; 31 | export declare const myItemsSelector: import("reselect").OutputSelector any[]>; 32 | export interface IContainerPropsState extends ISimpleModel { 33 | myItems: any[]; 34 | } 35 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 36 | } 37 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 38 | export declare const mapStateToProps: (state: IState) => IContainerPropsState; 39 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 40 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 41 | export declare const StateConnector: any; 42 | /** 43 | * @generated true 44 | */ 45 | export declare class RSimpleModel { 46 | private _state?; 47 | private _dispatch?; 48 | private _getState?; 49 | constructor(state?: ISimpleModel, dispatch?: (action: any) => any, getState?: () => any); 50 | items: any[]; 51 | SimpleDispatch(action: any): Promise; 52 | static SimpleDispatch(action: any): (dispatcher: any, getState: any) => Promise; 53 | getItems(): Promise; 54 | static getItems(): (dispatcher: any, getState: any) => Promise; 55 | } 56 | export declare const SimpleModelEnums: { 57 | SimpleModel_items: string; 58 | }; 59 | export declare const SimpleModelReducer: (state: ISimpleModel, action: any) => ISimpleModel; 60 | /******************************** 61 | * React Context API component * 62 | ********************************/ 63 | export declare const SimpleModelContext: React.Context; 64 | export declare const SimpleModelConsumer: React.ComponentType>; 65 | export declare class SimpleModelProvider extends React.Component { 66 | state: ISimpleModel; 67 | lastSetState: ISimpleModel; 68 | private __devTools; 69 | private __selectormyItems; 70 | constructor(props: any); 71 | componentWillUnmount(): void; 72 | setStateSync(state: ISimpleModel): void; 73 | /** 74 | * @dispatch true 75 | * @param action 76 | */ 77 | SimpleDispatch(action: any): Promise; 78 | getItems(): Promise; 79 | render(): JSX.Element; 80 | } 81 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/TestModelCtx.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | newItemName?: string; 10 | items: ShopCartItem[]; 11 | } 12 | export declare enum TaskState { 13 | UNDEFINED = 0, 14 | RUNNING = 1, 15 | ERROR = 2, 16 | SUCCESS = 3 17 | } 18 | import { State } from './index'; 19 | import * as React from 'react'; 20 | export interface ContainerPropsMethods { 21 | setUserMessage?: (value: string) => any; 22 | add?: (item: ShopCartItem) => any; 23 | removeFirst?: () => any; 24 | sort?: () => any; 25 | addCart?: () => any; 26 | addCartSync?: () => any; 27 | addToCart?: (adding: { 28 | cartId: string; 29 | item: ShopCartItem; 30 | }) => any; 31 | setCartNewItem?: (adding: { 32 | cartId: string; 33 | name: string; 34 | }) => any; 35 | addToCartRandom?: () => any; 36 | renameLast?: (newName: string) => any; 37 | createItem?: (someName: string) => any; 38 | addOneFriend?: (name: any) => any; 39 | fillSomeFriends?: () => any; 40 | ChangeLastItem?: () => any; 41 | } 42 | export interface ITestModel { 43 | items: ShopCartItem[]; 44 | maxId: number; 45 | cartId: number; 46 | shopState: TaskState; 47 | carts: { 48 | [key: string]: ShopCart; 49 | }; 50 | userMessage: string; 51 | } 52 | export interface ContainerPropsState extends ITestModel { 53 | } 54 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 55 | } 56 | export declare const mapStateToProps: (state: State) => ContainerPropsState; 57 | export declare const mapDispatchToProps: (dispatch: any) => ContainerPropsMethods; 58 | export declare const StateConnector: any; 59 | /** 60 | * @generated true 61 | */ 62 | export declare class RTestModel { 63 | private _state?; 64 | private _dispatch?; 65 | private _getState?; 66 | constructor(state?: ITestModel, dispatch?: (action: any) => void, getState?: () => any); 67 | items: ShopCartItem[]; 68 | maxId: number; 69 | cartId: number; 70 | shopState: TaskState; 71 | carts: { 72 | [key: string]: ShopCart; 73 | }; 74 | userMessage: string; 75 | setUserMessage(value: string): void; 76 | static setUserMessage(value: string): (dispatcher: any, getState: any) => void; 77 | add(item: ShopCartItem): void; 78 | static add(item: ShopCartItem): (dispatcher: any, getState: any) => void; 79 | removeFirst(): void; 80 | static removeFirst(): (dispatcher: any, getState: any) => void; 81 | sort(): void; 82 | static sort(): (dispatcher: any, getState: any) => void; 83 | addCart(): void; 84 | static addCart(): (dispatcher: any, getState: any) => void; 85 | addCartSync(): void; 86 | static addCartSync(): (dispatcher: any, getState: any) => void; 87 | addToCart(adding: { 88 | cartId: string; 89 | item: ShopCartItem; 90 | }): void; 91 | static addToCart(adding: { 92 | cartId: string; 93 | item: ShopCartItem; 94 | }): (dispatcher: any, getState: any) => void; 95 | setCartNewItem(adding: { 96 | cartId: string; 97 | name: string; 98 | }): void; 99 | static setCartNewItem(adding: { 100 | cartId: string; 101 | name: string; 102 | }): (dispatcher: any, getState: any) => void; 103 | addToCartRandom(): void; 104 | static addToCartRandom(): (dispatcher: any, getState: any) => void; 105 | renameLast(newName: string): void; 106 | static renameLast(newName: string): (dispatcher: any, getState: any) => void; 107 | createItem(someName: string): Promise; 108 | static createItem(someName: string): (dispatcher: any, getState: any) => void; 109 | addOneFriend(name: any): Promise; 110 | static addOneFriend(name: any): (dispatcher: any, getState: any) => void; 111 | fillSomeFriends(): Promise; 112 | static fillSomeFriends(): (dispatcher: any, getState: any) => void; 113 | ChangeLastItem(): Promise; 114 | static ChangeLastItem(): (dispatcher: any, getState: any) => void; 115 | } 116 | export declare const TestModelEnums: { 117 | TestModel_items: string; 118 | TestModel_maxId: string; 119 | TestModel_cartId: string; 120 | TestModel_shopState: string; 121 | TestModel_carts: string; 122 | TestModel_userMessage: string; 123 | TestModel_setUserMessage: string; 124 | TestModel_add: string; 125 | TestModel_removeFirst: string; 126 | TestModel_sort: string; 127 | TestModel_addCart: string; 128 | TestModel_addCartSync: string; 129 | TestModel_addToCart: string; 130 | TestModel_setCartNewItem: string; 131 | TestModel_addToCartRandom: string; 132 | TestModel_renameLast: string; 133 | }; 134 | export declare const TestModelReducer: (state: ITestModel, action: any) => ITestModel; 135 | /*************************** 136 | * React Context API test * 137 | ***************************/ 138 | export declare const TestModelContext: React.Context; 139 | export declare class TestModelStore extends React.Component { 140 | state: ITestModel; 141 | constructor(props: any); 142 | setUserMessage(value: string): void; 143 | add(item: ShopCartItem): void; 144 | removeFirst(): void; 145 | sort(): void; 146 | addCart(): void; 147 | addCartSync(): void; 148 | addToCart(adding: { 149 | cartId: string; 150 | item: ShopCartItem; 151 | }): void; 152 | setCartNewItem(adding: { 153 | cartId: string; 154 | name: string; 155 | }): void; 156 | addToCartRandom(): void; 157 | renameLast(newName: string): void; 158 | createItem(someName: string): Promise; 159 | addOneFriend(name: any): Promise; 160 | fillSomeFriends(): Promise; 161 | ChangeLastItem(): Promise; 162 | render(): JSX.Element; 163 | } 164 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/TetrisModel.d.ts: -------------------------------------------------------------------------------- 1 | /*********************************************************************************** 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state TetrisModel * 4 | * Generated by ts2redux from Source file ../TetrisModel.ts * 5 | * * 6 | ***********************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | export interface Cell { 10 | color: string; 11 | } 12 | export declare enum Colors { 13 | EMPTY = "" 14 | } 15 | export interface ActivePiece { 16 | x: number; 17 | y: number; 18 | width: number; 19 | height: number; 20 | cells: Cell[][]; 21 | } 22 | /** 23 | * [' O '], 24 | * ['OOO'], 25 | * [' O '] 26 | */ 27 | export declare const createNewPiece: (usingColor: string) => ActivePiece; 28 | /** 29 | * @redux true 30 | */ 31 | export declare class TetrisModel { 32 | useColors: string[]; 33 | lastUsedColor: number; 34 | points: number; 35 | rows: number; 36 | cols: number; 37 | cells: Cell[][]; 38 | activePiece?: ActivePiece; 39 | gameOn: boolean; 40 | gameEnded: boolean; 41 | ticksPerMove: number; 42 | tickCnt: number; 43 | dx: number; 44 | dy: number; 45 | private doesCollide; 46 | tick(): void; 47 | left(): void; 48 | right(): void; 49 | rotate(): void; 50 | private rotateCells; 51 | step(): void; 52 | private pickNextColor; 53 | masonPiece(): void; 54 | dropRows(): void; 55 | clearCells(): void; 56 | resetGame(): void; 57 | start(): void; 58 | } 59 | export interface IContainerPropsMethods { 60 | tick: () => any; 61 | left: () => any; 62 | right: () => any; 63 | rotate: () => any; 64 | step: () => any; 65 | masonPiece: () => any; 66 | dropRows: () => any; 67 | clearCells: () => any; 68 | resetGame: () => any; 69 | start: () => any; 70 | } 71 | export interface ITetrisModel { 72 | useColors: Array; 73 | lastUsedColor: number; 74 | points: number; 75 | rows: number; 76 | cols: number; 77 | cells: Cell[][]; 78 | activePiece?: ActivePiece; 79 | gameOn: boolean; 80 | gameEnded: boolean; 81 | ticksPerMove: number; 82 | tickCnt: number; 83 | dx: number; 84 | dy: number; 85 | } 86 | export declare type IContainerPropsState = ITetrisModel; 87 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 88 | } 89 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 90 | export declare const mapStateToProps: (state: IState) => ITetrisModel; 91 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 92 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 93 | export declare const StateConnector: any; 94 | /** 95 | * @generated true 96 | */ 97 | export declare class RTetrisModel { 98 | private _state?; 99 | private _dispatch?; 100 | private _getState?; 101 | constructor(state?: ITetrisModel, dispatch?: (action: any) => any, getState?: () => any); 102 | useColors: Array; 103 | lastUsedColor: number; 104 | points: number; 105 | rows: number; 106 | cols: number; 107 | cells: Cell[][]; 108 | activePiece: ActivePiece | undefined; 109 | gameOn: boolean; 110 | gameEnded: boolean; 111 | ticksPerMove: number; 112 | tickCnt: number; 113 | dx: number; 114 | dy: number; 115 | private doesCollide; 116 | tick(): void; 117 | static tick(): (dispatcher: any, getState: any) => void; 118 | left(): void; 119 | static left(): (dispatcher: any, getState: any) => void; 120 | right(): void; 121 | static right(): (dispatcher: any, getState: any) => void; 122 | rotate(): void; 123 | static rotate(): (dispatcher: any, getState: any) => void; 124 | private rotateCells; 125 | step(): void; 126 | static step(): (dispatcher: any, getState: any) => void; 127 | private pickNextColor; 128 | masonPiece(): void; 129 | static masonPiece(): (dispatcher: any, getState: any) => void; 130 | dropRows(): void; 131 | static dropRows(): (dispatcher: any, getState: any) => void; 132 | clearCells(): void; 133 | static clearCells(): (dispatcher: any, getState: any) => void; 134 | resetGame(): void; 135 | static resetGame(): (dispatcher: any, getState: any) => void; 136 | start(): void; 137 | static start(): (dispatcher: any, getState: any) => void; 138 | } 139 | export declare const TetrisModelEnums: { 140 | TetrisModel_useColors: string; 141 | TetrisModel_lastUsedColor: string; 142 | TetrisModel_points: string; 143 | TetrisModel_rows: string; 144 | TetrisModel_cols: string; 145 | TetrisModel_cells: string; 146 | TetrisModel_activePiece: string; 147 | TetrisModel_gameOn: string; 148 | TetrisModel_gameEnded: string; 149 | TetrisModel_ticksPerMove: string; 150 | TetrisModel_tickCnt: string; 151 | TetrisModel_dx: string; 152 | TetrisModel_dy: string; 153 | TetrisModel_doesCollide: string; 154 | TetrisModel_tick: string; 155 | TetrisModel_left: string; 156 | TetrisModel_right: string; 157 | TetrisModel_rotate: string; 158 | TetrisModel_rotateCells: string; 159 | TetrisModel_step: string; 160 | TetrisModel_pickNextColor: string; 161 | TetrisModel_masonPiece: string; 162 | TetrisModel_dropRows: string; 163 | TetrisModel_clearCells: string; 164 | TetrisModel_resetGame: string; 165 | TetrisModel_start: string; 166 | }; 167 | export declare const TetrisModelReducer: (state: ITetrisModel, action: any) => ITetrisModel; 168 | /******************************** 169 | * React Context API component * 170 | ********************************/ 171 | export declare const TetrisModelContext: React.Context; 172 | export declare const TetrisModelConsumer: React.ComponentType>; 173 | export declare class TetrisModelProvider extends React.Component { 174 | state: ITetrisModel; 175 | lastSetState: ITetrisModel; 176 | private __devTools; 177 | constructor(props: any); 178 | componentWillUnmount(): void; 179 | setStateSync(state: ITetrisModel): void; 180 | tick(): void; 181 | left(): void; 182 | right(): void; 183 | rotate(): void; 184 | step(): void; 185 | masonPiece(): void; 186 | dropRows(): void; 187 | clearCells(): void; 188 | resetGame(): void; 189 | start(): void; 190 | render(): JSX.Element; 191 | } 192 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/TodoListCtx.d.ts: -------------------------------------------------------------------------------- 1 | export interface TodoListItem { 2 | userId: number; 3 | id: number; 4 | title: string; 5 | completed: boolean; 6 | } 7 | export declare type TaskState = 'UNDEFINED' | 'RUNNING' | 'LOADED' | 'ERROR'; 8 | /** 9 | * @redux true 10 | */ 11 | export declare class TodoList { 12 | items: TodoListItem[]; 13 | state: TaskState; 14 | stateError: any; 15 | clearTodoList(): void; 16 | reverse(): void; 17 | sortById(): void; 18 | sortByTitle(): void; 19 | sortByCompletion(): void; 20 | getItems(): Promise; 21 | } 22 | import { State } from './index'; 23 | import * as React from 'react'; 24 | export interface ContainerPropsMethods { 25 | clearTodoList?: () => any; 26 | reverse?: () => any; 27 | sortById?: () => any; 28 | sortByTitle?: () => any; 29 | sortByCompletion?: () => any; 30 | getItems?: () => any; 31 | } 32 | export interface ITodoList { 33 | items: TodoListItem[]; 34 | state: TaskState; 35 | stateError: any; 36 | } 37 | export interface ContainerPropsState extends ITodoList { 38 | } 39 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 40 | } 41 | export declare const mapStateToProps: (state: State) => ContainerPropsState; 42 | export declare const mapDispatchToProps: (dispatch: any) => ContainerPropsMethods; 43 | export declare const StateConnector: any; 44 | /** 45 | * @generated true 46 | */ 47 | export declare class RTodoList { 48 | private _state?; 49 | private _dispatch?; 50 | private _getState?; 51 | constructor(state?: ITodoList, dispatch?: (action: any) => void, getState?: () => any); 52 | items: TodoListItem[]; 53 | state: TaskState; 54 | stateError: any; 55 | clearTodoList(): void; 56 | static clearTodoList(): (dispatcher: any, getState: any) => void; 57 | reverse(): void; 58 | static reverse(): (dispatcher: any, getState: any) => void; 59 | sortById(): void; 60 | static sortById(): (dispatcher: any, getState: any) => void; 61 | sortByTitle(): void; 62 | static sortByTitle(): (dispatcher: any, getState: any) => void; 63 | sortByCompletion(): void; 64 | static sortByCompletion(): (dispatcher: any, getState: any) => void; 65 | getItems(): Promise; 66 | static getItems(): (dispatcher: any, getState: any) => void; 67 | } 68 | export declare const TodoListEnums: { 69 | TodoList_items: string; 70 | TodoList_state: string; 71 | TodoList_stateError: string; 72 | TodoList_clearTodoList: string; 73 | TodoList_reverse: string; 74 | TodoList_sortById: string; 75 | TodoList_sortByTitle: string; 76 | TodoList_sortByCompletion: string; 77 | }; 78 | export declare const TodoListReducer: (state: ITodoList, action: any) => ITodoList; 79 | /*************************** 80 | * React Context API test * 81 | ***************************/ 82 | export declare const TodoListContext: React.Context; 83 | export declare class TodoListStore extends React.Component { 84 | state: ITodoList; 85 | constructor(props: any); 86 | clearTodoList(): void; 87 | reverse(): void; 88 | sortById(): void; 89 | sortByTitle(): void; 90 | sortByCompletion(): void; 91 | getItems(): Promise; 92 | render(): JSX.Element; 93 | } 94 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/UIHelperModel.d.ts: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state UIHelperModel * 4 | * Generated by ts2redux from Source file ../UIHelper.ts * 5 | * * 6 | *************************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | export interface IContainerPropsMethods { 10 | toggle: () => any; 11 | } 12 | export interface IUIHelperModel { 13 | showWasps: boolean; 14 | } 15 | export declare type IContainerPropsState = IUIHelperModel; 16 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 17 | } 18 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 19 | export declare const mapStateToProps: (state: IState) => IUIHelperModel; 20 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 21 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 22 | export declare const StateConnector: any; 23 | /** 24 | * @generated true 25 | */ 26 | export declare class RUIHelperModel { 27 | private _state?; 28 | private _dispatch?; 29 | private _getState?; 30 | constructor(state?: IUIHelperModel, dispatch?: (action: any) => any, getState?: () => any); 31 | showWasps: boolean; 32 | toggle(): void; 33 | static toggle(): (dispatcher: any, getState: any) => void; 34 | } 35 | export declare const UIHelperModelEnums: { 36 | UIHelperModel_showWasps: string; 37 | UIHelperModel_toggle: string; 38 | }; 39 | export declare const UIHelperModelReducer: (state: IUIHelperModel, action: any) => IUIHelperModel; 40 | /******************************** 41 | * React Context API component * 42 | ********************************/ 43 | export declare const UIHelperModelContext: React.Context; 44 | export declare const UIHelperModelConsumer: React.ComponentType>; 45 | export declare class UIHelperModelProvider extends React.Component { 46 | state: IUIHelperModel; 47 | lastSetState: IUIHelperModel; 48 | private __devTools; 49 | constructor(props: any); 50 | componentWillUnmount(): void; 51 | setStateSync(state: IUIHelperModel): void; 52 | toggle(): void; 53 | render(): JSX.Element; 54 | } 55 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/UserState.d.ts: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state UserState * 4 | * Generated by ts2redux from Source file ../UserState.ts * 5 | * * 6 | *********************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | export interface IContainerPropsMethods { 10 | login: (loginInfo: { 11 | username: string; 12 | password: string; 13 | }) => any; 14 | logout: () => any; 15 | fakeLogin: () => any; 16 | } 17 | export interface IUserState { 18 | logged: boolean; 19 | username: string; 20 | firstName: string; 21 | lastName: string; 22 | lastLogin: number; 23 | } 24 | export declare type IContainerPropsState = IUserState; 25 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 26 | } 27 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 28 | export declare const mapStateToProps: (state: IState) => IUserState; 29 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 30 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 31 | export declare const StateConnector: any; 32 | /** 33 | * @generated true 34 | */ 35 | export declare class RUserState { 36 | private _state?; 37 | private _dispatch?; 38 | private _getState?; 39 | constructor(state?: IUserState, dispatch?: (action: any) => any, getState?: () => any); 40 | logged: boolean; 41 | username: string; 42 | firstName: string; 43 | lastName: string; 44 | lastLogin: number; 45 | login(loginInfo: { 46 | username: string; 47 | password: string; 48 | }): Promise; 49 | static login(loginInfo: { 50 | username: string; 51 | password: string; 52 | }): (dispatcher: any, getState: any) => Promise; 53 | logout(): Promise; 54 | static logout(): (dispatcher: any, getState: any) => Promise; 55 | fakeLogin(): void; 56 | static fakeLogin(): (dispatcher: any, getState: any) => void; 57 | } 58 | export declare const UserStateEnums: { 59 | UserState_logged: string; 60 | UserState_username: string; 61 | UserState_firstName: string; 62 | UserState_lastName: string; 63 | UserState_lastLogin: string; 64 | UserState_fakeLogin: string; 65 | }; 66 | export declare const UserStateReducer: (state: IUserState, action: any) => IUserState; 67 | /******************************** 68 | * React Context API component * 69 | ********************************/ 70 | export declare const UserStateContext: React.Context; 71 | export declare const UserStateConsumer: React.ComponentType>; 72 | export declare class UserStateProvider extends React.Component { 73 | state: IUserState; 74 | lastSetState: IUserState; 75 | private __devTools; 76 | constructor(props: any); 77 | componentWillUnmount(): void; 78 | setStateSync(state: IUserState): void; 79 | login(loginInfo: { 80 | username: string; 81 | password: string; 82 | }): Promise; 83 | logout(): Promise; 84 | fakeLogin(): void; 85 | render(): JSX.Element; 86 | } 87 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/UserStateCtx.d.ts: -------------------------------------------------------------------------------- 1 | import { State } from './index'; 2 | import * as React from 'react'; 3 | export interface ContainerPropsMethods { 4 | login?: (loginInfo: { 5 | username: string; 6 | password: string; 7 | }) => any; 8 | logout?: () => any; 9 | fakeLogin?: () => any; 10 | } 11 | export interface IUserState { 12 | logged: boolean; 13 | username: string; 14 | firstName: string; 15 | lastName: string; 16 | lastLogin: number; 17 | } 18 | export interface ContainerPropsState extends IUserState { 19 | } 20 | export interface Props extends ContainerPropsState, ContainerPropsMethods { 21 | } 22 | export declare const mapStateToProps: (state: State) => ContainerPropsState; 23 | export declare const mapDispatchToProps: (dispatch: any) => ContainerPropsMethods; 24 | export declare const StateConnector: any; 25 | /** 26 | * @generated true 27 | */ 28 | export declare class RUserState { 29 | private _state?; 30 | private _dispatch?; 31 | private _getState?; 32 | constructor(state?: IUserState, dispatch?: (action: any) => void, getState?: () => any); 33 | logged: boolean; 34 | username: string; 35 | firstName: string; 36 | lastName: string; 37 | lastLogin: number; 38 | login(loginInfo: { 39 | username: string; 40 | password: string; 41 | }): Promise; 42 | static login(loginInfo: { 43 | username: string; 44 | password: string; 45 | }): (dispatcher: any, getState: any) => void; 46 | logout(): Promise; 47 | static logout(): (dispatcher: any, getState: any) => void; 48 | fakeLogin(): void; 49 | static fakeLogin(): (dispatcher: any, getState: any) => void; 50 | } 51 | export declare const UserStateEnums: { 52 | UserState_logged: string; 53 | UserState_username: string; 54 | UserState_firstName: string; 55 | UserState_lastName: string; 56 | UserState_lastLogin: string; 57 | UserState_fakeLogin: string; 58 | }; 59 | export declare const UserStateReducer: (state: IUserState, action: any) => IUserState; 60 | /*************************** 61 | * React Context API test * 62 | ***************************/ 63 | export declare const UserStateContext: React.Context; 64 | export declare class UserStateStore extends React.Component { 65 | state: IUserState; 66 | constructor(props: any); 67 | login(loginInfo: { 68 | username: string; 69 | password: string; 70 | }): Promise; 71 | logout(): Promise; 72 | fakeLogin(): void; 73 | render(): JSX.Element; 74 | } 75 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/WaspModel.d.ts: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state WaspModel * 4 | * Generated by ts2redux from Source file ../WaspModel.ts * 5 | * * 6 | *********************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | export interface Wasp { 10 | id?: number; 11 | x: number; 12 | y: number; 13 | dx?: number; 14 | dy?: number; 15 | steps?: number; 16 | color?: string; 17 | } 18 | export interface IContainerPropsMethods { 19 | addWasp: (pos: { 20 | x: number; 21 | y: number; 22 | }) => any; 23 | incSpeed: (value: number) => any; 24 | setColor: (value: { 25 | waspId: number; 26 | colorValue: string; 27 | }) => any; 28 | step: () => any; 29 | } 30 | export interface IWaspModel { 31 | speed: number; 32 | lastId: number; 33 | wasps: { 34 | [id: number]: Wasp; 35 | }; 36 | } 37 | export declare type IContainerPropsState = IWaspModel; 38 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 39 | } 40 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 41 | export declare const mapStateToProps: (state: IState) => IWaspModel; 42 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 43 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 44 | export declare const StateConnector: any; 45 | /** 46 | * @generated true 47 | */ 48 | export declare class RWaspModel { 49 | private _state?; 50 | private _dispatch?; 51 | private _getState?; 52 | constructor(state?: IWaspModel, dispatch?: (action: any) => any, getState?: () => any); 53 | speed: number; 54 | lastId: number; 55 | wasps: { 56 | [id: number]: Wasp; 57 | }; 58 | addWasp(pos: { 59 | x: number; 60 | y: number; 61 | }): void; 62 | static addWasp(pos: { 63 | x: number; 64 | y: number; 65 | }): (dispatcher: any, getState: any) => void; 66 | incSpeed(value: number): void; 67 | static incSpeed(value: number): (dispatcher: any, getState: any) => void; 68 | setColor(value: { 69 | waspId: number; 70 | colorValue: string; 71 | }): void; 72 | static setColor(value: { 73 | waspId: number; 74 | colorValue: string; 75 | }): (dispatcher: any, getState: any) => void; 76 | step(): void; 77 | static step(): (dispatcher: any, getState: any) => void; 78 | } 79 | export declare const WaspModelEnums: { 80 | WaspModel_speed: string; 81 | WaspModel_lastId: string; 82 | WaspModel_wasps: string; 83 | WaspModel_addWasp: string; 84 | WaspModel_incSpeed: string; 85 | WaspModel_setColor: string; 86 | WaspModel_step: string; 87 | }; 88 | export declare const WaspModelReducer: (state: IWaspModel, action: any) => IWaspModel; 89 | /******************************** 90 | * React Context API component * 91 | ********************************/ 92 | export declare const WaspModelContext: React.Context; 93 | export declare const WaspModelConsumer: React.ComponentType>; 94 | export declare class WaspModelProvider extends React.Component { 95 | state: IWaspModel; 96 | lastSetState: IWaspModel; 97 | private __devTools; 98 | constructor(props: any); 99 | componentWillUnmount(): void; 100 | setStateSync(state: IWaspModel): void; 101 | addWasp(pos: { 102 | x: number; 103 | y: number; 104 | }): void; 105 | incSpeed(value: number): void; 106 | setColor(value: { 107 | waspId: number; 108 | colorValue: string; 109 | }): void; 110 | step(): void; 111 | render(): JSX.Element; 112 | } 113 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/genericModel.d.ts: -------------------------------------------------------------------------------- 1 | /************************************************************************************ 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state GenericModel * 4 | * Generated by ts2redux from Source file ../genericModel.ts * 5 | * * 6 | ************************************************************************************/ 7 | import { IState } from "./index"; 8 | import * as React from "react"; 9 | export interface Summable { 10 | value: () => number; 11 | } 12 | export declare class SomeList { 13 | items: T[]; 14 | forItems(fn: (item: T) => void): void; 15 | addItems(items: T[]): void; 16 | } 17 | /** 18 | * @redux true 19 | */ 20 | export declare class GenericModel { 21 | sum: number; 22 | isLoading: { 23 | [key: string]: boolean; 24 | }; 25 | list: SomeList; 26 | refreshSum(): void; 27 | addItems(items: T[]): void; 28 | inc(): void; 29 | testLoading(): Promise; 30 | } 31 | export interface IContainerPropsMethods { 32 | refreshSum: () => any; 33 | addItems: (items: T[]) => any; 34 | inc: () => any; 35 | testLoading: () => any; 36 | } 37 | export interface IGenericModel { 38 | sum: number; 39 | isLoading: { 40 | [key: string]: boolean; 41 | }; 42 | list: SomeList; 43 | } 44 | export declare type IContainerPropsState = IGenericModel; 45 | export interface IProps extends IContainerPropsState, IContainerPropsMethods { 46 | } 47 | export declare function mapStateToPropsWithKeys(state: IState, keys: K[]): Pick; 48 | export declare const mapStateToProps: (state: IState) => IGenericModel; 49 | export declare const mapDispatchToProps: (dispatch: any) => IContainerPropsMethods; 50 | export declare function ConnectKeys(keys: K[], methods: J[]): any; 51 | export declare const StateConnector: any; 52 | /** 53 | * @generated true 54 | */ 55 | export declare class RGenericModel { 56 | private _state?; 57 | private _dispatch?; 58 | private _getState?; 59 | constructor(state?: IGenericModel, dispatch?: (action: any) => any, getState?: () => any); 60 | sum: number; 61 | isLoading: { 62 | [key: string]: boolean; 63 | }; 64 | list: SomeList; 65 | refreshSum(): void; 66 | static refreshSum(): (dispatcher: any, getState: any) => void; 67 | addItems(items: T[]): void; 68 | static addItems(items: T[]): (dispatcher: any, getState: any) => void; 69 | inc(): void; 70 | static inc(): (dispatcher: any, getState: any) => void; 71 | testLoading(): Promise; 72 | static testLoading(): (dispatcher: any, getState: any) => Promise; 73 | } 74 | export declare const GenericModelEnums: { 75 | GenericModel_sum: string; 76 | GenericModel_isLoading: string; 77 | GenericModel_list: string; 78 | GenericModel_refreshSum: string; 79 | GenericModel_addItems: string; 80 | GenericModel_inc: string; 81 | }; 82 | export declare const GenericModelReducer: (state: IGenericModel, action: any) => IGenericModel; 83 | /******************************** 84 | * React Context API component * 85 | ********************************/ 86 | export declare const GenericModelContext: React.Context; 87 | export declare const GenericModelConsumer: React.ComponentType>; 88 | export declare class GenericModelProvider extends React.Component { 89 | state: IGenericModel; 90 | lastSetState: IGenericModel; 91 | private __devTools; 92 | constructor(props: any); 93 | componentWillUnmount(): void; 94 | setStateSync(state: IGenericModel): void; 95 | refreshSum(): void; 96 | addItems(items: T[]): void; 97 | inc(): void; 98 | testLoading(): Promise; 99 | render(): JSX.Element; 100 | } 101 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/index.d.ts: -------------------------------------------------------------------------------- 1 | /*********************************************** 2 | * * 3 | * Combined Reducers for main application * 4 | * Generated by ts2redux * 5 | * * 6 | ***********************************************/ 7 | import * as redux from "redux"; 8 | import { IGenericModel } from "./GenericModel"; 9 | import { IIncModel } from "./IncModel"; 10 | import { ISimpleModel } from "./SimpleModel"; 11 | import { ITestModel } from "./TestModel"; 12 | import { ITetrisModel } from "./TetrisModel"; 13 | import { ITodoList } from "./TodoList"; 14 | import { IUIHelperModel } from "./UIHelperModel"; 15 | import { IUserState } from "./UserState"; 16 | import { IWaspModel } from "./WaspModel"; 17 | export interface IState { 18 | GenericModel: IGenericModel; 19 | IncModel: IIncModel; 20 | SimpleModel: ISimpleModel; 21 | TestModel: ITestModel; 22 | TetrisModel: ITetrisModel; 23 | TodoList: ITodoList; 24 | UIHelperModel: IUIHelperModel; 25 | UserState: IUserState; 26 | WaspModel: IWaspModel; 27 | } 28 | export declare const reducerObject: { 29 | GenericModel: (state: IGenericModel, action: any) => IGenericModel; 30 | IncModel: (state: IIncModel, action: any) => IIncModel; 31 | SimpleModel: (state: ISimpleModel, action: any) => ISimpleModel; 32 | TestModel: (state: ITestModel, action: any) => ITestModel; 33 | TetrisModel: (state: ITetrisModel, action: any) => ITetrisModel; 34 | TodoList: (state: ITodoList, action: any) => ITodoList; 35 | UIHelperModel: (state: IUIHelperModel, action: any) => IUIHelperModel; 36 | UserState: (state: IUserState, action: any) => IUserState; 37 | WaspModel: (state: IWaspModel, action: any) => IWaspModel; 38 | }; 39 | export declare const reducers: redux.Reducer; 40 | -------------------------------------------------------------------------------- /dist/src/frontend/models/reducers/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | /*********************************************** 4 | * * 5 | * Combined Reducers for main application * 6 | * Generated by ts2redux * 7 | * * 8 | ***********************************************/ 9 | var redux = require("redux"); 10 | var GenericModel_1 = require("./GenericModel"); 11 | var IncModel_1 = require("./IncModel"); 12 | var SimpleModel_1 = require("./SimpleModel"); 13 | var TestModel_1 = require("./TestModel"); 14 | var TetrisModel_1 = require("./TetrisModel"); 15 | var TodoList_1 = require("./TodoList"); 16 | var UIHelperModel_1 = require("./UIHelperModel"); 17 | var UserState_1 = require("./UserState"); 18 | var WaspModel_1 = require("./WaspModel"); 19 | // use reducerObject if you combine reducers manually 20 | // for example when using connected-react-router 21 | exports.reducerObject = { 22 | GenericModel: GenericModel_1.GenericModelReducer, 23 | IncModel: IncModel_1.IncModelReducer, 24 | SimpleModel: SimpleModel_1.SimpleModelReducer, 25 | TestModel: TestModel_1.TestModelReducer, 26 | TetrisModel: TetrisModel_1.TetrisModelReducer, 27 | TodoList: TodoList_1.TodoListReducer, 28 | UIHelperModel: UIHelperModel_1.UIHelperModelReducer, 29 | UserState: UserState_1.UserStateReducer, 30 | WaspModel: WaspModel_1.WaspModelReducer 31 | }; 32 | exports.reducers = redux.combineReducers(exports.reducerObject); 33 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/frontend/models/testModels.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terotests/ts2redux/74da23a74cdc698f982a765b2675968be68b8812/dist/src/frontend/models/testModels.d.ts -------------------------------------------------------------------------------- /dist/src/frontend/models/testModels.js: -------------------------------------------------------------------------------- 1 | //# sourceMappingURL=testModels.js.map -------------------------------------------------------------------------------- /dist/src/frontend/ng.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | items: ShopCartItem[]; 10 | } 11 | export declare enum TaskState { 12 | UNDEFINED = 0, 13 | RUNNING = 1, 14 | ERROR = 2, 15 | SUCCESS = 3 16 | } 17 | export interface ITestModel { 18 | items: ShopCartItem[]; 19 | maxId: number; 20 | cartId: number; 21 | shopState: TaskState; 22 | carts: { 23 | [key: string]: ShopCart; 24 | }; 25 | } 26 | /** 27 | * @generated true 28 | */ 29 | export declare class RTestModel { 30 | private _state?; 31 | private _dispatch?; 32 | private _getState?; 33 | constructor(state?: ITestModel, dispatch?: (action: any) => void, getState?: () => ITestModel); 34 | items: ShopCartItem[]; 35 | maxId: number; 36 | cartId: number; 37 | shopState: TaskState; 38 | carts: { 39 | [key: string]: ShopCart; 40 | }; 41 | add(item: ShopCartItem): void; 42 | addCart(): Promise; 43 | static addCart(): (dispatcher: any, getState: any) => void; 44 | addToCart(adding: { 45 | cartId: string; 46 | item: ShopCartItem; 47 | }): Promise; 48 | static addToCart(adding: { 49 | cartId: string; 50 | item: ShopCartItem; 51 | }): (dispatcher: any, getState: any) => void; 52 | addToCartRandom(): Promise; 53 | static addToCartRandom(): (dispatcher: any, getState: any) => void; 54 | renameLast(newName: string): void; 55 | createItem(someName: string): Promise; 56 | static createItem(someName: string): (dispatcher: any, getState: any) => void; 57 | fillSomeFriends(): Promise; 58 | static fillSomeFriends(): (dispatcher: any, getState: any) => void; 59 | ChangeLastItem(): Promise; 60 | static ChangeLastItem(): (dispatcher: any, getState: any) => void; 61 | } 62 | export declare const TestModelEnums: { 63 | TestModel_items: string; 64 | TestModel_maxId: string; 65 | TestModel_cartId: string; 66 | TestModel_shopState: string; 67 | TestModel_carts: string; 68 | TestModel_add: string; 69 | TestModel_renameLast: string; 70 | }; 71 | export declare const TestModelReducer: (state: ITestModel, action: any) => ITestModel; 72 | export interface IUserState { 73 | logged: boolean; 74 | username: string; 75 | firstName: string; 76 | lastName: string; 77 | } 78 | export declare class RUserState { 79 | private _state?; 80 | private _dispatch?; 81 | private _getState?; 82 | constructor(state?: IUserState, dispatch?: (action: any) => void, getState?: () => IUserState); 83 | logged: boolean; 84 | username: string; 85 | firstName: string; 86 | lastName: string; 87 | login(loginInfo: { 88 | username: string; 89 | password: string; 90 | }): Promise; 91 | static login(loginInfo: { 92 | username: string; 93 | password: string; 94 | }): (dispatcher: any, getState: any) => void; 95 | } 96 | export declare const UserStateEnums: { 97 | UserState_logged: string; 98 | UserState_username: string; 99 | UserState_firstName: string; 100 | UserState_lastName: string; 101 | }; 102 | export declare const UserStateReducer: (state: IUserState, action: any) => IUserState; 103 | -------------------------------------------------------------------------------- /dist/src/frontend/reducers/TestModel.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | items: ShopCartItem[]; 10 | } 11 | export declare enum TaskState { 12 | UNDEFINED = 0, 13 | RUNNING = 1, 14 | ERROR = 2, 15 | SUCCESS = 3 16 | } 17 | export interface ContainerPropsMethods { 18 | addCart?: () => any; 19 | addToCart?: (adding: { 20 | cartId: string; 21 | item: ShopCartItem; 22 | }) => any; 23 | addToCartRandom?: () => any; 24 | createItem?: (someName: string) => any; 25 | addOneFriend?: (name: any) => any; 26 | fillSomeFriends?: () => any; 27 | ChangeLastItem?: () => any; 28 | } 29 | export interface ITestModel { 30 | items: ShopCartItem[]; 31 | maxId: number; 32 | cartId: number; 33 | shopState: TaskState; 34 | carts: { 35 | [key: string]: ShopCart; 36 | }; 37 | } 38 | export interface ContainerPropsState extends ITestModel { 39 | } 40 | export interface Props extends ITestModel, ContainerPropsMethods { 41 | } 42 | export declare const StateConnector: any; 43 | /** 44 | * @generated true 45 | */ 46 | export declare class RTestModel { 47 | private _state?; 48 | private _dispatch?; 49 | private _getState?; 50 | constructor(state?: ITestModel, dispatch?: (action: any) => void, getState?: () => ITestModel); 51 | items: ShopCartItem[]; 52 | maxId: number; 53 | cartId: number; 54 | shopState: TaskState; 55 | carts: { 56 | [key: string]: ShopCart; 57 | }; 58 | add(item: ShopCartItem): void; 59 | addCart(): Promise; 60 | static addCart(): (dispatcher: any, getState: any) => void; 61 | addToCart(adding: { 62 | cartId: string; 63 | item: ShopCartItem; 64 | }): Promise; 65 | static addToCart(adding: { 66 | cartId: string; 67 | item: ShopCartItem; 68 | }): (dispatcher: any, getState: any) => void; 69 | addToCartRandom(): Promise; 70 | static addToCartRandom(): (dispatcher: any, getState: any) => void; 71 | renameLast(newName: string): void; 72 | createItem(someName: string): Promise; 73 | static createItem(someName: string): (dispatcher: any, getState: any) => void; 74 | addOneFriend(name: any): Promise; 75 | static addOneFriend(name: any): (dispatcher: any, getState: any) => void; 76 | fillSomeFriends(): Promise; 77 | static fillSomeFriends(): (dispatcher: any, getState: any) => void; 78 | ChangeLastItem(): Promise; 79 | static ChangeLastItem(): (dispatcher: any, getState: any) => void; 80 | } 81 | export declare const TestModelEnums: { 82 | TestModel_items: string; 83 | TestModel_maxId: string; 84 | TestModel_cartId: string; 85 | TestModel_shopState: string; 86 | TestModel_carts: string; 87 | TestModel_add: string; 88 | TestModel_renameLast: string; 89 | }; 90 | export declare const TestModelReducer: (state: ITestModel, action: any) => ITestModel; 91 | -------------------------------------------------------------------------------- /dist/src/frontend/reducers/UserState.d.ts: -------------------------------------------------------------------------------- 1 | export interface ContainerPropsMethods { 2 | login?: (loginInfo: { 3 | username: string; 4 | password: string; 5 | }) => any; 6 | } 7 | export interface IUserState { 8 | logged: boolean; 9 | username: string; 10 | firstName: string; 11 | lastName: string; 12 | } 13 | export interface ContainerPropsState extends IUserState { 14 | } 15 | export interface Props extends IUserState, ContainerPropsMethods { 16 | } 17 | export declare const StateConnector: any; 18 | /** 19 | * @generated true 20 | */ 21 | export declare class RUserState { 22 | private _state?; 23 | private _dispatch?; 24 | private _getState?; 25 | constructor(state?: IUserState, dispatch?: (action: any) => void, getState?: () => IUserState); 26 | logged: boolean; 27 | username: string; 28 | firstName: string; 29 | lastName: string; 30 | login(loginInfo: { 31 | username: string; 32 | password: string; 33 | }): Promise; 34 | static login(loginInfo: { 35 | username: string; 36 | password: string; 37 | }): (dispatcher: any, getState: any) => void; 38 | } 39 | export declare const UserStateEnums: { 40 | UserState_logged: string; 41 | UserState_username: string; 42 | UserState_firstName: string; 43 | UserState_lastName: string; 44 | }; 45 | export declare const UserStateReducer: (state: IUserState, action: any) => IUserState; 46 | -------------------------------------------------------------------------------- /dist/src/frontend/reducers/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as redux from 'redux'; 2 | import { ITestModel } from './TestModel'; 3 | import { IUserState } from './UserState'; 4 | export interface State { 5 | TestModel: ITestModel; 6 | UserState: IUserState; 7 | } 8 | export declare const reducers: redux.Reducer; 9 | -------------------------------------------------------------------------------- /dist/src/frontend/reducers/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var redux = require("redux"); 4 | var TestModel_1 = require("./TestModel"); 5 | var UserState_1 = require("./UserState"); 6 | exports.reducers = redux.combineReducers({ 7 | TestModel: TestModel_1.TestModelReducer, 8 | UserState: UserState_1.UserStateReducer, 9 | }); 10 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/frontend/redux.d.ts: -------------------------------------------------------------------------------- 1 | import * as redux from 'redux'; 2 | import { ITestModel } from './ng'; 3 | export interface State { 4 | TestModelReducer: ITestModel; 5 | } 6 | export declare const reducers: redux.Reducer; 7 | -------------------------------------------------------------------------------- /dist/src/frontend/redux.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var redux = require("redux"); 4 | // TestModelReducer 5 | // import { userProfileReducer, UserProfileState } from './userProfile'; 6 | var ng_1 = require("./ng"); 7 | ; 8 | exports.reducers = redux.combineReducers({ 9 | TestModelReducer: ng_1.TestModelReducer 10 | }); 11 | // export const n = reducers; 12 | //# sourceMappingURL=redux.js.map -------------------------------------------------------------------------------- /dist/src/frontend/state.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | * 4 | * Nice links btw. 5 | * https://github.com/gcanti/fp-ts/issues/251 6 | * https://jaysoo.ca/2017/05/10/learn-fp-with-react-part-2/ 7 | */ 8 | export interface ShopCartItem { 9 | name: string; 10 | } 11 | export declare type TaskStateName = 'UNDEFINED' | 'RUNNING' | 'ERROR' | 'SUCCESS'; 12 | export interface TaskState { 13 | state?: TaskStateName; 14 | result?: T; 15 | error?: any; 16 | } 17 | /** 18 | * @redux model 19 | */ 20 | export interface ShopCartModel { 21 | items: ShopCartItem[]; 22 | fetchAll?: TaskState; 23 | RequstAddNewItem?: TaskState; 24 | AnyFn?: TaskState; 25 | } 26 | export declare function initializeShopCart(): ShopCartModel; 27 | export declare function updateItems(input: ShopCartModel, newItems: ShopCartItem[]): ShopCartModel; 28 | /** 29 | * @taskfor updateItems 30 | */ 31 | export declare function fetchAll(dispatch: () => void): Promise; 32 | /** 33 | * @taskfor updateItems 34 | */ 35 | export declare function getItemsFromCategory(id: number, dispatch: () => void): Promise; 36 | export declare function AddItem(input: ShopCartModel, newItem: ShopCartItem): ShopCartModel; 37 | /** 38 | * @taskfor AddItem 39 | */ 40 | export declare function RequstAddNewItem(itemName: string): Promise; 41 | /** 42 | * @taskfor AddItem 43 | */ 44 | export declare function AnyFn(itemName: string): Promise; 45 | /** 46 | * @redux model 47 | */ 48 | export interface UserInfoModel { 49 | logged: boolean; 50 | userId?: number; 51 | userName?: string; 52 | } 53 | export interface UserInfoModelMsg extends UserInfoModel { 54 | } 55 | export declare function initUserModel(): UserInfoModel; 56 | export declare function setUser(input: UserInfoModel, basicInfo: UserInfoModelMsg): UserInfoModel; 57 | /** 58 | * @taskfor setUser 59 | */ 60 | export declare function loginUser(username: string, password: string): Promise; 61 | /** 62 | * 63 | * @param username 64 | * @param password 65 | * @reduxfn true 66 | */ 67 | export declare function loginUser2(username: string, password: string): Promise<(state: UserInfoModelMsg) => UserInfoModelMsg>; 68 | -------------------------------------------------------------------------------- /dist/src/frontend/state2.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Interface State 3 | */ 4 | export interface ShopCartItem { 5 | id?: number; 6 | name: string; 7 | } 8 | export interface ShopCart { 9 | items: ShopCartItem[]; 10 | } 11 | export declare enum TaskState { 12 | UNDEFINED = 0, 13 | RUNNING = 1, 14 | ERROR = 2, 15 | SUCCESS = 3 16 | } 17 | -------------------------------------------------------------------------------- /dist/src/index.d.ts: -------------------------------------------------------------------------------- 1 | import { InterfaceDeclaration, SourceFile, ClassDeclaration } from "ts-morph"; 2 | import * as R from "robowr"; 3 | export interface GenerationOptions { 4 | path: string; 5 | reducerPath?: string; 6 | disableDevtoolsFromContext?: boolean; 7 | onlyFile?: string; 8 | router?: boolean; 9 | } 10 | export interface ModelDefinition { 11 | name: string; 12 | iface: ClassDeclaration; 13 | file: SourceFile; 14 | } 15 | export interface TargetFile { 16 | path: string; 17 | file: SourceFile; 18 | classes: { 19 | [key: string]: string; 20 | }; 21 | } 22 | export interface SyncInterface { 23 | name: string; 24 | file: SourceFile; 25 | iface: InterfaceDeclaration; 26 | } 27 | export interface GeneratedReducer { 28 | name: string; 29 | fileName: string; 30 | writer: R.CodeWriter; 31 | writerMainDir: string; 32 | writerReducerDir: string; 33 | } 34 | export declare function createProject(settings: GenerationOptions): Promise; 35 | -------------------------------------------------------------------------------- /dist/src/programmer/service.d.ts: -------------------------------------------------------------------------------- 1 | import * as R from 'robowr'; 2 | import { MethodDeclaration, ClassDeclaration, Project } from 'ts-simple-ast'; 3 | export declare const initSwagger: (wr: R.CodeWriter, service: any) => R.CodeWriter; 4 | export declare const WriteEndpoint: (wr: R.CodeWriter, project: Project, clName: ClassDeclaration, method: MethodDeclaration) => R.CodeWriter; 5 | export declare const WriteClientEndpoint: (wr: R.CodeWriter, project: Project, clName: ClassDeclaration, method: MethodDeclaration) => R.CodeWriter; 6 | -------------------------------------------------------------------------------- /dist/src/tssimplec.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/tssimplec.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var index_1 = require("./index"); 4 | index_1.createProject({ 5 | path: 'src', 6 | reducerPath: 'reducers' 7 | }); 8 | //# sourceMappingURL=tssimplec.js.map -------------------------------------------------------------------------------- /dist/src/utils/index.d.ts: -------------------------------------------------------------------------------- 1 | import { TypeChecker, Project, FunctionDeclaration, MethodDeclaration, ClassDeclaration, InterfaceDeclaration, PropertyDeclaration } from "ts-morph"; 2 | export declare type InterfaceOrClass = ClassDeclaration | InterfaceDeclaration; 3 | export declare const findModel: (project: Project, className: string) => InterfaceOrClass; 4 | export declare class JSDocParams { 5 | comment: string; 6 | tags: { 7 | [key: string]: string; 8 | }; 9 | params: { 10 | [key: string]: string; 11 | }; 12 | errors: { 13 | [key: string]: string; 14 | }; 15 | } 16 | export declare const getFunctionDoc: (method: FunctionDeclaration) => JSDocParams; 17 | export declare const getMethodDoc: (method: MethodDeclaration) => JSDocParams; 18 | export declare const getClassDoc: (method: InterfaceOrClass) => JSDocParams; 19 | export declare const getSwaggerType: (name: string, is_array?: boolean) => any; 20 | export declare const isSimpleType: (cType: any) => boolean; 21 | export declare const isBoolean: (cType: any) => boolean; 22 | export declare const getTypePath: (cType: any, current?: string[]) => string[]; 23 | export declare const getPropertyTypeName: (p: PropertyDeclaration) => string; 24 | export declare const getTypeName: (cType: any) => string; 25 | export declare const getMethodReturnTypeName: (checker: TypeChecker, m: MethodDeclaration) => string; 26 | -------------------------------------------------------------------------------- /dist/src/utils/oldcode.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Collection of some code snippets which may be useful at some day 3 | */ 4 | -------------------------------------------------------------------------------- /dist/src/utils/oldcode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Collection of some code snippets which may be useful at some day 3 | */ 4 | /* 5 | 6 | // NOTE: sync is not used ATM. 7 | syncInterfaces.forEach( decl => { 8 | console.log('SYNC', decl.name) 9 | if(decl.name == c.getName()) { 10 | console.log(`Syncing ${c.getName()} -> ${decl.iface.getName()}`) 11 | decl.iface.getProperties().forEach( p => { 12 | console.log( ' *)', p.getName()) 13 | }) 14 | c.getProperties().forEach( p => { 15 | const has = decl.iface.getProperties().filter( ip => ip.getName() == p.getName() ) 16 | if(has.length == 0 ) { 17 | const imports = decl.file.getImportDeclarations(); 18 | let hadImport = false 19 | imports.forEach( i => { 20 | // i 21 | console.log('NameSpace getModuleSpecifierValue', i.getModuleSpecifierValue()) 22 | const ns = i.getNamespaceImport() 23 | if(ns) { 24 | console.log('NameSpace import', ns.getText()) 25 | if(ns.getText() == 'TestModelModule') hadImport = true 26 | } 27 | const named = i.getNamedImports() 28 | named.forEach( n => { 29 | console.log(' - ', n.getText()) 30 | }) 31 | }) 32 | if(!hadImport) { 33 | const n:ImportDeclarationStructure = {moduleSpecifier:'jee'} 34 | decl.file.addImportDeclaration({ 35 | namespaceImport:'TestModelModule', 36 | moduleSpecifier: "../ng" 37 | }) 38 | } 39 | } 40 | }) 41 | 42 | } 43 | }) 44 | */ 45 | //# sourceMappingURL=oldcode.js.map -------------------------------------------------------------------------------- /dist/swagger/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "basePath": "/sometest/v1/", 4 | "paths": { 5 | "/ping/{message}": { 6 | "get": { 7 | "parameters": [ 8 | { 9 | "name": "message", 10 | "in": "path", 11 | "description": "", 12 | "required": true, 13 | "type": "string" 14 | } 15 | ], 16 | "description": "", 17 | "summary": "", 18 | "produces": [ 19 | "application/json" 20 | ], 21 | "responses": { 22 | "200": { 23 | "description": "", 24 | "schema": { 25 | "type": "string" 26 | } 27 | } 28 | }, 29 | "tags": [] 30 | } 31 | }, 32 | "/hello/{name}": { 33 | "get": { 34 | "parameters": [ 35 | { 36 | "name": "name", 37 | "in": "path", 38 | "description": "", 39 | "required": true, 40 | "type": "string" 41 | } 42 | ], 43 | "description": "", 44 | "summary": "", 45 | "produces": [ 46 | "application/json" 47 | ], 48 | "responses": { 49 | "200": { 50 | "description": "", 51 | "schema": { 52 | "type": "string" 53 | } 54 | } 55 | }, 56 | "tags": [] 57 | } 58 | }, 59 | "/getDevices": { 60 | "get": { 61 | "parameters": [], 62 | "description": "", 63 | "summary": "", 64 | "produces": [ 65 | "application/json" 66 | ], 67 | "responses": { 68 | "200": { 69 | "description": "", 70 | "schema": { 71 | "type": "array", 72 | "items": { 73 | "$ref": "#/definitions/Device" 74 | } 75 | } 76 | } 77 | }, 78 | "tags": [] 79 | } 80 | }, 81 | "/upload": { 82 | "post": { 83 | "parameters": [], 84 | "description": "", 85 | "summary": "", 86 | "produces": [ 87 | "application/json" 88 | ], 89 | "responses": { 90 | "200": { 91 | "description": "", 92 | "schema": { 93 | "type": "number" 94 | } 95 | } 96 | }, 97 | "tags": [] 98 | } 99 | } 100 | }, 101 | "definitions": { 102 | "Device": { 103 | "type": "object", 104 | "properties": { 105 | "id": { 106 | "type": "number" 107 | }, 108 | "name": { 109 | "type": "string" 110 | } 111 | } 112 | } 113 | }, 114 | "schemes": [ 115 | "http", 116 | "https" 117 | ], 118 | "info": { 119 | "version": "1.0.1 ", 120 | "title": "The title of the Doc", 121 | "description": "Freeform test of the API comes here", 122 | "termsOfService": "" 123 | }, 124 | "tags": [] 125 | } -------------------------------------------------------------------------------- /dist/swagger/server2.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "basePath": "/sometest/v1/", 4 | "paths": { 5 | "/hello/{id}": { 6 | "get": { 7 | "parameters": [ 8 | { 9 | "name": "id", 10 | "in": "path", 11 | "description": "", 12 | "required": true, 13 | "type": "string" 14 | } 15 | ], 16 | "description": "", 17 | "summary": "", 18 | "produces": [ 19 | "application/json" 20 | ], 21 | "responses": { 22 | "200": { 23 | "description": "", 24 | "schema": { 25 | "type": "string" 26 | } 27 | } 28 | }, 29 | "tags": [] 30 | } 31 | } 32 | }, 33 | "definitions": {}, 34 | "schemes": [ 35 | "http", 36 | "https" 37 | ], 38 | "info": { 39 | "version": "1.0.1 ", 40 | "title": "JeeJee", 41 | "description": "APIn kuvaus jne.", 42 | "termsOfService": "" 43 | }, 44 | "tags": [] 45 | } -------------------------------------------------------------------------------- /dist/test/test_base.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terotests/ts2redux/74da23a74cdc698f982a765b2675968be68b8812/dist/test/test_base.d.ts -------------------------------------------------------------------------------- /dist/test/test_base.js: -------------------------------------------------------------------------------- 1 | describe('no tests at the moment', function () { 2 | }); 3 | //# sourceMappingURL=test_base.js.map -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts2redux", 3 | "version": "1.0.37", 4 | "description": "Convert TypeScript classes into Reducers", 5 | "main": "dist/src/index.js", 6 | "bin": { 7 | "ts2redux": "dist/src/cli.js" 8 | }, 9 | "scripts": { 10 | "build:frontend": "browserify ./dist/src/frontend/main.js -o ./public/index.js", 11 | "rmandcompile": "find ./dist/ -name \"*.d.ts\" -delete && tsc", 12 | "compile": "tsc", 13 | "compilerversion": "tsc --version", 14 | "build:ts": "echo 'Building ts' && tsc && npm run build:frontend ", 15 | "watch:redux": "ts2redux src/frontend/models -w", 16 | "watch:ts": "nodemon -e js,ts,tsx --watch src --ignore src/frontend/models/ --exec npm run build:ts", 17 | "test": "npm run watch:ts & npm run watch:redux & node dist/src/tssimplec src/testinput.ts && npm run compile && npm run build:frontend && node dist/src/backend/index" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/terotests/ts2redux.git" 22 | }, 23 | "keywords": [], 24 | "author": "Tero Tolonen", 25 | "license": "MIT", 26 | "dependencies": { 27 | "chokidar": "^2.0.4", 28 | "prettier": "^1.15.1", 29 | "robowr": "^1.0.11", 30 | "typescript": "^3.5.3", 31 | "yargs": "^12.0.2", 32 | "ts-morph": "^3.1.3" 33 | }, 34 | "devDependencies": { 35 | "@types/chai": "^4.1.7", 36 | "@types/chokidar": "^1.7.5", 37 | "@types/express": "^4.16.0", 38 | "@types/mocha": "^5.2.5", 39 | "@types/node": "^10.12.3", 40 | "@types/react": "16.4.18", 41 | "axios": ">=0.18.1", 42 | "body-parser": "^1.18.3", 43 | "browserify": "^16.2.3", 44 | "chai": "^4.2.0", 45 | "express": "^4.16.4", 46 | "express-http-context": "^1.2.0", 47 | "immer": "^1.7.4", 48 | "json2yaml": "^1.1.0", 49 | "mocha": "^5.2.0", 50 | "nodemon": "^1.18.6", 51 | "react": "^16.6.3", 52 | "react-dom": "^16.6.1", 53 | "react-redux": "^5.1.0", 54 | "redux": "^4.0.1", 55 | "redux-thunk": "^2.3.0", 56 | "reselect": "^4.0.0" 57 | }, 58 | "bugs": { 59 | "url": "https://github.com/terotests/ts2redux/issues" 60 | }, 61 | "homepage": "https://github.com/terotests/ts2redux#readme", 62 | "directories": { 63 | "test": "test" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Test

8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/backend/index.ts: -------------------------------------------------------------------------------- 1 | import * as express from "express"; 2 | const app = express(); 3 | 4 | const bodyParser = require("body-parser"); 5 | app.use(bodyParser.json()); 6 | app.use(express.static("public")); 7 | 8 | if (!module.parent) { 9 | app.listen(1337); 10 | console.log("listening on port 1337"); 11 | } 12 | -------------------------------------------------------------------------------- /src/cli.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import {createProject} from './index' 4 | import * as chokidar from 'chokidar' 5 | 6 | const path = require('path') 7 | 8 | const argv = require('yargs') 9 | .demandCommand(1) 10 | .describe('reducers', 'Directory for reducers') 11 | .alias('r', 'reducers') 12 | .nargs('r', 1) 13 | .describe('nodevtools', 'Disable Redux Devtools integration from the React Context API components') 14 | .alias('n', 'nodevtools') 15 | .describe('watch', 'Watch directory for changes') 16 | .alias('w', 'watch') 17 | .argv 18 | 19 | const args = process.argv.slice(2); 20 | if( args.length === 0 ) { 21 | console.log('ts2redux ') 22 | process.exit() 23 | } 24 | const state = { 25 | is_running : false 26 | } 27 | const compileProject = async (eventArgs:string | null) => { 28 | if(state.is_running) return 29 | console.log('ts2redux: compiling path: ', args[0]) 30 | state.is_running = true 31 | await createProject({ 32 | path: args[0], 33 | reducerPath : argv.reducers || 'reducers', 34 | disableDevtoolsFromContext : argv.n, 35 | onlyFile: eventArgs ? path.basename( eventArgs ) : undefined 36 | }) 37 | setTimeout( 38 | () => { 39 | state.is_running = false 40 | },100) 41 | } 42 | const start = async() => { 43 | await compileProject(null) 44 | if( argv.watch ) { 45 | const watcher = chokidar.watch( args[0], { 46 | ignored:'*.tsx' 47 | }) 48 | watcher 49 | .on('add', compileProject) 50 | .on('change', compileProject) 51 | .on('unlink', compileProject); 52 | } 53 | } 54 | start() 55 | 56 | -------------------------------------------------------------------------------- /src/frontend/components/GenericComp.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as container from '../models/reducers/GenericModel' 3 | 4 | // abstract properties version of the component 5 | export interface Props extends container.IProps {} 6 | 7 | class Nro { 8 | val = 0 9 | constructor(n:number) { 10 | this.val = n 11 | } 12 | value() { 13 | return this.val 14 | } 15 | } 16 | 17 | class OtherNro { 18 | val = 0 19 | constructor(n:number) { 20 | this.val = n 21 | } 22 | value() { 23 | return this.val 24 | } 25 | } 26 | 27 | // this component can be re-used 28 | export const AbstractGeneric = (props : Props) => { 29 | return ( 30 |
31 | Redux Sum : {props.sum} 32 |
35 |
36 | ); 37 | } 38 | 39 | // This is the specialized version of the component 40 | export const GenericRedux = container.StateConnector( AbstractGeneric ) -------------------------------------------------------------------------------- /src/frontend/components/PureList.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { TodoListItem } from '../models/interfaces'; 3 | 4 | export interface IPureList { 5 | items: TodoListItem[] 6 | } 7 | 8 | export class PureList extends React.PureComponent { 9 | render() { 10 | return {this.props.items.map( m => { 11 | return 12 | 13 | 14 | 15 | ; 16 | })}
{m.id}{m.title}{m.completed ? 'Completed' : 'In Progress'}
17 | } 18 | } -------------------------------------------------------------------------------- /src/frontend/components/ReduxInc.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as container from "../models/reducers/IncModel"; 3 | 4 | // abstract properties version of the component 5 | export interface Props extends container.IProps {} 6 | 7 | // this component can be re-used 8 | export const AbstractInc = (props: Props) => { 9 | return ( 10 |
11 |
{props.cnt}
12 | 13 | 14 |
15 | ); 16 | }; 17 | 18 | // ConnectKeys can be used to map specific functions and properties 19 | // to the target object 20 | export const ReduxInc = container.ConnectKeys( 21 | ["cnt"], 22 | ["increment", "decrement"] 23 | )(AbstractInc); 24 | -------------------------------------------------------------------------------- /src/frontend/components/TetrisComponent.tsx: -------------------------------------------------------------------------------- 1 | 2 | import * as React from 'react'; 3 | import * as container from '../models/reducers/TetrisModel' 4 | import { PureList } from './PureList'; 5 | import { Colors } from '../models/TetrisModel' 6 | 7 | // abstract properties version of the component 8 | export interface Props extends container.IProps {} 9 | 10 | // this component can be re-used 11 | export class TetrisC extends React.PureComponent { 12 | interval: any 13 | keyFunction = (event:KeyboardEvent) => { 14 | if(this.props.gameOn) { 15 | if(event.keyCode == 37) { 16 | this.props.left() 17 | } 18 | if(event.keyCode == 38) { 19 | this.props.rotate() 20 | } 21 | if(event.keyCode == 39) { 22 | this.props.right() 23 | } 24 | if(event.keyCode == 40) { 25 | this.props.step() 26 | } 27 | } 28 | event.preventDefault() 29 | } 30 | componentDidMount() { 31 | this.interval = setInterval(()=>{ 32 | if(this.props.gameOn) this.props.tick() 33 | }, 100) 34 | document.addEventListener("keydown", this.keyFunction, false); 35 | } 36 | componentWillUnmount() { 37 | clearInterval( this.interval ) 38 | document.removeEventListener("keydown", this.keyFunction, false); 39 | } 40 | render() { 41 | return ( 42 |
45 | 46 | { !this.props.gameOn ? 47 |
48 | : ''} 49 |
Points:{this.props.points} {this.props.gameEnded ? 'Game Over' : ''}
50 | 51 |
52 | { 53 | this.props.cells.map( (row,y) =>
{ 56 | row.map( (cell,x) => { 57 | /* 58 | const active = this.props.activePiece 59 | let color = cell.color 60 | active.cells.forEach( (arow, ay)=>{ 61 | arow.forEach( (acell, ax) => { 62 | if( ((active.x + ax) == x) && ((active.y + ay) == y)) { 63 | if(acell.color !== Colors.EMPTY) color = acell.color 64 | } 65 | }) 66 | }) 67 | */ 68 | const color = cell.color 69 | return
73 | })}
) 74 | } 75 | {this.props.activePiece ? this.props.activePiece.cells.map( (arow, y) => { 76 | return arow.map( (cell, x) => { 77 | const active = this.props.activePiece 78 | const color = cell.color 79 | const ax = active.x + x 80 | const ay = active.y + y - ( 1 - this.props.tickCnt / this.props.ticksPerMove) 81 | return (
) 85 | }) 86 | }) : '' 87 | } ) 88 | })} 89 |
90 |
91 | ); 92 | } 93 | } 94 | 95 | // This is the specialized version of the component 96 | export const TetrisComponent = container.StateConnector( TetrisC ) -------------------------------------------------------------------------------- /src/frontend/components/WaspComponent.tsx: -------------------------------------------------------------------------------- 1 | 2 | import * as React from 'react'; 3 | import * as container from '../models/reducers/WaspModel' 4 | import { PureList } from './PureList'; 5 | 6 | // abstract properties version of the component 7 | export interface Props extends container.IProps {} 8 | 9 | // this component can be re-used 10 | export class WaspC extends React.PureComponent { 11 | interval: any 12 | componentDidMount() { 13 | this.interval = setInterval(()=>{ 14 | this.props.step() 15 | }, 20) 16 | } 17 | componentWillUnmount() { 18 | clearInterval( this.interval ) 19 | } 20 | render() { 21 | return ( 22 |
23 |
Wasps using Redux
24 | 27 |
28 | 29 | { 30 | Object.keys( this.props.wasps ).map( key => { 31 | const wasp = this.props.wasps[parseInt(key)] 32 | return 33 | }) 34 | } 35 | 36 |
37 |
38 | ); 39 | } 40 | } 41 | 42 | // This is the specialized version of the component 43 | export const WaspComponent = container.StateConnector( WaspC ) -------------------------------------------------------------------------------- /src/frontend/components/WaspContextComponent.tsx: -------------------------------------------------------------------------------- 1 | 2 | import * as React from 'react'; 3 | import { WaspModelConsumer} from '../models/reducers/WaspModel' 4 | import { PureList } from './PureList'; 5 | 6 | export interface IInterval { 7 | time: number 8 | fn: ()=>void 9 | } 10 | export class Interval extends React.PureComponent { 11 | interval: any 12 | componentDidMount() { 13 | this.interval = setInterval(()=>{ 14 | this.props.fn() 15 | }, this.props.time) 16 | } 17 | componentWillUnmount() { 18 | clearInterval( this.interval ) 19 | } 20 | render() { 21 | return 22 | } 23 | } 24 | 25 | // this component can be re-used 26 | export class WaspContextComponent extends React.PureComponent { 27 | render() { 28 | return ( 29 | { 30 | state =>
31 |
Wasps using React Context API
32 | 33 | 36 |
37 | 38 | { 39 | Object.keys( state.wasps ).map( key => { 40 | const wasp = state.wasps[parseInt(key)] 41 | return { 42 | state.setColor( {waspId: parseInt(key), colorValue:'green'} ) 43 | }} cx={wasp.x} cy={wasp.y} key={key} r={10} fill={wasp.color} /> 44 | }) 45 | } 46 | 47 |
48 |
49 | } 50 |
51 | ); 52 | } 53 | } -------------------------------------------------------------------------------- /src/frontend/components/combinedState.tsx: -------------------------------------------------------------------------------- 1 | 2 | import * as React from 'react'; 3 | import { connect } from 'react-redux' 4 | import * as todoContainer from '../models/reducers/TodoList' 5 | import * as userContainer from '../models/reducers/UserState' 6 | 7 | // abstract properties version of the component 8 | export interface Props extends todoContainer.IProps, userContainer.IProps {} 9 | 10 | // this component can be re-used 11 | export const AbstractCombinedStates = (props : Props) => { 12 | return ( 13 |
14 |
Combined States Component
15 |
16 |
User Name Now: {props.username}
17 |
Items length Now: {props.items.length}
18 | 19 | 20 | 21 |
22 |
23 | ); 24 | } 25 | 26 | export const StateConnector = connect( 27 | (state) => ({ 28 | ...todoContainer.mapStateToProps(state), 29 | ...userContainer.mapStateToProps(state), 30 | }), 31 | (dispatch) => ({ 32 | ...todoContainer.mapDispatchToProps(dispatch), 33 | ...userContainer.mapDispatchToProps(dispatch), 34 | }), 35 | ); 36 | 37 | // This is the specialized version of the component 38 | export const CombinedStates = StateConnector( AbstractCombinedStates ) 39 | -------------------------------------------------------------------------------- /src/frontend/components/memberArea.tsx: -------------------------------------------------------------------------------- 1 | 2 | import * as React from 'react'; 3 | import * as container from '../models/reducers/TestModel' 4 | 5 | // abstract properties version of the component 6 | export interface Props extends container.IProps {} 7 | 8 | // this component can be re-used 9 | export const AbstractMemberArea = (props : Props) => { 10 | return ( 11 |
12 |
Member Area Component
13 | props.addOneFriend('Teppo')} 17 | /> 18 | props.fillSomeFriends()} 22 | /> 23 | props.createItem('John Smith')} 27 | /> 28 | 29 | props.ChangeLastItem()} 33 | /> 34 | props.removeFirst()} 38 | /> 39 | props.sort()} 43 | /> 44 | props.addCartSync()} 48 | /> 49 | props.addCart()} 53 | /> 54 | props.addToCartRandom()} 58 | /> 59 | props.setUserMessage('Hello WOrld!!!!')} 63 | /> 64 |
65 |
{props.userMessage}
66 |
{props.shopState}
67 | {props.items.map( m => { 68 | return
{m.name}
; 69 | })} 70 |

Shopping Carts

71 | {Object.keys(props.carts).map( cartId => { 72 | const cart = props.carts[cartId] 73 | return
74 |

{cartId}

75 | 78 |
    79 | {cart.items.map( item =>
  • {item.name}
  • )} 80 |
81 |
82 | })} 83 | 84 |
85 |
86 | ); 87 | } 88 | 89 | // This is the specialized version of the component 90 | export const MemberArea = container.StateConnector( AbstractMemberArea ) -------------------------------------------------------------------------------- /src/frontend/components/todoList.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as container from "../models/reducers/TodoList"; 3 | import { PureList } from "./PureList"; 4 | 5 | // abstract properties version of the component 6 | export interface Props extends container.IProps {} 7 | 8 | // this component can be re-used 9 | export const AbstractTodoList = (props: Props) => { 10 | return ( 11 |
12 |

TodoList Component, with memoization

13 |
Title: {props.listTitle}
14 | 15 | 16 | 17 | 18 | 21 | 24 |
25 |
{props.state}
26 |
{props.state === "ERROR" ? new String(props.stateError) : ""}
27 | 28 |
29 |
30 | ); 31 | }; 32 | 33 | // This is the specialized version of the component 34 | export const TodoList = container.StateConnector(AbstractTodoList); 35 | -------------------------------------------------------------------------------- /src/frontend/index.ts: -------------------------------------------------------------------------------- 1 | 2 | console.log('frontend sample') -------------------------------------------------------------------------------- /src/frontend/models/IncModel.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | 5 | export class IncModel { 6 | cnt = 0; 7 | 8 | increment() { 9 | this.cnt++; 10 | } 11 | decrement() { 12 | this.cnt--; 13 | } 14 | 15 | get incValue() { 16 | return this.cnt; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/frontend/models/SimpleModel.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | /** 4 | * @redux true 5 | */ 6 | export class SimpleModel { 7 | items: any[] = []; 8 | 9 | /** 10 | * @dispatch true 11 | * @param action 12 | */ 13 | async SimpleDispatch(action: any) { 14 | // Example of dispatcher routine 15 | } 16 | 17 | async getItems() { 18 | this.items = (await axios.get( 19 | "https://jsonplaceholder.typicode.com/todos" 20 | )).data; 21 | } 22 | get myItems(): any[] { 23 | return this.items; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/frontend/models/TestModel.ts: -------------------------------------------------------------------------------- 1 | import { setTimeout } from "timers"; 2 | 3 | /** 4 | * User Interface State 5 | */ 6 | 7 | export interface ShopCartItem { 8 | id?: number; 9 | name: string; 10 | } 11 | 12 | export interface ShopCart { 13 | newItemName?: string; 14 | items: ShopCartItem[]; 15 | } 16 | 17 | export enum TaskState { 18 | UNDEFINED, 19 | RUNNING, 20 | ERROR, 21 | SUCCESS 22 | } 23 | 24 | export interface TestObj { 25 | name: string; 26 | } 27 | 28 | function getTestObj(): TestObj { 29 | return { name: "OK" }; 30 | } 31 | 32 | const MSG = "STATE IS NOW"; 33 | const MSG2 = "AFTER DISPATCH STATE IS"; 34 | const DELAY = 1000; 35 | const LAST_NAME = "I am the last item!!!!"; 36 | const STR_CART = "cart"; 37 | const STR_ITEM = "item"; 38 | const PROB_50 = 0.5; 39 | 40 | const FRIEND_LIST = ["Arthur", "John", "Martin", "Peter"]; 41 | /** 42 | * @redux true 43 | */ 44 | class TestModel { 45 | // model with initializer 46 | items: ShopCartItem[] = []; 47 | maxId = 1; 48 | 49 | maybeString?: string; 50 | 51 | // Default initializers work :) 52 | str_init_test = "OK?"; 53 | bool_init_test = false; 54 | bool4 = true; 55 | obj_init_test = getTestObj(); 56 | rand_init_test = Math.floor(Math.random() * 5); 57 | 58 | arr_init_test = [1, 2, 3]; 59 | arr_init_test2 = [1, 2, 3, "foo"]; 60 | obj_literal_test = { cnt: 200 }; 61 | 62 | cartId: number = 1; 63 | shopState: TaskState = TaskState.UNDEFINED; 64 | 65 | // my shopping carts 66 | carts: { [key: string]: ShopCart } = {}; 67 | 68 | // message to user 69 | userMessage: string = ""; 70 | testObj?: TestObj; 71 | 72 | setUserMessage(value: string) { 73 | this.userMessage = value; 74 | } 75 | 76 | // reducer 77 | add(item: ShopCartItem) { 78 | console.log(this.maxId); 79 | this.items.push({ 80 | ...item, 81 | id: this.maxId++ 82 | }); 83 | } 84 | 85 | removeFirst() { 86 | this.items.splice(0, 1); 87 | } 88 | 89 | sort() { 90 | this.items.sort((a, b) => { 91 | return a.name.localeCompare(b.name); 92 | }); 93 | } 94 | 95 | /** 96 | * Creates a new shopping cart 97 | */ 98 | 99 | addCart() { 100 | const key = "cart" + this.cartId++; 101 | this.carts[key] = { 102 | items: [{ id: this.maxId++, name: STR_ITEM }] 103 | }; 104 | } 105 | 106 | addCartSync() { 107 | const key = "cart" + this.cartId++; 108 | this.carts[key] = { 109 | items: [{ id: this.maxId++, name: STR_ITEM }] 110 | }; 111 | } 112 | 113 | addToCart(adding: { cartId: string; item: ShopCartItem }) { 114 | this.carts[adding.cartId].items.push({ 115 | ...adding.item, 116 | id: this.maxId++ 117 | }); 118 | } 119 | 120 | setCartNewItem(adding: { cartId: string; name: string }) { 121 | this.carts[adding.cartId].newItemName = name; 122 | } 123 | 124 | addToCartRandom() { 125 | Object.keys(this.carts).forEach(cartKey => { 126 | this.addToCart({ 127 | cartId: cartKey, 128 | item: { name: STR_ITEM + this.maxId++ } 129 | }); 130 | }); 131 | } 132 | 133 | renameLast(newName: string) { 134 | this.items[this.items.length - 1].name = newName; 135 | } 136 | // action 137 | async createItem(someName: string) { 138 | console.log(MSG, this.shopState); 139 | if (this.shopState == TaskState.RUNNING) { 140 | return; 141 | } 142 | this.shopState = TaskState.RUNNING; 143 | await new Promise(res => { 144 | setTimeout(res, DELAY); 145 | }); 146 | console.log(MSG2, this.shopState); 147 | this.add({ name: someName }); 148 | this.shopState = TaskState.SUCCESS; 149 | } 150 | 151 | async addOneFriend(name) { 152 | this.add({ name }); 153 | } 154 | 155 | async fillSomeFriends() { 156 | FRIEND_LIST.forEach(name => { 157 | this.add({ name }); 158 | }); 159 | } 160 | 161 | async ChangeLastItem() { 162 | this.renameLast(LAST_NAME); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /src/frontend/models/TetrisModel.ts: -------------------------------------------------------------------------------- 1 | export interface Cell { 2 | color: string; 3 | } 4 | 5 | export enum Colors { 6 | EMPTY = "" 7 | } 8 | 9 | export interface ActivePiece { 10 | x: number; 11 | y: number; 12 | width: number; 13 | height: number; 14 | cells: Cell[][]; 15 | } 16 | 17 | const pieceDeclaration = (color: string, rows: string[]): ActivePiece => { 18 | const cells = new Array(rows.length); 19 | for (let i = 0; i < rows.length; i++) { 20 | const row = rows[i]; 21 | cells[i] = new Array(row.length); 22 | for (let c = 0; c < row.length; c++) { 23 | if (row.charAt(c) == " ") { 24 | cells[i][c] = { color: Colors.EMPTY }; 25 | } else { 26 | cells[i][c] = { color: color }; 27 | } 28 | } 29 | } 30 | return { 31 | x: 0, 32 | y: rows.length * -1, 33 | width: rows.length, 34 | height: rows.length, 35 | cells 36 | }; 37 | }; 38 | 39 | /** 40 | * [' O '], 41 | * ['OOO'], 42 | * [' O '] 43 | */ 44 | 45 | export const createNewPiece = (usingColor: string): ActivePiece => { 46 | const items = [ 47 | pieceDeclaration(usingColor, ["xx", "xx"]), 48 | pieceDeclaration(usingColor, [" ", "xxx", " x "]), 49 | pieceDeclaration(usingColor, [" x ", " x ", "xx "]), 50 | pieceDeclaration(usingColor, [" x ", " x ", " xx"]), 51 | pieceDeclaration(usingColor, [" x ", " x ", " x ", " x "]) 52 | ]; 53 | return items[Math.floor(Math.random() * items.length)]; 54 | }; 55 | 56 | /** 57 | * @redux true 58 | */ 59 | export class TetrisModel { 60 | useColors = ["red", "blue", "green", "yellow", "brown", "orange"]; 61 | lastUsedColor = Math.floor(Math.random() * this.useColors.length); 62 | points = 0; 63 | rows = 20; 64 | cols = 15; 65 | cells: Cell[][] = []; 66 | activePiece?: ActivePiece; 67 | gameOn = false; 68 | gameEnded = false; 69 | ticksPerMove = 10; 70 | tickCnt = 0; 71 | dx = 0; 72 | dy = 1; 73 | 74 | private doesCollide( 75 | pieceX: number, 76 | pieceY: number, 77 | pieceCells?: Cell[][] 78 | ): boolean { 79 | let collides = false; 80 | const compareAgainst = pieceCells || this.activePiece.cells; 81 | compareAgainst.forEach((row, y) => { 82 | row.forEach((cell, x) => { 83 | if (cell.color === Colors.EMPTY) return; 84 | if (pieceY + y >= this.rows) { 85 | collides = true; 86 | return; 87 | } 88 | if (pieceX + x < 0 || pieceX + x >= this.cols) { 89 | collides = true; 90 | return; 91 | } 92 | if (cell.color !== Colors.EMPTY) { 93 | if (pieceY + y < 0) return; 94 | if (this.cells[pieceY + y][pieceX + x].color !== Colors.EMPTY) { 95 | collides = true; 96 | } 97 | } 98 | }); 99 | }); 100 | return collides; 101 | } 102 | 103 | tick() { 104 | this.tickCnt++; 105 | if (this.tickCnt >= this.ticksPerMove) { 106 | this.tickCnt = 0; 107 | this.step(); 108 | } 109 | } 110 | 111 | left() { 112 | if (!this.doesCollide(this.activePiece.x - 1, this.activePiece.y)) { 113 | this.activePiece.x--; 114 | } 115 | } 116 | 117 | right() { 118 | if (!this.doesCollide(this.activePiece.x + 1, this.activePiece.y)) { 119 | this.activePiece.x++; 120 | } 121 | } 122 | // keyboard control for rotation, tries to rotate activePiece and if 123 | // it does not collide, rotation can be done 124 | rotate() { 125 | const newOrientation = this.rotateCells(this.activePiece.cells); 126 | if ( 127 | !this.doesCollide(this.activePiece.x, this.activePiece.y, newOrientation) 128 | ) { 129 | this.activePiece.cells = newOrientation; 130 | } 131 | } 132 | // creates a new piece with rotated values 133 | private rotateCells(cells: Cell[][]): Cell[][] { 134 | const res: Cell[][] = new Array(cells.length); 135 | for (let j = 0; j < cells.length; j++) { 136 | res[j] = new Array(cells[j].length); 137 | } 138 | for (let j = 0; j < cells.length; j++) { 139 | const row = cells[j]; 140 | for (let i = 0; i < row.length; i++) { 141 | res[i][j] = { color: Colors.EMPTY }; 142 | } 143 | } 144 | for (let j = 0; j < cells.length; j++) { 145 | const row = cells[j]; 146 | for (let i = 0; i < row.length; i++) { 147 | res[i][cells.length - j - 1] = row[i]; 148 | } 149 | } 150 | return res; 151 | } 152 | 153 | step() { 154 | if (this.gameOn) { 155 | if (!this.doesCollide(this.activePiece.x, this.activePiece.y + 1)) { 156 | this.activePiece.y++; 157 | } else { 158 | if (this.activePiece.y < 0) { 159 | this.gameEnded = true; 160 | this.gameOn = false; 161 | } else { 162 | this.masonPiece(); 163 | this.dropRows(); 164 | this.activePiece = createNewPiece(this.pickNextColor()); 165 | this.activePiece.x = Math.floor(Math.random() * 5); 166 | } 167 | } 168 | } 169 | } 170 | 171 | private pickNextColor(): string { 172 | this.lastUsedColor++; 173 | if (this.lastUsedColor >= this.useColors.length) { 174 | this.lastUsedColor = 0; 175 | } 176 | return this.useColors[this.lastUsedColor]; 177 | } 178 | 179 | // adds the piece permanently to the structure 180 | masonPiece() { 181 | const piece = this.activePiece; 182 | piece.cells.forEach((row, y) => { 183 | if (piece.y + y < 0) return; 184 | row.forEach((cell, x) => { 185 | if (cell.color !== Colors.EMPTY) { 186 | this.cells[piece.y + y][piece.x + x].color = cell.color; 187 | } 188 | }); 189 | }); 190 | } 191 | 192 | // drops full rows and adds points to the user 193 | dropRows() { 194 | const nextRows = []; 195 | let emptyCnt = 0; 196 | for (let i = 0; i < this.cells.length; i++) { 197 | const row = this.cells[i]; 198 | if (row.filter(cell => cell.color === Colors.EMPTY).length > 0) { 199 | nextRows.push(row); 200 | } else { 201 | emptyCnt++; 202 | } 203 | } 204 | if (emptyCnt > 0) { 205 | this.points += emptyCnt * emptyCnt * 10; 206 | while (emptyCnt-- > 0) { 207 | const newEmpty = new Array(this.cols); 208 | for (let col = 0; col < this.cols; col++) { 209 | newEmpty[col] = { color: Colors.EMPTY }; 210 | } 211 | nextRows.unshift(newEmpty); 212 | } 213 | this.cells = nextRows; 214 | this.ticksPerMove--; 215 | } 216 | } 217 | 218 | clearCells() { 219 | this.cells = new Array(this.rows); 220 | for (let row = 0; row < this.rows; row++) { 221 | this.cells[row] = new Array(this.cols); 222 | for (let col = 0; col < this.cols; col++) { 223 | this.cells[row][col] = { color: Colors.EMPTY }; 224 | } 225 | } 226 | } 227 | 228 | resetGame() { 229 | this.clearCells(); 230 | this.activePiece = createNewPiece(this.pickNextColor()); 231 | this.ticksPerMove = 10; 232 | this.tickCnt = 0; 233 | } 234 | 235 | start() { 236 | this.resetGame(); 237 | this.gameOn = true; 238 | this.gameEnded = false; 239 | this.points = 0; 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /src/frontend/models/TodoList.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { TodoListItem } from "./interfaces"; 3 | 4 | export type TaskState = "UNDEFINED" | "RUNNING" | "LOADED" | "ERROR"; 5 | export enum SortOrder { 6 | ASC = "asc", 7 | DESC = "desc" 8 | } 9 | 10 | const sortFn = (order: SortOrder) => (a: TodoListItem, b: TodoListItem) => { 11 | if (order === SortOrder.ASC) return a.id - b.id; 12 | return b.id - a.id; 13 | }; 14 | 15 | /** 16 | * @redux true 17 | */ 18 | export class TodoList { 19 | items: TodoListItem[] = []; 20 | state: TaskState = "UNDEFINED"; 21 | stateError: any; 22 | sortOrder: SortOrder = SortOrder.ASC; 23 | listStart = 0; 24 | listPageLength = 10; 25 | listTitle = "Title of TODO -list"; 26 | customMessage = ""; 27 | 28 | // Example of memoized list using reselect 29 | get listToDisplay(): TodoListItem[] { 30 | return this.items 31 | .filter(item => item.completed) 32 | .sort(sortFn(this.sortOrder)) 33 | .slice(this.listStart, this.listStart + this.listPageLength); 34 | } 35 | 36 | private findMaxId(): number { 37 | let max = 0; 38 | this.items.forEach(item => { 39 | if (item.id > max) max = item.id; 40 | }); 41 | return max; 42 | } 43 | nextPage() { 44 | this.listStart += this.listPageLength; 45 | } 46 | prevPage() { 47 | this.listStart -= this.listPageLength; 48 | if (this.listStart < 0) this.listStart = 0; 49 | } 50 | toggleSortOrder() { 51 | this.sortOrder = 52 | this.sortOrder == SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC; 53 | } 54 | clearTodoList() { 55 | this.items = []; 56 | } 57 | reverse() { 58 | this.items.reverse(); 59 | } 60 | sortById() { 61 | this.items.sort((a, b) => a.id - b.id); 62 | } 63 | sortByTitle() { 64 | this.items.sort((a, b) => a.title.localeCompare(b.title)); 65 | } 66 | sortByCompletion() { 67 | const toNumber = (value: boolean): number => (value ? 1 : 0); 68 | this.items.sort((a, b) => toNumber(a.completed) - toNumber(b.completed)); 69 | } 70 | setTitle(value: string) { 71 | this.listTitle = value; 72 | } 73 | addLotOfItems(cnt: number) { 74 | const maxId = this.findMaxId(); 75 | for (let i = 0; i < cnt; i++) { 76 | this.items.push({ 77 | id: i + maxId, 78 | userId: 123 + i, 79 | completed: Math.random() > 0.5 ? true : false, 80 | title: "New Task " + i 81 | }); 82 | } 83 | } 84 | /** 85 | * Fetch items from json placeholder service 86 | */ 87 | async getItems() { 88 | if (this.state === "RUNNING") return; 89 | try { 90 | this.state = "RUNNING"; 91 | this.items = (await axios.get( 92 | "https://jsonplaceholder.typicode.com/todos" 93 | )).data; 94 | this.state = "LOADED"; 95 | } catch (e) { 96 | this.state = "ERROR"; 97 | this.stateError = e; 98 | } 99 | } 100 | 101 | async getShortList(makeError: boolean) { 102 | if (makeError) { 103 | this.customMessage = "Custom Exception send this custom message to state"; 104 | throw "Custom Exception"; 105 | } 106 | this.customMessage = ""; 107 | return new Promise(resolve => { 108 | setTimeout(() => { 109 | resolve([1, 2, 3, 4, 5]); 110 | }, 1000); 111 | }); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/frontend/models/UIHelper.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | class UIHelperModel { 5 | showWasps = false; 6 | toggle() { 7 | this.showWasps = !this.showWasps; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/frontend/models/UserState.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @redux true 3 | */ 4 | class UserState { 5 | logged = false; 6 | username: string = "anonymous"; 7 | firstName: string; 8 | lastName: string; 9 | lastLogin: number; 10 | async login(loginInfo: { username: string; password: string }) { 11 | console.log("Login called with ", loginInfo); 12 | } 13 | async logout() {} 14 | fakeLogin() { 15 | this.username = "Fake Login"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/frontend/models/WaspModel.ts: -------------------------------------------------------------------------------- 1 | export interface Wasp { 2 | id?: number; 3 | x: number; 4 | y: number; 5 | dx?: number; 6 | dy?: number; 7 | steps?: number; 8 | color?: string; 9 | } 10 | 11 | /** 12 | * @redux true 13 | */ 14 | class WaspModel { 15 | speed: number = 10; 16 | lastId: number = 1; 17 | wasps: { [id: number]: Wasp } = {}; 18 | 19 | addWasp(pos: { x: number; y: number }) { 20 | const o: Wasp = { x: 0, y: 0 }; 21 | o.id = this.lastId++; 22 | o.x = pos.x; 23 | o.y = pos.y; 24 | o.dx = 1 - 2 * Math.random(); 25 | o.dy = 1 - 2 * Math.random(); 26 | o.color = "red"; 27 | this.wasps[o.id] = o; 28 | } 29 | 30 | incSpeed(value: number) { 31 | this.speed = this.speed + value; 32 | } 33 | 34 | setColor(value: { waspId: number; colorValue: string }) { 35 | if (this.wasps[value.waspId]) 36 | this.wasps[value.waspId].color = value.colorValue; 37 | } 38 | 39 | step() { 40 | const list: Wasp[] = Object.keys(this.wasps).map(i => this.wasps[i]); 41 | if (list.length === 0) { 42 | return; 43 | } 44 | const center = list.reduce( 45 | (prev, curr) => { 46 | return { 47 | x: prev.x + curr.x, 48 | y: prev.y + curr.y 49 | }; 50 | }, 51 | { x: 0, y: 0 } 52 | ); 53 | center.x = center.x / list.length; 54 | center.y = center.y / list.length; 55 | for (let key of Object.keys(this.wasps)) { 56 | const wasp = this.wasps[key]; 57 | const x = center.x - wasp.x; 58 | const y = center.y - wasp.y; 59 | const len = Math.sqrt(x * x + y * y); 60 | if (len > 20) { 61 | wasp.dx += x / len; 62 | wasp.dy += y / len; 63 | } 64 | wasp.steps = 0; 65 | wasp.x += wasp.dx; 66 | wasp.y += wasp.dy; 67 | if (wasp.x < 0 || wasp.x > 300) wasp.dx = wasp.dx * -1; 68 | if (wasp.y < 0 || wasp.y > 300) wasp.dy = wasp.dy * -1; 69 | wasp.steps++; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/frontend/models/genericModel.ts: -------------------------------------------------------------------------------- 1 | export interface Summable { 2 | value: () => number; 3 | } 4 | 5 | export class SomeList { 6 | items: T[] = []; 7 | forItems(fn: (item: T) => void) { 8 | this.items.forEach(fn); 9 | } 10 | addItems(items: T[]) { 11 | console.log("Generic SomeList::addItems was called..."); 12 | console.log(this); 13 | this.items = [...this.items, ...items]; 14 | } 15 | } 16 | /** 17 | * @redux true 18 | */ 19 | export class GenericModel { 20 | sum = 0; 21 | isLoading: { [key: string]: boolean } = {}; 22 | // This is not a good idea with Immer... 23 | list: SomeList = new SomeList(); 24 | refreshSum() { 25 | this.sum = this.list.items.reduce((prev, curr) => prev + curr.value(), 0); 26 | } 27 | addItems(items: T[]) { 28 | console.log(this); 29 | this.list.addItems(items); 30 | this.refreshSum(); 31 | } 32 | inc() { 33 | this.sum++; 34 | } 35 | async testLoading() {} 36 | } 37 | -------------------------------------------------------------------------------- /src/frontend/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface TodoListItem { 2 | userId: number; 3 | id: number; 4 | title: string; 5 | completed: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /src/frontend/models/reducers/UIHelperModel.tsx: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | * * 3 | * Redux Reducers and React Context API Provider/Consumer for state UIHelperModel * 4 | * Generated by ts2redux from Source file ../UIHelper.ts * 5 | * * 6 | *************************************************************************************/ 7 | 8 | import * as immer from "immer"; 9 | import { connect } from "react-redux"; 10 | import { IState } from "./index"; 11 | import * as React from "react"; 12 | class UIHelperModel { 13 | showWasps = false; 14 | toggle() { 15 | this.showWasps = !this.showWasps; 16 | } 17 | } 18 | 19 | export interface IContainerPropsMethods { 20 | toggle: () => any; 21 | } 22 | export interface IUIHelperModel { 23 | showWasps: boolean; 24 | } 25 | 26 | export type IContainerPropsState = IUIHelperModel; 27 | export interface IProps extends IContainerPropsState, IContainerPropsMethods {} 28 | 29 | function pick(o: T, ...props: K[]) { 30 | return props.reduce((a, e) => ({ ...a, [e]: o[e] }), {}) as Pick; 31 | } 32 | export function mapStateToPropsWithKeys( 33 | state: IState, 34 | keys: K[] 35 | ): Pick { 36 | return pick(state.UIHelperModel as IContainerPropsState, ...keys); 37 | } 38 | 39 | export const mapStateToProps = (state: IState): IContainerPropsState => { 40 | return { 41 | showWasps: state.UIHelperModel.showWasps 42 | }; 43 | }; 44 | 45 | function mapDispatchToPropsWithKeys( 46 | dispatch: any, 47 | keys: K[] 48 | ): Pick { 49 | return pick(mapDispatchToProps(dispatch), ...keys); 50 | } 51 | 52 | export const mapDispatchToProps = (dispatch: any): IContainerPropsMethods => { 53 | return { 54 | toggle: () => { 55 | return dispatch(RUIHelperModel.toggle()); 56 | } 57 | }; 58 | }; 59 | 60 | export function ConnectKeys< 61 | K extends keyof IUIHelperModel, 62 | J extends keyof IContainerPropsMethods 63 | >(keys: K[], methods: J[]) { 64 | return connect( 65 | (state: IState) => mapStateToPropsWithKeys(state, keys), 66 | (dispatch: any) => mapDispatchToPropsWithKeys(dispatch, methods) 67 | ); 68 | } 69 | 70 | export const StateConnector = connect( 71 | mapStateToProps, 72 | mapDispatchToProps 73 | ); 74 | 75 | const initUIHelperModel = () => { 76 | const o = new UIHelperModel(); 77 | return { 78 | showWasps: o.showWasps 79 | }; 80 | }; 81 | const initWithMethodsUIHelperModel = () => { 82 | const o = new UIHelperModel(); 83 | return { 84 | showWasps: o.showWasps, 85 | toggle: o.toggle 86 | }; 87 | }; 88 | 89 | /** 90 | * @generated true 91 | */ 92 | export class RUIHelperModel { 93 | private _state?: IUIHelperModel; 94 | private _dispatch?: (action: A) => T; 95 | private _getState?: () => any; 96 | constructor( 97 | state?: IUIHelperModel, 98 | dispatch?: (action: any) => any, 99 | getState?: () => any 100 | ) { 101 | this._state = state; 102 | this._dispatch = dispatch; 103 | this._getState = getState; 104 | } 105 | get showWasps(): boolean { 106 | if (this._getState) { 107 | return this._getState().UIHelperModel.showWasps; 108 | } else { 109 | if (this._state) { 110 | return this._state.showWasps; 111 | } 112 | } 113 | throw "Invalid State in UIHelperModel_showWasps"; 114 | } 115 | set showWasps(value: boolean) { 116 | if (this._state && typeof value !== "undefined") { 117 | this._state.showWasps = value; 118 | } else { 119 | // dispatch change for item showWasps 120 | if (this._dispatch) { 121 | this._dispatch({ 122 | type: UIHelperModelEnums.UIHelperModel_showWasps, 123 | payload: value 124 | }); 125 | } 126 | } 127 | } 128 | 129 | toggle() { 130 | if (this._state) { 131 | this.showWasps = !this.showWasps; 132 | } else { 133 | if (this._dispatch) { 134 | this._dispatch({ type: UIHelperModelEnums.UIHelperModel_toggle }); 135 | } 136 | } 137 | } 138 | 139 | public static toggle() { 140 | return (dispatcher: any, getState: any) => { 141 | return new RUIHelperModel(undefined, dispatcher, getState).toggle(); 142 | }; 143 | } 144 | } 145 | 146 | export const UIHelperModelEnums = { 147 | UIHelperModel_showWasps: "UIHelperModel_showWasps", 148 | UIHelperModel_toggle: "UIHelperModel_toggle" 149 | }; 150 | 151 | export const UIHelperModelReducer = ( 152 | state: IUIHelperModel = initUIHelperModel(), 153 | action: any 154 | ) => { 155 | return immer.produce(state, (draft: IUIHelperModel) => { 156 | switch (action.type) { 157 | case UIHelperModelEnums.UIHelperModel_showWasps: 158 | new RUIHelperModel(draft).showWasps = action.payload; 159 | break; 160 | case UIHelperModelEnums.UIHelperModel_toggle: 161 | new RUIHelperModel(draft).toggle(); 162 | break; 163 | } 164 | }); 165 | }; 166 | /******************************** 167 | * React Context API component * 168 | ********************************/ 169 | export const UIHelperModelContext = React.createContext( 170 | initWithMethodsUIHelperModel() 171 | ); 172 | export const UIHelperModelConsumer = UIHelperModelContext.Consumer; 173 | let instanceCnt = 1; 174 | export class UIHelperModelProvider extends React.Component { 175 | public state: IUIHelperModel = initUIHelperModel(); 176 | public lastSetState: IUIHelperModel; 177 | private __devTools: any = null; 178 | constructor(props: any) { 179 | super(props); 180 | this.lastSetState = this.state; 181 | this.toggle = this.toggle.bind(this); 182 | const devs = window["__REDUX_DEVTOOLS_EXTENSION__"] 183 | ? window["__REDUX_DEVTOOLS_EXTENSION__"] 184 | : null; 185 | if (devs) { 186 | this.__devTools = devs.connect({ name: "UIHelperModel" + instanceCnt++ }); 187 | this.__devTools.init(this.state); 188 | this.__devTools.subscribe((msg: any) => { 189 | if (msg.type === "DISPATCH" && msg.state) { 190 | this.setState(JSON.parse(msg.state)); 191 | } 192 | }); 193 | } 194 | } 195 | public componentWillUnmount() { 196 | if (this.__devTools) { 197 | this.__devTools.unsubscribe(); 198 | } 199 | } 200 | public setStateSync(state: IUIHelperModel) { 201 | this.lastSetState = state; 202 | this.setState(state); 203 | } 204 | toggle() { 205 | const nextState = immer.produce(this.state, (draft: IUIHelperModel) => 206 | new RUIHelperModel(draft).toggle() 207 | ); 208 | if (this.__devTools) { 209 | this.__devTools.send("toggle", nextState); 210 | } 211 | this.setStateSync(nextState); 212 | } 213 | public render() { 214 | return ( 215 | 218 | {" "} 219 | {this.props.children} 220 | 221 | ); 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /src/frontend/models/reducers/index.ts: -------------------------------------------------------------------------------- 1 | /*********************************************** 2 | * * 3 | * Combined Reducers for main application * 4 | * Generated by ts2redux * 5 | * * 6 | ***********************************************/ 7 | import * as redux from "redux"; 8 | import { GenericModelReducer, IGenericModel } from "./GenericModel"; 9 | import { IIncModel, IncModelReducer } from "./IncModel"; 10 | import { ISimpleModel, SimpleModelReducer } from "./SimpleModel"; 11 | import { ITestModel, TestModelReducer } from "./TestModel"; 12 | import { ITetrisModel, TetrisModelReducer } from "./TetrisModel"; 13 | import { ITodoList, TodoListReducer } from "./TodoList"; 14 | import { IUIHelperModel, UIHelperModelReducer } from "./UIHelperModel"; 15 | import { IUserState, UserStateReducer } from "./UserState"; 16 | import { IWaspModel, WaspModelReducer } from "./WaspModel"; 17 | export interface IState { 18 | GenericModel: IGenericModel; 19 | IncModel: IIncModel; 20 | SimpleModel: ISimpleModel; 21 | TestModel: ITestModel; 22 | TetrisModel: ITetrisModel; 23 | TodoList: ITodoList; 24 | UIHelperModel: IUIHelperModel; 25 | UserState: IUserState; 26 | WaspModel: IWaspModel; 27 | } 28 | // use reducerObject if you combine reducers manually 29 | // for example when using connected-react-router 30 | export const reducerObject = { 31 | GenericModel: GenericModelReducer, 32 | IncModel: IncModelReducer, 33 | SimpleModel: SimpleModelReducer, 34 | TestModel: TestModelReducer, 35 | TetrisModel: TetrisModelReducer, 36 | TodoList: TodoListReducer, 37 | UIHelperModel: UIHelperModelReducer, 38 | UserState: UserStateReducer, 39 | WaspModel: WaspModelReducer 40 | }; 41 | export const reducers = redux.combineReducers(reducerObject); 42 | -------------------------------------------------------------------------------- /src/tssimplec.ts: -------------------------------------------------------------------------------- 1 | 2 | import {createProject} from './index' 3 | 4 | createProject({ 5 | path:'src', 6 | reducerPath: 'reducers' 7 | }) 8 | -------------------------------------------------------------------------------- /test/test_base.ts: -------------------------------------------------------------------------------- 1 | 2 | describe('no tests at the moment', () => { 3 | }); 4 | 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "moduleResolution": "node", 5 | "module": "commonjs", 6 | "rootDir": ".", 7 | "outDir": "dist", 8 | "allowSyntheticDefaultImports": true, 9 | "sourceMap": true, 10 | "inlineSources": true, 11 | "declaration": true, 12 | "emitDecoratorMetadata": true, 13 | "experimentalDecorators": true, 14 | "removeComments": false, 15 | "noImplicitAny": false, 16 | "jsx": "react", 17 | "lib": ["es6", "es2015", "dom"] 18 | }, 19 | "include": ["./**/*"], 20 | "exclude": ["dist/**/*", "node_modules", ".npm", "docs"] 21 | } 22 | --------------------------------------------------------------------------------