Commit 4ccddadf authored by 神楽坂玲奈's avatar 神楽坂玲奈

angular seed

parent 105cce99
...@@ -8,8 +8,8 @@ import {clipboard, remote} from "electron"; ...@@ -8,8 +8,8 @@ import {clipboard, remote} from "electron";
import * as path from "path"; import * as path from "path";
import {InstallService} from "./install.service"; import {InstallService} from "./install.service";
declare var Notification; declare const Notification: any;
declare var $; declare const $: any;
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
...@@ -150,7 +150,7 @@ export class AppDetailComponent implements OnInit { ...@@ -150,7 +150,7 @@ export class AppDetailComponent implements OnInit {
this.appsService.runApp(app, 'custom'); this.appsService.runApp(app, 'custom');
} }
copy(text) { copy(text: string) {
clipboard.writeText(text); clipboard.writeText(text);
} }
......
...@@ -8,7 +8,7 @@ export class AppLocal { ...@@ -8,7 +8,7 @@ export class AppLocal {
files: Map<string,string>; files: Map<string,string>;
action: Map<string,{execute: string, args: string[], env: {}, open: App}>; action: Map<string,{execute: string, args: string[], env: {}, open: App}>;
update(local) { update(local: any) {
this.path = local.path; this.path = local.path;
this.version = local.version; this.version = local.version;
let files = new Map<string,string>(); let files = new Map<string,string>();
...@@ -19,7 +19,7 @@ export class AppLocal { ...@@ -19,7 +19,7 @@ export class AppLocal {
} }
toJSON() { toJSON() {
let t = {}; let t: any = {};
for (let [k,v] of this.files) { for (let [k,v] of this.files) {
t[k] = v; t[k] = v;
} }
......
import {AppLocal} from "./app-local"; import {AppLocal} from "./app-local";
export enum Category { export enum Category {
game, // 游戏 game,
music, // 音乐 music,
book, // 图书 book,
runtime, // 运行库 runtime,
emulator, // 模拟器 emulator,
language, // 语言包 language,
expansion, // 资料片 expansion,
module, // 创意工坊 module
} }
// export enum Status{ // export enum Status{
...@@ -69,7 +69,7 @@ export class App { ...@@ -69,7 +69,7 @@ export class App {
return [Category.game].includes(this.category); return [Category.game].includes(this.category);
} }
constructor(app) { constructor(app: any) {
this.id = app.id; this.id = app.id;
this.name = app.name; this.name = app.name;
this.description = app.description; this.description = app.description;
......
...@@ -5,10 +5,12 @@ import {SettingsService} from "./settings.sevices"; ...@@ -5,10 +5,12 @@ import {SettingsService} from "./settings.sevices";
import * as fs from "fs"; import * as fs from "fs";
import * as path from "path"; import * as path from "path";
import * as child_process from "child_process"; import * as child_process from "child_process";
import {ChildProcess} from "child_process";
import {remote} from "electron"; import {remote} from "electron";
import "rxjs/Rx"; import "rxjs/Rx";
import {AppLocal} from "./app-local"; import {AppLocal} from "./app-local";
import * as ini from "ini"; import * as ini from "ini";
import Timer = NodeJS.Timer;
const Aria2 = require('aria2'); const Aria2 = require('aria2');
const sudo = require('electron-sudo'); const sudo = require('electron-sudo');
...@@ -229,9 +231,9 @@ export class AppsService { ...@@ -229,9 +231,9 @@ export class AppsService {
} }
connections = new Map<App, Connection>(); connections = new Map<App, Connection>();
maotama; maotama: Promise<ChildProcess>;
async network(app: App, server) { async network(app: App, server: any) {
if (!this.maotama) { if (!this.maotama) {
this.maotama = new Promise((resolve, reject) => { this.maotama = new Promise((resolve, reject) => {
let child = sudo.fork('maotama', [], {stdio: ['inherit', 'inherit', 'inherit', 'ipc']}); let child = sudo.fork('maotama', [], {stdio: ['inherit', 'inherit', 'inherit', 'ipc']});
...@@ -240,7 +242,7 @@ export class AppsService { ...@@ -240,7 +242,7 @@ export class AppsService {
child.once('exit', reject); child.once('exit', reject);
}) })
} }
let child; let child: ChildProcess;
try { try {
child = await this.maotama; child = await this.maotama;
} catch (error) { } catch (error) {
...@@ -253,7 +255,7 @@ export class AppsService { ...@@ -253,7 +255,7 @@ export class AppsService {
connection.connection.close(); connection.connection.close();
} }
connection = {connection: new WebSocket(server.url), address: null}; connection = {connection: new WebSocket(server.url), address: null};
let id; let id: Timer | null;
this.connections.set(app, connection); this.connections.set(app, connection);
connection.connection.onmessage = (event) => { connection.connection.onmessage = (event) => {
console.log(event.data); console.log(event.data);
...@@ -273,8 +275,10 @@ export class AppsService { ...@@ -273,8 +275,10 @@ export class AppsService {
}, 200); }, 200);
break; break;
case 'CONNECTED': case 'CONNECTED':
if (id) {
clearInterval(id); clearInterval(id);
id = null; id = null;
}
break; break;
} }
}; };
......
...@@ -6,6 +6,8 @@ import {Http} from "@angular/http"; ...@@ -6,6 +6,8 @@ import {Http} from "@angular/http";
import {Observable} from "rxjs/Observable"; import {Observable} from "rxjs/Observable";
import {EventEmitter} from "events"; import {EventEmitter} from "events";
import {App} from "./app"; import {App} from "./app";
import {Observer} from "rxjs";
import Timer = NodeJS.Timer;
const Aria2 = require('aria2'); const Aria2 = require('aria2');
...@@ -20,7 +22,7 @@ export class DownloadService { ...@@ -20,7 +22,7 @@ export class DownloadService {
open = this.aria2.open(); open = this.aria2.open();
constructor(private ngZone: NgZone, private http: Http) { constructor(private ngZone: NgZone, private http: Http) {
this.aria2.onDownloadComplete = (result) => { this.aria2.onDownloadComplete = (result: any) => {
let app = this.gidAppMap.get(result.gid); let app = this.gidAppMap.get(result.gid);
if (app) { if (app) {
this.appGidMap.delete(app); this.appGidMap.delete(app);
...@@ -41,7 +43,7 @@ export class DownloadService { ...@@ -41,7 +43,7 @@ export class DownloadService {
throw('nyaa'); throw('nyaa');
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.eventEmitter.once(app.id, (event) => { this.eventEmitter.once(app.id, (event: Event) => {
resolve(app); resolve(app);
}) })
}); });
...@@ -49,8 +51,8 @@ export class DownloadService { ...@@ -49,8 +51,8 @@ export class DownloadService {
getProgress(app: App): Observable<any> { getProgress(app: App): Observable<any> {
let gid = this.appGidMap.get(app); let gid = this.appGidMap.get(app);
return Observable.create((observer) => { return Observable.create((observer: Observer<any>) => {
let interval; let interval: Timer;
this.ngZone.runOutsideAngular(() => { this.ngZone.runOutsideAngular(() => {
interval = setInterval(() => { interval = setInterval(() => {
this.aria2.tellStatus(gid).then((status: any) => { this.aria2.tellStatus(gid).then((status: any) => {
...@@ -85,9 +87,9 @@ export class DownloadService { ...@@ -85,9 +87,9 @@ export class DownloadService {
async addMetalink(metalink: string, library: string) { async addMetalink(metalink: string, library: string) {
let meta4 = new Buffer((metalink)).toString('base64'); let meta4 = new Buffer((metalink)).toString('base64');
let gid = ( await this.aria2.addMetalink(meta4, {dir: library}))[0]; let gid = ( await this.aria2.addMetalink(meta4, {dir: library}))[0];
return Observable.create((observer) => { return Observable.create((observer: Observer<any>) => {
this.map.set(gid, observer); this.map.set(gid, observer);
let interval; let interval: Timer;
this.ngZone.runOutsideAngular(() => { this.ngZone.runOutsideAngular(() => {
interval = setInterval(async() => { interval = setInterval(async() => {
let status = await this.aria2.tellStatus(gid); let status = await this.aria2.tellStatus(gid);
......
...@@ -42,7 +42,7 @@ export class InstallService { ...@@ -42,7 +42,7 @@ export class InstallService {
getComplete(app: App): Promise<App> { getComplete(app: App): Promise<App> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.eventEmitter.once(app.id, (complete) => { this.eventEmitter.once(app.id, (complete: any) => {
resolve(); resolve();
}); });
}); });
...@@ -124,7 +124,7 @@ export class InstallService { ...@@ -124,7 +124,7 @@ export class InstallService {
if (["ygopro", 'desmume'].includes(app.id)) { if (["ygopro", 'desmume'].includes(app.id)) {
checksumUrl = this.checksumUri + app.id + "-" + process.platform; checksumUrl = this.checksumUri + app.id + "-" + process.platform;
} }
let checksumMap: Map<string,string> = await this.http.get(checksumUrl) return this.http.get(checksumUrl)
.map((response) => { .map((response) => {
let map = new Map<string,string>(); let map = new Map<string,string>();
for (let line of response.text().split('\n')) { for (let line of response.text().split('\n')) {
...@@ -135,7 +135,6 @@ export class InstallService { ...@@ -135,7 +135,6 @@ export class InstallService {
} }
return map; return map;
}).toPromise(); }).toPromise();
return checksumMap;
} }
async doInstall() { async doInstall() {
......
...@@ -86,9 +86,9 @@ export class LobbyComponent implements OnInit { ...@@ -86,9 +86,9 @@ export class LobbyComponent implements OnInit {
let a = await this.downloadService.addMetalink(metalink, dir); let a = await this.downloadService.addMetalink(metalink, dir);
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
a.subscribe((status) => { a.subscribe((status: any) => {
console.log(status); console.log(status);
}, (err) => { }, (err: any) => {
reject() reject()
}, () => { }, () => {
resolve(); resolve();
...@@ -121,7 +121,7 @@ export class LobbyComponent implements OnInit { ...@@ -121,7 +121,7 @@ export class LobbyComponent implements OnInit {
let contains = ["game", "music", "book"].map((value) => Category[value]); let contains = ["game", "music", "book"].map((value) => Category[value]);
let result = {runtime: []}; let result = {runtime: []};
for (let app of this.apps.values()) { for (let app of this.apps.values()) {
let tag; let tag: string;
if (contains.includes(app.category)) { if (contains.includes(app.category)) {
if (app.isInstalled()) { if (app.isInstalled()) {
tag = 'installed'; tag = 'installed';
......
...@@ -14,7 +14,7 @@ import * as url from "url"; ...@@ -14,7 +14,7 @@ import * as url from "url";
styleUrls: ['login.component.css'], styleUrls: ['login.component.css'],
}) })
export class LoginComponent { export class LoginComponent {
url; url: string;
return_sso_url = 'https://mycard.moe/login_callback'; // 这个url不会真的被使用,可以填写不存在的 return_sso_url = 'https://mycard.moe/login_callback'; // 这个url不会真的被使用,可以填写不存在的
constructor(private loginService: LoginService) { constructor(private loginService: LoginService) {
...@@ -36,7 +36,7 @@ export class LoginComponent { ...@@ -36,7 +36,7 @@ export class LoginComponent {
} }
} }
return_sso(return_url) { return_sso(return_url: string) {
if (!return_url.startsWith(this.return_sso_url)) { if (!return_url.startsWith(this.return_sso_url)) {
return; return;
} }
......
...@@ -28,7 +28,7 @@ export class LoginService { ...@@ -28,7 +28,7 @@ export class LoginService {
} }
} }
login(user) { login(user: User) {
this.user = user; this.user = user;
this.logged_in = true; this.logged_in = true;
localStorage.setItem('login', JSON.stringify(user)); localStorage.setItem('login', JSON.stringify(user));
......
body {
font-family: "Helvetica Neue", Helvetica, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
}
:host { :host {
height: 100%; height: 100%;
display: flex; display: flex;
......
...@@ -17,7 +17,7 @@ import "rxjs/Rx"; ...@@ -17,7 +17,7 @@ import "rxjs/Rx";
import {ISubscription} from "rxjs/Subscription"; import {ISubscription} from "rxjs/Subscription";
import {AppLocal} from "./app-local"; import {AppLocal} from "./app-local";
declare var $; declare const $: any;
interface SystemConf { interface SystemConf {
use_d3d: string use_d3d: string
...@@ -47,7 +47,7 @@ interface SystemConf { ...@@ -47,7 +47,7 @@ interface SystemConf {
interface Server { interface Server {
id?: string id?: string
url: string url?: string
address: string address: string
port: number port: number
} }
...@@ -56,6 +56,7 @@ interface Room { ...@@ -56,6 +56,7 @@ interface Room {
id?: string id?: string
title?: string title?: string
server?: Server server?: Server
private?: boolean
mode: number, mode: number,
rule: number, rule: number,
start_lp: number, start_lp: number,
...@@ -127,9 +128,9 @@ export class YGOProComponent implements OnInit { ...@@ -127,9 +128,9 @@ export class YGOProComponent implements OnInit {
let modal = $('#game-list-modal'); let modal = $('#game-list-modal');
modal.on('show.bs.modal', (event) => { modal.on('show.bs.modal', () => {
this.connections = this.servers.map((server) => { this.connections = this.servers.map((server) => {
let connection = new WebSocket(server.url); let connection = new WebSocket(<string>server.url);
connection.onclose = () => { connection.onclose = () => {
this.rooms = this.rooms.filter(room => room.server != server) this.rooms = this.rooms.filter(room => room.server != server)
}; };
...@@ -138,7 +139,7 @@ export class YGOProComponent implements OnInit { ...@@ -138,7 +139,7 @@ export class YGOProComponent implements OnInit {
//console.log(message) //console.log(message)
switch (message.event) { switch (message.event) {
case 'init': case 'init':
this.rooms = this.rooms.filter(room => room.server != server).concat(message.data.map(data => Object.assign({server: server}, this.default_options, data))); this.rooms = this.rooms.filter(room => room.server != server).concat(message.data.map((data: any) => Object.assign({server: server}, this.default_options, data)));
break; break;
case 'create': case 'create':
this.rooms.push(Object.assign({server: server}, this.default_options, message.data)); this.rooms.push(Object.assign({server: server}, this.default_options, message.data));
...@@ -155,7 +156,7 @@ export class YGOProComponent implements OnInit { ...@@ -155,7 +156,7 @@ export class YGOProComponent implements OnInit {
}); });
}); });
modal.on('hide.bs.modal', (event) => { modal.on('hide.bs.modal', () => {
for (let connection of this.connections) { for (let connection of this.connections) {
connection.close(); connection.close();
} }
...@@ -194,12 +195,12 @@ export class YGOProComponent implements OnInit { ...@@ -194,12 +195,12 @@ export class YGOProComponent implements OnInit {
} }
} }
async delete_deck(deck) { async delete_deck(deck: string) {
await new Promise(resolve => fs.unlink(path.join((<AppLocal>this.app.local).path, 'deck', deck + '.ydk'), resolve)); await new Promise(resolve => fs.unlink(path.join((<AppLocal>this.app.local).path, 'deck', deck + '.ydk'), resolve));
return this.refresh() return this.refresh()
} }
async fix_fonts(data) { async fix_fonts(data: SystemConf) {
if (!await this.get_font([data.numfont])) { if (!await this.get_font([data.numfont])) {
let font = await this.get_font(this.numfont); let font = await this.get_font(this.numfont);
if (font) { if (font) {
...@@ -233,12 +234,12 @@ export class YGOProComponent implements OnInit { ...@@ -233,12 +234,12 @@ export class YGOProComponent implements OnInit {
}) })
}; };
async join(name, server) { async join(name: string, server: Server) {
let system_conf = await this.load_system_conf(); let system_conf = await this.load_system_conf();
await this.fix_fonts(system_conf); await this.fix_fonts(system_conf);
system_conf.lastdeck = this.current_deck; system_conf.lastdeck = this.current_deck;
system_conf.lastip = server.address; system_conf.lastip = server.address;
system_conf.lastport = server.port; system_conf.lastport = server.port.toString();
system_conf.roompass = name; system_conf.roompass = name;
system_conf.nickname = this.loginService.user.username; system_conf.nickname = this.loginService.user.username;
await this.save_system_conf(system_conf); await this.save_system_conf(system_conf);
...@@ -253,11 +254,11 @@ export class YGOProComponent implements OnInit { ...@@ -253,11 +254,11 @@ export class YGOProComponent implements OnInit {
return this.start_game(['-d']); return this.start_game(['-d']);
} }
join_windbot(name) { join_windbot(name: string) {
return this.join('AI#' + name, this.servers[0]) return this.join('AI#' + name, this.servers[0])
} }
start_game(args) { start_game(args: string[]) {
let win = remote.getCurrentWindow(); let win = remote.getCurrentWindow();
win.minimize(); win.minimize();
console.log(path.join((<AppLocal>this.app.local).path, (<any>this.app.actions.get('main')).execute), args, {cwd: (<AppLocal>this.app.local).path}); console.log(path.join((<AppLocal>this.app.local).path, (<any>this.app.actions.get('main')).execute), args, {cwd: (<AppLocal>this.app.local).path});
...@@ -275,13 +276,13 @@ export class YGOProComponent implements OnInit { ...@@ -275,13 +276,13 @@ export class YGOProComponent implements OnInit {
}) })
}; };
create_room(options) { create_room(options: Room) {
let options_buffer = new Buffer(6); let options_buffer = new Buffer(6);
// 建主密码 https://docs.google.com/document/d/1rvrCGIONua2KeRaYNjKBLqyG9uybs9ZI-AmzZKNftOI/edit // 建主密码 https://docs.google.com/document/d/1rvrCGIONua2KeRaYNjKBLqyG9uybs9ZI-AmzZKNftOI/edit
options_buffer.writeUInt8((options.private ? 2 : 1) << 4, 1); options_buffer.writeUInt8((options.private ? 2 : 1) << 4, 1);
options_buffer.writeUInt8(parseInt(options.rule) << 5 | parseInt(options.mode) << 3 | (options.enable_priority ? 1 << 2 : 0) | (options.no_check_deck ? 1 << 1 : 0) | (options.no_shuffle_deck ? 1 : 0), 2); options_buffer.writeUInt8(options.rule << 5 | options.mode << 3 | (options.enable_priority ? 1 << 2 : 0) | (options.no_check_deck ? 1 << 1 : 0) | (options.no_shuffle_deck ? 1 : 0), 2);
options_buffer.writeUInt16LE(parseInt(options.start_lp), 3); options_buffer.writeUInt16LE(options.start_lp, 3);
options_buffer.writeUInt8(parseInt(options.start_hand) << 4 | parseInt(options.draw_count), 5); options_buffer.writeUInt8(options.start_hand << 4 | options.draw_count, 5);
let checksum = 0; let checksum = 0;
for (let i = 1; i < options_buffer.length; i++) { for (let i = 1; i < options_buffer.length; i++) {
checksum -= options_buffer.readUInt8(i) checksum -= options_buffer.readUInt8(i)
...@@ -293,30 +294,30 @@ export class YGOProComponent implements OnInit { ...@@ -293,30 +294,30 @@ export class YGOProComponent implements OnInit {
options_buffer.writeUInt16LE(options_buffer.readUInt16LE(i) ^ secret, i) options_buffer.writeUInt16LE(options_buffer.readUInt16LE(i) ^ secret, i)
} }
let password = options_buffer.toString('base64') + options.title.replace(/\s/, String.fromCharCode(0xFEFF)); let password = options_buffer.toString('base64') + (<string>options.title).replace(/\s/, String.fromCharCode(0xFEFF));
let room_id = crypto.createHash('md5').update(password + this.loginService.user.username).digest('base64').slice(0, 10).replace('+', '-').replace('/', '_'); let room_id = crypto.createHash('md5').update(password + this.loginService.user.username).digest('base64').slice(0, 10).replace('+', '-').replace('/', '_');
this.join(password, this.servers[0]); this.join(password, this.servers[0]);
} }
join_room(room) { join_room(room: Room) {
let options_buffer = new Buffer(6); let options_buffer = new Buffer(6);
options_buffer.writeUInt8(3 << 4, 1); options_buffer.writeUInt8(3 << 4, 1);
let checksum = 0; let checksum = 0;
for (var i = 1; i < options_buffer.length; i++) { for (let i = 1; i < options_buffer.length; i++) {
checksum -= options_buffer.readUInt8(i) checksum -= options_buffer.readUInt8(i)
} }
options_buffer.writeUInt8(checksum & 0xFF, 0); options_buffer.writeUInt8(checksum & 0xFF, 0);
let secret = this.loginService.user.external_id % 65535 + 1; let secret = this.loginService.user.external_id % 65535 + 1;
for (i = 0; i < options_buffer.length; i += 2) { for (let i = 0; i < options_buffer.length; i += 2) {
options_buffer.writeUInt16LE(options_buffer.readUInt16LE(i) ^ secret, i) options_buffer.writeUInt16LE(options_buffer.readUInt16LE(i) ^ secret, i)
} }
let password = options_buffer.toString('base64') + room.id; let password = options_buffer.toString('base64') + room.id;
this.join(password, room.server); this.join(password, <Server>room.server);
} }
matching: ISubscription | null; matching: ISubscription | null;
......
<!DOCTYPE html>
<html> <html>
<head> <head>
<title>MyCard</title> <title>MyCard</title>
...@@ -5,25 +6,27 @@ ...@@ -5,25 +6,27 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css">
<!-- 1. Load libraries --> <link rel="stylesheet" href="styles.css">
<!-- Polyfill(s) for older browsers --> <!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script> <script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script> <script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>delete module.exports</script> <script>delete module.exports</script>
<script src="node_modules/jquery/dist/jquery.min.js"></script> <script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script> <script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script> <script>
document.locale = require('electron').remote.app.getLocale();
System.import('app') System.import('app')
</script> </script>
</head> </head>
<!-- 3. Display the application -->
<body> <body>
<mycard>Loading...</mycard> <mycard>Loading...</mycard>
</body> </body>
......
...@@ -7,7 +7,7 @@ const path = require('path'); ...@@ -7,7 +7,7 @@ const path = require('path');
if (process.platform == 'darwin') { if (process.platform == 'darwin') {
try { try {
autoUpdater.setFeedURL("https://wudizhanche.mycard.moe/update"); autoUpdater.setFeedURL("https://wudizhanche.mycard.moe/update/darwin/" + app.getVersion());
} catch (err) { } catch (err) {
} }
} }
......
{ {
"name": "mycard", "name": "mycard",
"version": "3.0.0-dev.9",
"description": "mycard", "description": "mycard",
"keywords": [],
"author": "zh99998 <zh99998@gmail.com>", "author": "zh99998 <zh99998@gmail.com>",
"homepage": "https://mycard.moe", "homepage": "https://mycard.moe",
"version": "3.0.0-dev.9", "license": "UNLICENSED",
"repository": "github:mycard/mycard", "repository": "github:mycard/mycard",
"scripts": { "scripts": {
"start": "tsc && electron .",
"pack": "tsc && build --dir", "pack": "tsc && build --dir",
"dist": "tsc && build", "dist": "tsc && build",
"release": "tsc && build",
"start": "tsc && electron .",
"postinstall": "typings install",
"tsc": "tsc", "tsc": "tsc",
"tsc:w": "tsc -w",
"i18n": "ng-xi18n" "i18n": "ng-xi18n"
}, },
"license": "UNLICENSED",
"dependencies": { "dependencies": {
"@angular/common": "latest", "@angular/common": "latest",
"@angular/compiler": "latest", "@angular/compiler": "latest",
...@@ -25,17 +23,18 @@ ...@@ -25,17 +23,18 @@
"@angular/platform-browser": "latest", "@angular/platform-browser": "latest",
"@angular/platform-browser-dynamic": "latest", "@angular/platform-browser-dynamic": "latest",
"@angular/router": "latest", "@angular/router": "latest",
"@angular/router-deprecated": "latest", "angular-in-memory-web-api": "latest",
"@angular/upgrade": "latest",
"angular2-in-memory-web-api": "latest",
"rxjs": "5.0.0-beta.12",
"systemjs": "latest", "systemjs": "latest",
"zone.js": "^0.6.21", "core-js": "latest",
"reflect-metadata": "latest",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.26",
"electron-auto-updater": "latest", "electron-auto-updater": "latest",
"electron-cookies": "latest", "electron-cookies": "latest",
"electron-sudo": "mycard/electron-sudo#mycard", "electron-sudo": "mycard/electron-sudo#mycard",
"bootstrap": "next", "jquery": "latest",
"tether": "latest", "tether": "latest",
"bootstrap": "next",
"font-awesome": "latest", "font-awesome": "latest",
"aria2": "latest", "aria2": "latest",
"ini": "latest", "ini": "latest",
...@@ -49,7 +48,10 @@ ...@@ -49,7 +48,10 @@
"electron-builder": "latest", "electron-builder": "latest",
"electron-rebuild": "latest", "electron-rebuild": "latest",
"typescript": "latest", "typescript": "latest",
"typings": "latest" "@types/node": "latest",
"@types/electron": "latest",
"@types/ini": "latest",
"@types/mkdirp": "latest"
}, },
"build": { "build": {
"productName": "MyCard", "productName": "MyCard",
......
/* Master Styles */ html, body {
h1 { height: 100%;
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: 250%;
}
h2, h3 {
color: #444;
font-family: Arial, Helvetica, sans-serif;
font-weight: lighter;
} }
body { body {
margin: 2em; font-family: -apple-system, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
} }
/** /**
* System configuration for Angular 2 samples * System configuration for Angular samples
* Adjust as necessary for your application needs. * Adjust as necessary for your application needs.
*/ */
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things // map tells the System loader where to look for things
var map = { map: {
'app': 'app', // 'dist', // our app is within the app folder
app: 'app',
// systemjs plugins
'text': 'systemjs-text-plugin.js', 'text': 'systemjs-text-plugin.js',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', // angular bundles
'rxjs': 'node_modules/rxjs', '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'ng2-translate': 'node_modules/ng2-translate/bundles/index.js', '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
// node.js built-in libraries
"buffer": "@node/buffer",
"querystring": "@node/querystring",
"events": "@node/events",
"http": "@node/http",
"cluster": "@node/cluster",
"zlib": "@node/zlib",
"os": "@node/os",
"https": "@node/https",
"punycode": "@node/punycode",
"repl": "@node/repl",
"readline": "@node/readline",
"vm": "@node/vm",
"child_process": "@node/child_process",
"url": "@node/url",
"dns": "@node/dns",
"net": "@node/net",
"dgram": "@node/dgram",
"fs": "@node/fs",
"path": "@node/path",
"string_decoder": "@node/string_decoder",
"tls": "@node/tls",
"crypto": "@node/crypto",
"stream": "@node/stream",
"util": "@node/util",
"assert": "@node/assert",
"tty": "@node/tty",
"domain": "@node/domain",
"constants": "@node/constants",
"process": "@node/process",
"v8": "@node/v8",
"timers": "@node/timers",
"console": "@node/console",
// other node.js libraries
"electron": "@node/electron", "electron": "@node/electron",
"ini": "@node/ini", "ini": "@node/ini",
"mkdirp": "@node/mkdirp", "mkdirp": "@node/mkdirp",
"aria2": "@node/aria2", "aria2": "@node/aria2",
"electron-sudo": "@node/electron-sudo" "electron-sudo": "@node/electron-sudo"
}; },
// packages tells the System loader how to load when no filename and/or no extension // packages tells the System loader how to load when no filename and/or no extension
var packages = { packages: {
'app': {main: 'main.js', defaultExtension: 'js'}, app: {
'rxjs': {defaultExtension: 'js'}, main: './main.js',
'angular2-in-memory-web-api': {main: 'index.js', defaultExtension: 'js'} defaultExtension: 'js'
}; },
rxjs: {
let builtin_modules = ["buffer", "querystring", "events", "http", "cluster", "zlib", "os", "https", "punycode", "repl", "readline", "vm", "child_process", "url", "dns", "net", "dgram", "fs", "path", "string_decoder", "tls", "crypto", "stream", "util", "assert", "tty", "domain", "constants", "process", "v8", "timers", "console"]; defaultExtension: 'js'
for (let mod of builtin_modules) { }
map[mod] = `@node/${mod}`; }
} });
\ No newline at end of file
var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];
// Individual files (~300 requests):
function packIndex(pkgName) {
packages['@angular/' + pkgName] = {main: 'index.js', defaultExtension: 'js'};
}
// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/' + pkgName] = {main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js'};
}
// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);
var config = {
map: map,
packages: packages
};
System.config(config);
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6", "target": "es6",
"lib": [
"dom",
"es2017"
],
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"removeComments": false, "lib": [
"noImplicitAny": false, "es2017",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true, "strictNullChecks": true,
"skipLibCheck": true "skipLibCheck": true
} }
......
{
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"label-position": true,
"label-undefined": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-unreachable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": true,
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}
{
"globalDependencies": {
"electron/github-electron": "registry:dt/electron/github-electron",
"ini": "registry:dt/ini",
"jasmine": "registry:dt/jasmine",
"node": "registry:dt/node"
},
"dependencies": {
"mkdirp": "registry:npm/mkdirp"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment