gitignore dist
This commit is contained in:
		
							parent
							
								
									a1b8cfe38f
								
							
						
					
					
						commit
						c7b40c5dc8
					
				
					 18 changed files with 2 additions and 3498 deletions
				
			
		
							
								
								
									
										3
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1,6 +1,7 @@ | |||
| .vercel | ||||
| .env | ||||
| .vscode/ | ||||
| node_modules/ | ||||
| ./dist/ | ||||
| ./node_modules/ | ||||
| coverage | ||||
| yarn-error.log | ||||
|  |  | |||
							
								
								
									
										173
									
								
								dist/action.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										173
									
								
								dist/action.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,173 +0,0 @@ | |||
| "use strict"; | ||||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||||
|     if (k2 === undefined) k2 = k; | ||||
|     var desc = Object.getOwnPropertyDescriptor(m, k); | ||||
|     if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||||
|       desc = { enumerable: true, get: function() { return m[k]; } }; | ||||
|     } | ||||
|     Object.defineProperty(o, k2, desc); | ||||
| }) : (function(o, m, k, k2) { | ||||
|     if (k2 === undefined) k2 = k; | ||||
|     o[k2] = m[k]; | ||||
| })); | ||||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||||
|     Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||||
| }) : function(o, v) { | ||||
|     o["default"] = v; | ||||
| }); | ||||
| var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     if (mod && mod.__esModule) return mod; | ||||
|     var result = {}; | ||||
|     if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||||
|     __setModuleDefault(result, mod); | ||||
|     return result; | ||||
| }; | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var core = __importStar(require("@actions/core")); | ||||
| var fs = __importStar(require("fs")); | ||||
| var themes_json_1 = __importDefault(require("./themes/themes.json")); | ||||
| var fetcher_1 = require("./src/fetcher"); | ||||
| var ProfileCard_1 = __importDefault(require("./src/cards/ProfileCard")); | ||||
| var TopLanguagesCard_1 = __importDefault(require("./src/cards/TopLanguagesCard")); | ||||
| var HistoryCard_1 = __importDefault(require("./src/cards/HistoryCard")); | ||||
| var server_1 = __importDefault(require("react-dom/server")); | ||||
| var utils_1 = require("./src/common/utils"); | ||||
| function main() { | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var username, profile, toplang, history_1, profilecard, toplangcard, historycard, error_1; | ||||
|         return __generator(this, function (_a) { | ||||
|             switch (_a.label) { | ||||
|                 case 0: | ||||
|                     _a.trys.push([0, 4, , 5]); | ||||
|                     username = core.getInput("username"); | ||||
|                     // Fetch Code::Stats API
 | ||||
|                     console.log("Fetch account data: codestats.net/users/".concat(username)); | ||||
|                     return [4 /*yield*/, (0, fetcher_1.fetchProfile)(username)]; | ||||
|                 case 1: | ||||
|                     profile = _a.sent(); | ||||
|                     return [4 /*yield*/, (0, fetcher_1.fetchTopLanguages)(username)]; | ||||
|                 case 2: | ||||
|                     toplang = _a.sent(); | ||||
|                     return [4 /*yield*/, (0, fetcher_1.fetchHistory)(username, (0, utils_1.parseNumber)(core.getInput("history_card_days_count")))]; | ||||
|                 case 3: | ||||
|                     history_1 = _a.sent(); | ||||
|                     profilecard = server_1.default.renderToStaticMarkup(new ProfileCard_1.default(profile.username, profile.xp, profile.recentXp, { | ||||
|                         hide: (0, utils_1.parseArray)(core.getInput("profile_card_hide_lines")), | ||||
|                         show_icons: core.getBooleanInput("profile_card_show_icons"), | ||||
|                         hide_rank: core.getBooleanInput("profile_card_hide_rank"), | ||||
|                         line_height: (0, utils_1.parseNumber)(core.getInput("profile_card_line_height")), | ||||
|                         title: core.getInput("profile_card_title") | ||||
|                             ? core.getInput("profile_card_title") | ||||
|                             : "Code::Stats of ".concat(username), | ||||
|                         title_color: core.getInput("common_title_color"), | ||||
|                         icon_color: core.getInput("common_icon_color"), | ||||
|                         text_color: core.getInput("common_text_color"), | ||||
|                         bg_color: core.getInput("common_bg_color"), | ||||
|                         hide_title: core.getBooleanInput("common_hide_title"), | ||||
|                         hide_border: core.getBooleanInput("common_hide_border"), | ||||
|                         theme: core.getInput("theme") in themes_json_1.default | ||||
|                             ? core.getInput("theme") | ||||
|                             : "default", | ||||
|                     }).render()); | ||||
|                     console.log("Generated ./codestats_profilecard_".concat(username, ".svg")); | ||||
|                     fs.writeFileSync("./codestats_profilecard_".concat(username, ".svg"), profilecard); | ||||
|                     toplangcard = server_1.default.renderToStaticMarkup(new TopLanguagesCard_1.default(username, toplang.langs, { | ||||
|                         hide: (0, utils_1.parseArray)(core.getInput("common_hide_languages")), | ||||
|                         language_count: (0, utils_1.parseNumber)(core.getInput("toplangs_card_language_count")), | ||||
|                         card_width: 500, | ||||
|                         layout: core.getBooleanInput("toplangs_card_compact_layout") | ||||
|                             ? "compact" | ||||
|                             : undefined, | ||||
|                         title: core.getInput("toplangs_card_title") | ||||
|                             ? core.getInput("toplangs_card_title") | ||||
|                             : "Code::Stats of ".concat(username), | ||||
|                         title_color: core.getInput("common_title_color"), | ||||
|                         text_color: core.getInput("common_text_color"), | ||||
|                         bg_color: core.getInput("common_bg_color"), | ||||
|                         hide_title: core.getBooleanInput("common_hide_title"), | ||||
|                         hide_border: core.getBooleanInput("common_hide_border"), | ||||
|                         theme: core.getInput("theme") in themes_json_1.default | ||||
|                             ? core.getInput("theme") | ||||
|                             : "default", | ||||
|                     }).render()); | ||||
|                     console.log("Generated ./codestats_toplangs_".concat(username, ".svg")); | ||||
|                     fs.writeFileSync("./codestats_toplangs_".concat(username, ".svg"), toplangcard); | ||||
|                     historycard = server_1.default.renderToStaticMarkup(new HistoryCard_1.default(username, history_1, { | ||||
|                         hide: (0, utils_1.parseArray)(core.getInput("common_hide_languages")), | ||||
|                         language_count: (0, utils_1.parseNumber)(core.getInput("history_card_language_count")), | ||||
|                         hide_legend: core.getBooleanInput("history_card_hide_legend"), | ||||
|                         reverse_order: core.getBooleanInput("history_card_reverse_order"), | ||||
|                         width: 500, | ||||
|                         height: 300, | ||||
|                         title_color: core.getInput("common_title_color"), | ||||
|                         text_color: core.getInput("common_text_color"), | ||||
|                         bg_color: core.getInput("common_bg_color"), | ||||
|                         layout: core.getBooleanInput("history_card_horizontal_layout") | ||||
|                             ? "horizontal" | ||||
|                             : undefined, | ||||
|                         hide_title: core.getBooleanInput("common_hide_title"), | ||||
|                         title: core.getInput("history_card_title") | ||||
|                             ? core.getInput("history_card_title") | ||||
|                             : "Last ".concat((0, utils_1.parseNumber)(core.getInput("history_card_language_count")), " days XP history"), | ||||
|                         hide_border: core.getBooleanInput("common_hide_border"), | ||||
|                         theme: core.getInput("theme") in themes_json_1.default | ||||
|                             ? core.getInput("theme") | ||||
|                             : "default", | ||||
|                     }).render()); | ||||
|                     console.log("Generated ./codestats_history_".concat(username, ".svg")); | ||||
|                     fs.writeFileSync("./codestats_history_".concat(username, ".svg"), historycard); | ||||
|                     return [3 /*break*/, 5]; | ||||
|                 case 4: | ||||
|                     error_1 = _a.sent(); | ||||
|                     if (error_1 instanceof Error) { | ||||
|                         core.setFailed(error_1.message); | ||||
|                     } | ||||
|                     else { | ||||
|                         console.log(error_1); | ||||
|                     } | ||||
|                     return [3 /*break*/, 5]; | ||||
|                 case 5: return [2 /*return*/]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| main(); | ||||
							
								
								
									
										83
									
								
								dist/api/history.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										83
									
								
								dist/api/history.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,83 +0,0 @@ | |||
| "use strict"; | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var server_1 = __importDefault(require("react-dom/server")); | ||||
| var utils_1 = require("../src/common/utils"); | ||||
| var fetcher_1 = require("../src/fetcher"); | ||||
| var Error_1 = __importDefault(require("../src/components/Error")); | ||||
| var HistoryCard_1 = __importDefault(require("../src/cards/HistoryCard")); | ||||
| exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () { | ||||
|     var _a, username, days_count, cache_seconds, width, height, language_count, hide, layout, reverse_order, hide_legend,  | ||||
|     // Master
 | ||||
|     bg_color, hide_border, hide_title, theme, title_color, data, err_1; | ||||
|     return __generator(this, function (_b) { | ||||
|         switch (_b.label) { | ||||
|             case 0: | ||||
|                 _a = req.query, username = _a.username, days_count = _a.days_count, cache_seconds = _a.cache_seconds, width = _a.width, height = _a.height, language_count = _a.language_count, hide = _a.hide, layout = _a.layout, reverse_order = _a.reverse_order, hide_legend = _a.hide_legend, bg_color = _a.bg_color, hide_border = _a.hide_border, hide_title = _a.hide_title, theme = _a.theme, title_color = _a.title_color; | ||||
|                 (0, utils_1.prepareResponse)(res); | ||||
|                 _b.label = 1; | ||||
|             case 1: | ||||
|                 _b.trys.push([1, 3, , 4]); | ||||
|                 return [4 /*yield*/, (0, fetcher_1.fetchHistory)(username, (0, utils_1.clampValue)((0, utils_1.parseNumber)(days_count) || 14, 1, 30))]; | ||||
|             case 2: | ||||
|                 data = _b.sent(); | ||||
|                 (0, utils_1.setCache)(res, parseInt(cache_seconds || '', 10)); | ||||
|                 return [2 /*return*/, res.send(server_1.default.renderToStaticMarkup(new HistoryCard_1.default(username, data, { | ||||
|                         hide_title: (0, utils_1.parseBoolean)(hide_title), | ||||
|                         hide_border: (0, utils_1.parseBoolean)(hide_border), | ||||
|                         title_color: title_color, | ||||
|                         hide_legend: (0, utils_1.parseBoolean)(hide_legend), | ||||
|                         bg_color: bg_color, | ||||
|                         layout: layout, | ||||
|                         theme: theme, | ||||
|                         reverse_order: (0, utils_1.parseBoolean)(reverse_order), | ||||
|                         language_count: (0, utils_1.parseNumber)(language_count), | ||||
|                         width: (0, utils_1.parseNumber)(width), | ||||
|                         height: (0, utils_1.clampValue)((0, utils_1.parseNumber)(height) || 300, 200), | ||||
|                         hide: (0, utils_1.parseArray)(hide) | ||||
|                     }).render()))]; | ||||
|             case 3: | ||||
|                 err_1 = _b.sent(); | ||||
|                 return [2 /*return*/, res.send(server_1.default.renderToStaticMarkup(new Error_1.default(err_1).render()))]; | ||||
|             case 4: return [2 /*return*/]; | ||||
|         } | ||||
|     }); | ||||
| }); }); | ||||
							
								
								
									
										83
									
								
								dist/api/profile.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										83
									
								
								dist/api/profile.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,83 +0,0 @@ | |||
| "use strict"; | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var server_1 = __importDefault(require("react-dom/server")); | ||||
| var utils_1 = require("../src/common/utils"); | ||||
| var fetcher_1 = require("../src/fetcher"); | ||||
| var ProfileCard_1 = __importDefault(require("../src/cards/ProfileCard")); | ||||
| var Error_1 = __importDefault(require("../src/components/Error")); | ||||
| exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () { | ||||
|     var _a, username, hide, hide_rank, show_icons, line_height, icon_color, text_color, cache_seconds, title,  | ||||
|     // Master
 | ||||
|     bg_color, hide_border, hide_title, theme, title_color, data, err_1; | ||||
|     return __generator(this, function (_b) { | ||||
|         switch (_b.label) { | ||||
|             case 0: | ||||
|                 _a = req.query, username = _a.username, hide = _a.hide, hide_rank = _a.hide_rank, show_icons = _a.show_icons, line_height = _a.line_height, icon_color = _a.icon_color, text_color = _a.text_color, cache_seconds = _a.cache_seconds, title = _a.title, bg_color = _a.bg_color, hide_border = _a.hide_border, hide_title = _a.hide_title, theme = _a.theme, title_color = _a.title_color; | ||||
|                 (0, utils_1.prepareResponse)(res); | ||||
|                 _b.label = 1; | ||||
|             case 1: | ||||
|                 _b.trys.push([1, 3, , 4]); | ||||
|                 return [4 /*yield*/, (0, fetcher_1.fetchProfile)(username)]; | ||||
|             case 2: | ||||
|                 data = _b.sent(); | ||||
|                 (0, utils_1.setCache)(res, parseInt(cache_seconds || '', 10)); | ||||
|                 return [2 /*return*/, res.send(server_1.default.renderToStaticMarkup(new ProfileCard_1.default(data.username, data.xp, data.recentXp, { | ||||
|                         hide: (0, utils_1.parseArray)(hide), | ||||
|                         show_icons: (0, utils_1.parseBoolean)(show_icons), | ||||
|                         hide_title: (0, utils_1.parseBoolean)(hide_title), | ||||
|                         hide_border: (0, utils_1.parseBoolean)(hide_border), | ||||
|                         hide_rank: (0, utils_1.parseBoolean)(hide_rank), | ||||
|                         line_height: (0, utils_1.parseNumber)(line_height), | ||||
|                         title: title, | ||||
|                         title_color: title_color, | ||||
|                         icon_color: icon_color, | ||||
|                         text_color: text_color, | ||||
|                         bg_color: bg_color, | ||||
|                         theme: theme, | ||||
|                     }).render()))]; | ||||
|             case 3: | ||||
|                 err_1 = _b.sent(); | ||||
|                 return [2 /*return*/, res.send(server_1.default.renderToStaticMarkup(new Error_1.default(err_1).render()))]; | ||||
|             case 4: return [2 /*return*/]; | ||||
|         } | ||||
|     }); | ||||
| }); }); | ||||
							
								
								
									
										80
									
								
								dist/api/top-langs.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										80
									
								
								dist/api/top-langs.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,80 +0,0 @@ | |||
| "use strict"; | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var server_1 = __importDefault(require("react-dom/server")); | ||||
| var utils_1 = require("../src/common/utils"); | ||||
| var fetcher_1 = require("../src/fetcher"); | ||||
| var TopLanguagesCard_1 = __importDefault(require("../src/cards/TopLanguagesCard")); | ||||
| var Error_1 = __importDefault(require("../src/components/Error")); | ||||
| exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () { | ||||
|     var _a, username, hide, hide_title, hide_border, card_width, title_color, text_color, bg_color, language_count, theme, cache_seconds, layout, title, topLangs, err_1; | ||||
|     return __generator(this, function (_b) { | ||||
|         switch (_b.label) { | ||||
|             case 0: | ||||
|                 _a = req.query, username = _a.username, hide = _a.hide, hide_title = _a.hide_title, hide_border = _a.hide_border, card_width = _a.card_width, title_color = _a.title_color, text_color = _a.text_color, bg_color = _a.bg_color, language_count = _a.language_count, theme = _a.theme, cache_seconds = _a.cache_seconds, layout = _a.layout, title = _a.title; | ||||
|                 (0, utils_1.prepareResponse)(res); | ||||
|                 _b.label = 1; | ||||
|             case 1: | ||||
|                 _b.trys.push([1, 3, , 4]); | ||||
|                 return [4 /*yield*/, (0, fetcher_1.fetchTopLanguages)(username)]; | ||||
|             case 2: | ||||
|                 topLangs = _b.sent(); | ||||
|                 (0, utils_1.setCache)(res, parseInt(cache_seconds || '', 10)); | ||||
|                 return [2 /*return*/, res.send(server_1.default.renderToStaticMarkup(new TopLanguagesCard_1.default(username, topLangs.langs, { | ||||
|                         hide: (0, utils_1.parseArray)(hide), | ||||
|                         language_count: (0, utils_1.parseNumber)(language_count), | ||||
|                         card_width: (0, utils_1.parseNumber)(card_width), | ||||
|                         layout: layout, | ||||
|                         text_color: text_color, | ||||
|                         theme: theme, | ||||
|                         title: title, | ||||
|                         title_color: title_color, | ||||
|                         bg_color: bg_color, | ||||
|                         hide_border: (0, utils_1.parseBoolean)(hide_border), | ||||
|                         hide_title: (0, utils_1.parseBoolean)(hide_title) | ||||
|                     }).render()))]; | ||||
|             case 3: | ||||
|                 err_1 = _b.sent(); | ||||
|                 return [2 /*return*/, res.send(server_1.default.renderToStaticMarkup(new Error_1.default(err_1).render()))]; | ||||
|             case 4: return [2 /*return*/]; | ||||
|         } | ||||
|     }); | ||||
| }); }); | ||||
							
								
								
									
										19
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,19 +0,0 @@ | |||
| "use strict"; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var express_1 = __importDefault(require("express")); | ||||
| var history_1 = __importDefault(require("./api/history")); | ||||
| var top_langs_1 = __importDefault(require("./api/top-langs")); | ||||
| var profile_1 = __importDefault(require("./api/profile")); | ||||
| var app = (0, express_1.default)(); | ||||
| app.use('/profile', profile_1.default); | ||||
| app.use('/history', history_1.default); | ||||
| app.use('/toplang', top_langs_1.default); | ||||
| app.get('/', function (_, res) { | ||||
|     res.redirect(301, 'https://github.com/domai-tb/codestats-readme'); | ||||
| }); | ||||
| app.listen(3000, function () { | ||||
|     console.log('server launched!'); | ||||
| }); | ||||
							
								
								
									
										225
									
								
								dist/src/cards/HistoryCard.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										225
									
								
								dist/src/cards/HistoryCard.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,225 +0,0 @@ | |||
| "use strict"; | ||||
| var __extends = (this && this.__extends) || (function () { | ||||
|     var extendStatics = function (d, b) { | ||||
|         extendStatics = Object.setPrototypeOf || | ||||
|             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||||
|             function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||||
|         return extendStatics(d, b); | ||||
|     }; | ||||
|     return function (d, b) { | ||||
|         if (typeof b !== "function" && b !== null) | ||||
|             throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||||
|         extendStatics(d, b); | ||||
|         function __() { this.constructor = d; } | ||||
|         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||||
|     }; | ||||
| })(); | ||||
| var __assign = (this && this.__assign) || function () { | ||||
|     __assign = Object.assign || function(t) { | ||||
|         for (var s, i = 1, n = arguments.length; i < n; i++) { | ||||
|             s = arguments[i]; | ||||
|             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||||
|                 t[p] = s[p]; | ||||
|         } | ||||
|         return t; | ||||
|     }; | ||||
|     return __assign.apply(this, arguments); | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var utils_1 = require("../common/utils"); | ||||
| var Card_1 = __importDefault(require("../common/Card")); | ||||
| var FlexLayout_1 = __importDefault(require("../components/FlexLayout")); | ||||
| var HistoryCard = /** @class */ (function (_super) { | ||||
|     __extends(HistoryCard, _super); | ||||
|     function HistoryCard(username, days, options) { | ||||
|         var _this = _super.call(this, options) || this; | ||||
|         _this.username = username; | ||||
|         _this.days = days; | ||||
|         _this.options = options; | ||||
|         _this.legendMinWidth = 180; | ||||
|         _this.processOptions(); | ||||
|         var languagesToHide = options.hide || []; | ||||
|         var languageCount = []; | ||||
|         for (var _i = 0, _a = _this.days; _i < _a.length; _i++) { | ||||
|             var day = _a[_i]; | ||||
|             var _loop_1 = function (data) { | ||||
|                 var index = languageCount.findIndex(function (item) { return item.language === data.language; }); | ||||
|                 if (index === -1) { | ||||
|                     index = languageCount.push({ | ||||
|                         language: data.language, | ||||
|                         xp: 0 | ||||
|                     }) - 1; | ||||
|                 } | ||||
|                 languageCount[index].xp += data.xp; | ||||
|             }; | ||||
|             for (var _b = 0, _c = day.data; _b < _c.length; _b++) { | ||||
|                 var data = _c[_b]; | ||||
|                 _loop_1(data); | ||||
|             } | ||||
|         } | ||||
|         _this.topLanguages = languageCount | ||||
|             .sort(function (a, b) { return b.xp - a.xp; }) | ||||
|             .map(function (item) { return item.language; }) | ||||
|             .filter(function (lang) { return !languagesToHide.includes(lang); }); | ||||
|         languagesToHide.push.apply(languagesToHide, _this.topLanguages.splice((options.language_count || 8))); | ||||
|         if (languagesToHide.length > 0) { | ||||
|             _this.topLanguages.push('Other'); | ||||
|         } | ||||
|         _this.hideLanguages(languagesToHide); | ||||
|         return _this; | ||||
|     } | ||||
|     HistoryCard.prototype.hideLanguages = function (languagesToHide) { | ||||
|         for (var _i = 0, _a = this.days; _i < _a.length; _i++) { | ||||
|             var day = _a[_i]; | ||||
|             // Prepare array of indexes to remove
 | ||||
|             var toRemove = []; | ||||
|             // Loop through data
 | ||||
|             for (var i = 0; i < day.data.length; i++) { | ||||
|                 var element = day.data[i]; | ||||
|                 // If Language should not be hidden: goto next
 | ||||
|                 if (!languagesToHide.includes(element.language)) { | ||||
|                     continue; | ||||
|                 } | ||||
|                 // Search indexOf 'Others'
 | ||||
|                 var otherIndex = day.data.findIndex(function (el) { return el.language === 'Others'; }); | ||||
|                 if (otherIndex === -1) { | ||||
|                     day.data.push({ | ||||
|                         language: 'Others', | ||||
|                         xp: element.xp | ||||
|                     }); | ||||
|                 } | ||||
|                 else { | ||||
|                     day.data[otherIndex].xp += element.xp; | ||||
|                 } | ||||
|                 toRemove.push(i); | ||||
|             } | ||||
|             // Reverse array and remove each indexes
 | ||||
|             for (var _b = 0, _c = toRemove.reverse(); _b < _c.length; _b++) { | ||||
|                 var index = _c[_b]; | ||||
|                 day.data.splice(index, 1); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|     HistoryCard.prototype.processOptions = function () { | ||||
|         var _a, _b, _c; | ||||
|         this.height = 45 + (this.days.length + 1) * 40; | ||||
|         this.width = (_a = this.options.width) !== null && _a !== void 0 ? _a : 500; | ||||
|         if (this.options.layout === 'horizontal') { | ||||
|             this.width = 45 + (this.days.length + 1) * 40 + (this.options.hide_legend ? 0 : this.legendMinWidth); | ||||
|             this.height = (_b = this.options.height) !== null && _b !== void 0 ? _b : 300; | ||||
|         } | ||||
|         this.title = (_c = this.options.title) !== null && _c !== void 0 ? _c : "Last ".concat(this.days.length, " days XP history"); | ||||
|         this.css = ProgressNode.getCSS((0, utils_1.getColor)('text_color', this.options.text_color, this.options.theme)); | ||||
|         if (this.options.reverse_order) { | ||||
|             this.days = this.days.reverse(); | ||||
|         } | ||||
|     }; | ||||
|     HistoryCard.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         var totalTotal = this.days.reduce(function (prvs, crnt) { | ||||
|             if (prvs < crnt.total) { | ||||
|                 return crnt.total; | ||||
|             } | ||||
|             return prvs; | ||||
|         }, 0); | ||||
|         var legendWidth = this.options.hide_legend ? 0 : Math.max(this.width * 20 / 100 + 60, this.legendMinWidth); | ||||
|         var historyWidth = this.width - legendWidth; | ||||
|         var items = []; | ||||
|         // Format History bars
 | ||||
|         var history = this.options.layout === 'horizontal' ? (react_1.default.createElement(FlexLayout_1.default, { key: 0, items: this.days.reverse().map(function (el, index) { return (react_1.default.createElement(VerticalProgressNode, __assign({ key: index }, el, { totalTotal: totalTotal, height: _this.height - 120 }))); }), gap: 40 })) : (react_1.default.createElement(FlexLayout_1.default, { key: 0, items: this.days.map(function (el, index) { return (react_1.default.createElement(ProgressNode, __assign({ key: index }, el, { totalTotal: totalTotal, width: historyWidth - 60 }))); }), gap: 40, direction: "column" })); | ||||
|         items.push(history); | ||||
|         if (!this.options.hide_legend) { | ||||
|             items.push(react_1.default.createElement(FlexLayout_1.default, { key: 1, items: this.topLanguages.map(function (el, index) { return (react_1.default.createElement(react_1.default.Fragment, { key: index }, | ||||
|                     react_1.default.createElement("rect", { rx: "5", x: "2", y: "7", height: "12", width: "12", fill: (0, utils_1.getColorOfLanguage)(el) }), | ||||
|                     react_1.default.createElement("text", { x: "18", y: "18", className: "lang-name", key: index }, el))); }), gap: 20, direction: "column" })); | ||||
|         } | ||||
|         return _super.prototype.render.call(this, react_1.default.createElement("svg", { x: "25" }, | ||||
|             react_1.default.createElement(FlexLayout_1.default, { items: items, gap: historyWidth }))); | ||||
|     }; | ||||
|     return HistoryCard; | ||||
| }(Card_1.default)); | ||||
| exports.default = HistoryCard; | ||||
| var ProgressNode = /** @class */ (function (_super) { | ||||
|     __extends(ProgressNode, _super); | ||||
|     function ProgressNode() { | ||||
|         return _super !== null && _super.apply(this, arguments) || this; | ||||
|     } | ||||
|     ProgressNode.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         var offset = 0; | ||||
|         var maskId = "mask-".concat(this.props.day); | ||||
|         return (react_1.default.createElement(react_1.default.Fragment, null, | ||||
|             react_1.default.createElement("text", { x: "2", y: "15", className: "lang-name" }, new Date(this.props.day).toDateString().substr(4, 6)), | ||||
|             react_1.default.createElement("svg", { width: this.props.width }, | ||||
|                 react_1.default.createElement("mask", { id: maskId }, | ||||
|                     react_1.default.createElement("rect", { x: "0", y: "20", width: this.calcSize(this.props.total), height: "16", fill: "white", rx: "5" })), | ||||
|                 react_1.default.createElement("rect", { rx: "5", ry: "5", x: "0", y: "20", width: this.props.width, height: "16", fill: "#ddd" }), | ||||
|                 this.props.data.map(function (el, index) { | ||||
|                     var color = (0, utils_1.getColorOfLanguage)(el.language); | ||||
|                     offset += el.xp; | ||||
|                     return (react_1.default.createElement("rect", { key: index, mask: "url(#".concat(maskId, ")"), height: "16", fill: color, x: _this.calcSize(offset - el.xp), y: "20", width: "".concat(_this.calcSize(el.xp), "px") })); | ||||
|                 }), | ||||
|                 this.getXPText(offset)))); | ||||
|     }; | ||||
|     ProgressNode.prototype.calcSize = function (number) { | ||||
|         return number * this.props.width / this.props.totalTotal; | ||||
|     }; | ||||
|     ProgressNode.prototype.getXPText = function (offset) { | ||||
|         var size = this.calcSize(offset) + 6; | ||||
|         var txtSize = (this.props.total.toString().length + 3) * 8; | ||||
|         var classes = 'xp-txt'; | ||||
|         if (size + txtSize >= this.calcSize(this.props.totalTotal)) { | ||||
|             size -= txtSize; | ||||
|             classes += ' xp-txt-invert'; | ||||
|         } | ||||
|         return (react_1.default.createElement("text", { x: size, y: "33", className: classes }, | ||||
|             this.props.total, | ||||
|             " XP")); | ||||
|     }; | ||||
|     ProgressNode.getCSS = function (textColor) { return "\n\t.lang-name {\n\t\tfont: 400 16px 'Segoe UI', Ubuntu, Sans-Serif;\n\t\tfill: ".concat(textColor, ";\n\t}\n\t.xp-txt {\n\t\tfont: 400 12px 'Segoe UI', Ubuntu, Sans-Serif;\n\t\tfill: black;\n\t}\n\t.xp-txt-invert {\n\t\tfont: 600 12px 'Segoe UI', Ubuntu, Sans-Serif;\n\t\tfill: white;\n\t}\n\t.subtitle {\n\t\tfont: 400 14px 'Segoe UI', Ubuntu, Sans-Serif;\n\t\tfill: ").concat(textColor, ";\n\t}\n"); }; | ||||
|     return ProgressNode; | ||||
| }(react_1.default.Component)); | ||||
| var VerticalProgressNode = /** @class */ (function (_super) { | ||||
|     __extends(VerticalProgressNode, _super); | ||||
|     function VerticalProgressNode() { | ||||
|         return _super !== null && _super.apply(this, arguments) || this; | ||||
|     } | ||||
|     VerticalProgressNode.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         var offset = this.props.totalTotal; | ||||
|         var maskId = "mask-".concat(this.props.day); | ||||
|         return (react_1.default.createElement(react_1.default.Fragment, null, | ||||
|             react_1.default.createElement("svg", { x: "7", y: "-20", height: this.props.height + 60 }, | ||||
|                 react_1.default.createElement("mask", { id: maskId }, | ||||
|                     react_1.default.createElement("rect", { x: "0", y: 25 + this.calcSize(this.props.totalTotal - this.props.total), width: "16", height: this.calcSize(this.props.total), fill: "white", rx: "5" })), | ||||
|                 react_1.default.createElement("rect", { rx: "5", ry: "5", x: "0", y: "25", width: "16", height: this.props.height, fill: "#ddd" }), | ||||
|                 this.props.data.map(function (el, index) { | ||||
|                     var color = (0, utils_1.getColorOfLanguage)(el.language); | ||||
|                     offset -= el.xp; | ||||
|                     return (react_1.default.createElement("rect", { key: index, mask: "url(#".concat(maskId, ")"), width: "16", fill: color, y: 25 + _this.calcSize(offset), x: "0", height: "".concat(_this.calcSize(el.xp), "px") })); | ||||
|                 }), | ||||
|                 this.getXPTxt()), | ||||
|             react_1.default.createElement("text", { x: "2", y: this.props.height + 18, className: "subtitle" }, new Date(this.props.day).toDateString().substr(4, 3)), | ||||
|             react_1.default.createElement("text", { x: "6", y: this.props.height + 34, className: "subtitle" }, (0, utils_1.formatDateNumber)(new Date(this.props.day).getDate())))); | ||||
|     }; | ||||
|     VerticalProgressNode.prototype.calcSize = function (number) { | ||||
|         return number * this.props.height / this.props.totalTotal; | ||||
|     }; | ||||
|     VerticalProgressNode.prototype.getXPTxt = function () { | ||||
|         var txtLength = (this.props.total.toString().length + 3) * 13; | ||||
|         var position = 25 + this.calcSize(this.props.totalTotal - this.props.total) - txtLength; | ||||
|         var classes = 'xp-txt'; | ||||
|         if (position <= 28) { | ||||
|             position += txtLength + 16; | ||||
|             classes += ' xp-txt-invert'; | ||||
|         } | ||||
|         return (react_1.default.createElement("text", { transform: "rotate(90, 4, ".concat(position, ")"), letterSpacing: "5", y: position, x: "4", rotate: "-90", className: classes }, | ||||
|             this.props.total, | ||||
|             " XP")); | ||||
|     }; | ||||
|     return VerticalProgressNode; | ||||
| }(react_1.default.Component)); | ||||
							
								
								
									
										127
									
								
								dist/src/cards/ProfileCard.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										127
									
								
								dist/src/cards/ProfileCard.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,127 +0,0 @@ | |||
| "use strict"; | ||||
| var __extends = (this && this.__extends) || (function () { | ||||
|     var extendStatics = function (d, b) { | ||||
|         extendStatics = Object.setPrototypeOf || | ||||
|             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||||
|             function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||||
|         return extendStatics(d, b); | ||||
|     }; | ||||
|     return function (d, b) { | ||||
|         if (typeof b !== "function" && b !== null) | ||||
|             throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||||
|         extendStatics(d, b); | ||||
|         function __() { this.constructor = d; } | ||||
|         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||||
|     }; | ||||
| })(); | ||||
| var __assign = (this && this.__assign) || function () { | ||||
|     __assign = Object.assign || function(t) { | ||||
|         for (var s, i = 1, n = arguments.length; i < n; i++) { | ||||
|             s = arguments[i]; | ||||
|             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||||
|                 t[p] = s[p]; | ||||
|         } | ||||
|         return t; | ||||
|     }; | ||||
|     return __assign.apply(this, arguments); | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var utils_1 = require("../common/utils"); | ||||
| var icons_1 = __importDefault(require("../common/icons")); | ||||
| var Card_1 = __importDefault(require("../common/Card")); | ||||
| var FlexLayout_1 = __importDefault(require("../components/FlexLayout")); | ||||
| var ProfileCard = /** @class */ (function (_super) { | ||||
|     __extends(ProfileCard, _super); | ||||
|     function ProfileCard(username, xp, recentXp, options) { | ||||
|         var _a; | ||||
|         var _this = _super.call(this, options) || this; | ||||
|         _this.username = username; | ||||
|         _this.xp = xp; | ||||
|         _this.recentXp = recentXp; | ||||
|         _this.options = options; | ||||
|         _this.defaults = { | ||||
|             line_height: 25, | ||||
|             hide: [] | ||||
|         }; | ||||
|         // This Element
 | ||||
|         _this.stats = { | ||||
|             xp: { | ||||
|                 icon: icons_1.default.star, | ||||
|                 label: 'XP', | ||||
|                 value: xp | ||||
|             }, | ||||
|             recent_xp: { | ||||
|                 icon: icons_1.default.commits, | ||||
|                 label: 'Recent xp', | ||||
|                 value: _this.recentXp | ||||
|             } | ||||
|         }; | ||||
|         // Card Settings
 | ||||
|         _this.width = 495; | ||||
|         _this.height = Math.max(45 + (Object.keys(_this.stats).length + 1) * (_this.options.line_height || _this.defaults.line_height), options.hide_rank ? 0 : 120); | ||||
|         _this.title = (_a = _this.options.title) !== null && _a !== void 0 ? _a : "".concat((0, utils_1.encodeHTML)(_this.username)).concat(['x', 's'].includes(_this.username.slice(-1)) ? '\'' : '\'s', " Code::Stats Profile"); | ||||
|         var textColor = (0, utils_1.getColor)('text_color', options.text_color, options.theme); | ||||
|         var iconColor = (0, utils_1.getColor)('icon_color', options.icon_color, options.theme); | ||||
|         if (!_this.options.hide_rank) { | ||||
|             _this.css += RankCircle.getCSS(textColor, iconColor, (0, utils_1.getProgress)(xp)); | ||||
|         } | ||||
|         if ((_this.options.hide || []) < Object.keys(_this.stats)) { | ||||
|             _this.css += TextNode.getCSS(textColor, _this.options.show_icons ? iconColor : undefined); | ||||
|         } | ||||
|         return _this; | ||||
|     } | ||||
|     ProfileCard.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         return _super.prototype.render.call(this, react_1.default.createElement(react_1.default.Fragment, null, | ||||
|             !this.options.hide_rank && (react_1.default.createElement(RankCircle, { xp: this.xp })), | ||||
|             react_1.default.createElement("svg", { x: "0", y: "0" }, | ||||
|                 react_1.default.createElement(FlexLayout_1.default, { items: Object | ||||
|                         .keys(this.stats) | ||||
|                         .filter(function (item) { return !(_this.options.hide || []).includes(item); }) | ||||
|                         .map(function (el, index) { | ||||
|                         var item = _this.stats[el]; | ||||
|                         return (react_1.default.createElement(TextNode, __assign({}, item, { icon: _this.options.show_icons ? item.icon : undefined, key: index, index: index }))); | ||||
|                     }), gap: this.options.line_height || this.defaults.line_height, direction: "column" })))); | ||||
|     }; | ||||
|     return ProfileCard; | ||||
| }(Card_1.default)); | ||||
| exports.default = ProfileCard; | ||||
| var RankCircle = /** @class */ (function (_super) { | ||||
|     __extends(RankCircle, _super); | ||||
|     function RankCircle() { | ||||
|         var _this = _super !== null && _super.apply(this, arguments) || this; | ||||
|         _this.render = function () { return (react_1.default.createElement("g", { "data-testid": "rank-circle", transform: "translate(400, 0)" }, | ||||
|             react_1.default.createElement("circle", { className: "rank-circle-rim", cx: "-10", cy: "8", r: "40" }), | ||||
|             react_1.default.createElement("circle", { className: "rank-circle", cx: "-10", cy: "8", r: "40" }), | ||||
|             react_1.default.createElement("g", { className: "rank-text" }, | ||||
|                 react_1.default.createElement("text", { x: "-4", y: "0", alignmentBaseline: "central", dominantBaseline: "central", textAnchor: "middle" }, | ||||
|                     "lv ", | ||||
|                     (0, utils_1.getLevel)(_this.props.xp))))); }; | ||||
|         return _this; | ||||
|     } | ||||
|     RankCircle.getCSS = function (textColor, titleColor, progress) { return "\n\t\t.rank-text {\n\t\t\tfont: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ".concat(textColor, ";\n\t\t\tanimation: scaleInAnimation 0.3s ease-in-out forwards;\n\t\t}\n\n\t\t.rank-circle-rim {\n\t\t\tstroke: ").concat(titleColor, ";\n\t\t\tfill: none;\n\t\t\tstroke-width: 6;\n\t\t\topacity: 0.2;\n\t\t}\n\t\t.rank-circle {\n\t\t\tstroke: ").concat(titleColor, ";\n\t\t\tstroke-dasharray: 250;\n\t\t\tfill: none;\n\t\t\tstroke-width: 6;\n\t\t\tstroke-linecap: round;\n\t\t\topacity: 0.8;\n\t\t\ttransform-origin: -10px 8px;\n\t\t\ttransform: rotate(-90deg);\n\t\t\tanimation: rankAnimation 1s forwards ease-in-out;\n\t\t}\n\n\t\t@keyframes rankAnimation {\n\t\t\tfrom {\n\t\t\t\tstroke-dashoffset: ").concat((0, utils_1.calculateCircleProgress)(0), ";\n\t\t\t}\n\t\t\tto {\n\t\t\t\tstroke-dashoffset: ").concat((0, utils_1.calculateCircleProgress)(progress), ";\n\t\t\t}\n\t\t}\n\t"); }; | ||||
|     return RankCircle; | ||||
| }(react_1.default.Component)); | ||||
| var TextNode = /** @class */ (function (_super) { | ||||
|     __extends(TextNode, _super); | ||||
|     function TextNode() { | ||||
|         return _super !== null && _super.apply(this, arguments) || this; | ||||
|     } | ||||
|     TextNode.prototype.render = function () { | ||||
|         var delay = (this.props.index + 3 * 150); | ||||
|         // Icon prefixing line
 | ||||
|         var icon = this.props.icon ? (react_1.default.createElement("svg", { "data-testid": "icon", className: "icon", viewBox: "0 0 16 16", version: "1.1", width: "16", height: "16" }, this.props.icon)) : undefined; | ||||
|         return (react_1.default.createElement("g", { className: "stagger", style: { animationDelay: "".concat(delay, "ms") }, transform: "translate(25, 0)" }, | ||||
|             icon, | ||||
|             react_1.default.createElement("text", { className: "stat bold", x: this.props.icon ? 25 : undefined, y: "12.5" }, | ||||
|                 this.props.label, | ||||
|                 ":"), | ||||
|             react_1.default.createElement("text", { className: "stat", x: this.props.icon ? 120 : 100, y: "12.5" }, (0, utils_1.kFormatter)(this.props.value)))); | ||||
|     }; | ||||
|     TextNode.getCSS = function (textColor, iconColor) { return "\n\t\t".concat(iconColor ? ".icon {\n\t\t\t\tfill: ".concat(iconColor, ";\n\t\t\t\t// display: block;\n\t\t\t}") : '', "\n\t\t.stagger {\n\t\t\topacity: 0;\n\t\t\tanimation: fadeInAnimation 0.3s ease-in-out forwards;\n\t\t}\n\t\t.stat {\n\t\t\tfont: 600 14px 'Segoe UI', Ubuntu, \"Helvetica Neue\", Sans-Serif; fill: ").concat(textColor, ";\n\t\t}\n\t\t.bold {\n\t\t\tfont-weight: 700\n\t\t}\n\t"); }; | ||||
|     return TextNode; | ||||
| }(react_1.default.Component)); | ||||
							
								
								
									
										132
									
								
								dist/src/cards/TopLanguagesCard.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										132
									
								
								dist/src/cards/TopLanguagesCard.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,132 +0,0 @@ | |||
| "use strict"; | ||||
| var __extends = (this && this.__extends) || (function () { | ||||
|     var extendStatics = function (d, b) { | ||||
|         extendStatics = Object.setPrototypeOf || | ||||
|             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||||
|             function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||||
|         return extendStatics(d, b); | ||||
|     }; | ||||
|     return function (d, b) { | ||||
|         if (typeof b !== "function" && b !== null) | ||||
|             throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||||
|         extendStatics(d, b); | ||||
|         function __() { this.constructor = d; } | ||||
|         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||||
|     }; | ||||
| })(); | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var utils_1 = require("../common/utils"); | ||||
| var Card_1 = __importDefault(require("../common/Card")); | ||||
| var FlexLayout_1 = __importDefault(require("../components/FlexLayout")); | ||||
| var TopLanguagesCard = /** @class */ (function (_super) { | ||||
|     __extends(TopLanguagesCard, _super); | ||||
|     function TopLanguagesCard(username, langs, options) { | ||||
|         var _a; | ||||
|         var _this = _super.call(this, options) || this; | ||||
|         _this.username = username; | ||||
|         _this.langs = langs; | ||||
|         _this.options = options; | ||||
|         _this.langs = _this.langs | ||||
|             .filter(function (item) { return !(options.hide || []).includes(item.name); }) | ||||
|             .slice(0, options.language_count || 5); | ||||
|         _this.height = 45 + (_this.langs.length + 1) * 40; | ||||
|         _this.width = 300; | ||||
|         if (options.card_width && !isNaN(options.card_width)) { | ||||
|             _this.width = options.card_width; | ||||
|         } | ||||
|         var textColor = (0, utils_1.getColor)('text_color', options.text_color, options.theme); | ||||
|         _this.title = (_a = _this.options.title) !== null && _a !== void 0 ? _a : 'Most Used Languages'; | ||||
|         _this.css = CompactTextNode.getCSS(textColor); | ||||
|         return _this; | ||||
|     } | ||||
|     TopLanguagesCard.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         var total = this.langs.reduce(function (acc, curr) { return acc + curr.xp; }, 0); | ||||
|         if (this.options.layout === 'compact') { | ||||
|             this.width = this.width + 50; | ||||
|             this.height = 90 + Math.round(this.langs.length / 2) * 25; | ||||
|             return _super.prototype.render.call(this, react_1.default.createElement("svg", { x: "25" }, | ||||
|                 react_1.default.createElement("mask", { id: "rect-mask" }, | ||||
|                     react_1.default.createElement("rect", { x: "0", y: "0", width: this.width - 50, height: "8", fill: "white", rx: "5" })), | ||||
|                 react_1.default.createElement(CompactProgressBar, { langs: this.langs, total: total, parentWidth: this.width }), | ||||
|                 this.langs.map(function (el, index) { return (react_1.default.createElement(CompactTextNode, { key: index, index: index, total: total, lang: el })); }))); | ||||
|         } | ||||
|         else { | ||||
|             return _super.prototype.render.call(this, react_1.default.createElement("svg", { x: "25" }, | ||||
|                 react_1.default.createElement(FlexLayout_1.default, { items: this.langs.map(function (el, index) { return (react_1.default.createElement(ProgressNode, { key: index, lang: el, total: total, parentWidth: _this.width })); }), gap: 40, direction: "column" }))); | ||||
|         } | ||||
|     }; | ||||
|     return TopLanguagesCard; | ||||
| }(Card_1.default)); | ||||
| exports.default = TopLanguagesCard; | ||||
| var CompactProgressBar = /** @class */ (function (_super) { | ||||
|     __extends(CompactProgressBar, _super); | ||||
|     function CompactProgressBar() { | ||||
|         return _super !== null && _super.apply(this, arguments) || this; | ||||
|     } | ||||
|     CompactProgressBar.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         var offset = 0; | ||||
|         return this.props.langs.map(function (lang, index) { | ||||
|             var percent = (0, utils_1.trunc)((lang.xp / _this.props.total) * (_this.props.parentWidth - 50), 2); | ||||
|             var progress = percent < 10 ? percent + 10 : percent; | ||||
|             var output = (react_1.default.createElement("rect", { key: index, mask: "url(#rect-mask)", "data-testid": "lang-progress", x: offset, y: "0", width: progress, height: "8", fill: lang.color || '#858585' })); | ||||
|             offset += percent; | ||||
|             return output; | ||||
|         }); | ||||
|     }; | ||||
|     return CompactProgressBar; | ||||
| }(react_1.default.Component)); | ||||
| var CompactTextNode = /** @class */ (function (_super) { | ||||
|     __extends(CompactTextNode, _super); | ||||
|     function CompactTextNode() { | ||||
|         return _super !== null && _super.apply(this, arguments) || this; | ||||
|     } | ||||
|     CompactTextNode.prototype.render = function () { | ||||
|         var index = this.props.index; | ||||
|         var x = 0; | ||||
|         var y = 12.5 * index + 25; | ||||
|         if (index % 2 !== 0) { | ||||
|             x = 150; | ||||
|             y = 12.5 + 12.5 * index; | ||||
|         } | ||||
|         return (react_1.default.createElement("g", { transform: "translate(".concat(x, ", ").concat(y, ")") }, | ||||
|             react_1.default.createElement("circle", { cx: "5", cy: "6", r: "5", fill: this.props.lang.color }), | ||||
|             react_1.default.createElement("text", { "data-testid": "lang-name", x: "15", y: "10", className: 'lang-name' }, | ||||
|                 this.props.lang.name, | ||||
|                 " ", | ||||
|                 (0, utils_1.getPercent)(this.props.lang.xp, this.props.total), | ||||
|                 "%"))); | ||||
|     }; | ||||
|     CompactTextNode.getCSS = function (textColor) { return "\n\t\t.lang-name {\n\t\t\tfont: 400 11px 'Segoe UI', Ubuntu, Sans-Serif;\n\t\t\tfill: ".concat(textColor, ";\n\t\t}\n\t"); }; | ||||
|     return CompactTextNode; | ||||
| }(react_1.default.Component)); | ||||
| var ProgressNode = /** @class */ (function (_super) { | ||||
|     __extends(ProgressNode, _super); | ||||
|     function ProgressNode() { | ||||
|         var _this = _super !== null && _super.apply(this, arguments) || this; | ||||
|         _this.paddingRight = 60; | ||||
|         return _this; | ||||
|     } | ||||
|     ProgressNode.prototype.render = function () { | ||||
|         var width = this.props.parentWidth - this.paddingRight; | ||||
|         var progress1 = (0, utils_1.getPercent)(this.props.lang.xp, this.props.total); | ||||
|         var progress2 = (0, utils_1.getPercent)(this.props.lang.xp - this.props.lang.recentXp, this.props.total); | ||||
|         return (react_1.default.createElement(react_1.default.Fragment, null, | ||||
|             react_1.default.createElement("text", { x: "2", y: "15", className: "lang-name" }, | ||||
|                 this.props.lang.name, | ||||
|                 " ", | ||||
|                 progress1, | ||||
|                 "% ", | ||||
|                 this.props.lang.recentXp >= 1 ? " + ".concat((0, utils_1.trunc)(progress1 - progress2, 2), "%") : ''), | ||||
|             react_1.default.createElement("svg", { width: width }, | ||||
|                 react_1.default.createElement("rect", { rx: "5", ry: "5", x: "0", y: "25", width: width, height: "8", fill: "#ddd" }), | ||||
|                 progress1 !== progress2 && (react_1.default.createElement("rect", { height: "8", fill: "#f2b866", rx: "5", ry: "5", x: "1", y: "25", width: "".concat(progress1, "%") })), | ||||
|                 progress1 >= progress2 && (react_1.default.createElement("rect", { height: "8", fill: this.props.lang.color, rx: "5", ry: "5", x: "0", y: "25", "data-testid": "lang-progress", width: "".concat(progress2, "%") }))))); | ||||
|     }; | ||||
|     return ProgressNode; | ||||
| }(react_1.default.Component)); | ||||
							
								
								
									
										60
									
								
								dist/src/common/Card.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										60
									
								
								dist/src/common/Card.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,60 +0,0 @@ | |||
| "use strict"; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var FlexLayout_1 = __importDefault(require("../components/FlexLayout")); | ||||
| var utils_1 = require("./utils"); | ||||
| var Card = /** @class */ (function () { | ||||
|     function Card(options) { | ||||
|         this.hideBorder = false; | ||||
|         this.hideTitle = false; | ||||
|         this.css = ''; | ||||
|         this.paddingX = 25; | ||||
|         this.paddingY = 35; | ||||
|         this.animations = true; | ||||
|         this.height = 100; | ||||
|         this.width = 100; | ||||
|         this.title = ''; | ||||
|         this.colors = {}; | ||||
|         if (options) { | ||||
|             this.hideBorder = (0, utils_1.parseBoolean)(options.hide_border); | ||||
|             this.hideTitle = (0, utils_1.parseBoolean)(options.hide_title); | ||||
|             this.colors = { | ||||
|                 titleColor: (0, utils_1.getColor)('title_color', options === null || options === void 0 ? void 0 : options.title_color, options === null || options === void 0 ? void 0 : options.theme), | ||||
|                 bgColor: (0, utils_1.getColor)('bg_color', options === null || options === void 0 ? void 0 : options.bg_color, options === null || options === void 0 ? void 0 : options.theme) | ||||
|             }; | ||||
|         } | ||||
|     } | ||||
|     Card.prototype.renderTitle = function () { | ||||
|         var titleText = (react_1.default.createElement("text", { x: "0", y: "0", className: "header" }, this.title)); | ||||
|         var prefixIcon = (react_1.default.createElement("svg", { className: "icon", x: "0", y: "-13", viewBox: "0 0 16 16", version: "1.1", width: "16", height: "16" }, this.titlePrefix)); | ||||
|         return (react_1.default.createElement("g", { transform: "translate(".concat(this.paddingX, ", ").concat(this.paddingY, ")") }, | ||||
|             react_1.default.createElement(FlexLayout_1.default, { items: [this.titlePrefix && prefixIcon, titleText], gap: 25 }))); | ||||
|     }; | ||||
|     Card.prototype.renderGradient = function () { | ||||
|         if (typeof this.colors.bgColor !== 'object') | ||||
|             return; | ||||
|         var gradients = this.colors.bgColor.slice(1); | ||||
|         return typeof this.colors.bgColor === 'object' ? | ||||
|             (react_1.default.createElement("defs", null, | ||||
|                 react_1.default.createElement("linearGradient", { id: "gradient", gradientTransform: "rotate(".concat(this.colors.bgColor[0], ")") }, gradients.map(function (grad, index) { | ||||
|                     var offset = (index * 100) / (gradients.length - 1); | ||||
|                     return "<stop offset=\"".concat(offset, "%\" stop-color=\"#").concat(grad, "\" />"); | ||||
|                 })))) : | ||||
|             ''; | ||||
|     }; | ||||
|     Card.prototype.render = function (body) { | ||||
|         return (react_1.default.createElement("svg", { width: this.width, height: this.height - (this.hideTitle ? 30 : 0), viewBox: "0 0 ".concat(this.width, " ").concat(this.height), fill: "none", xmlns: "http://www.w3.org/2000/svg" }, | ||||
|             react_1.default.createElement("style", null, "\n\t\t\t\t\t.header {\n\t\t\t\t\t\tfont: 600 18px 'Segoe UI', Ubuntu, Sans-Serif;\n\t\t\t\t\t\tfill: ".concat(this.colors.titleColor, ";\n\t\t\t\t\t\tanimation: fadeInAnimation 0.8s ease-in-out forwards;\n\t\t\t\t\t}\n\t\t\t\t\t").concat(this.css, "\n\n\t\t\t\t\t/* Animations */\n\t\t\t\t\t@keyframes scaleInAnimation {\n\t\t\t\t\t\tfrom {\n\t\t\t\t\t\t\ttransform: translate(-5px, 5px) scale(0);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tto {\n\t\t\t\t\t\t\ttransform: translate(-5px, 5px) scale(1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t@keyframes fadeInAnimation {\n\t\t\t\t\t\tfrom {\n\t\t\t\t\t\t\topacity: 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tto {\n\t\t\t\t\t\t\topacity: 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t")), | ||||
|             this.renderGradient(), | ||||
|             react_1.default.createElement("rect", { x: "0.5", y: "0.5", rx: "4.5", height: "99%", stroke: "#E4E2E2", width: this.width - 1, fill: typeof this.colors.bgColor === 'object' ? | ||||
|                     'url(#gradient)' : | ||||
|                     this.colors.bgColor, strokeOpacity: this.hideBorder ? 0 : 1 }), | ||||
|             this.hideTitle ? '' : this.renderTitle(), | ||||
|             react_1.default.createElement("g", { transform: "translate(0, ".concat(this.hideTitle ? this.paddingX : this.paddingY + 20, ")") }, body))); | ||||
|     }; | ||||
|     return Card; | ||||
| }()); | ||||
| exports.default = Card; | ||||
							
								
								
									
										16
									
								
								dist/src/common/icons.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								dist/src/common/icons.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,16 +0,0 @@ | |||
| "use strict"; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var icons = { | ||||
|     star: react_1.default.createElement("path", { fillRule: "evenodd", d: "M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z" }), | ||||
|     commits: react_1.default.createElement("path", { fillRule: "evenodd", d: "M1.643 3.143L.427 1.927A.25.25 0 000 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 00.177-.427L2.715 4.215a6.5 6.5 0 11-1.18 4.458.75.75 0 10-1.493.154 8.001 8.001 0 101.6-5.684zM7.75 4a.75.75 0 01.75.75v2.992l2.028.812a.75.75 0 01-.557 1.392l-2.5-1A.75.75 0 017 8.25v-3.5A.75.75 0 017.75 4z" }), | ||||
|     prs: react_1.default.createElement("path", { fillRule: "evenodd", d: "M7.177 3.073L9.573.677A.25.25 0 0110 .854v4.792a.25.25 0 01-.427.177L7.177 3.427a.25.25 0 010-.354zM3.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122v5.256a2.251 2.251 0 11-1.5 0V5.372A2.25 2.25 0 011.5 3.25zM11 2.5h-1V4h1a1 1 0 011 1v5.628a2.251 2.251 0 101.5 0V5A2.5 2.5 0 0011 2.5zm1 10.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0zM3.75 12a.75.75 0 100 1.5.75.75 0 000-1.5z" }), | ||||
|     issues: react_1.default.createElement("path", { fillRule: "evenodd", d: "M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z" }), | ||||
|     icon: react_1.default.createElement("path", { fillRule: "evenodd", d: "M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z" }), | ||||
|     contribs: react_1.default.createElement("path", { fillRule: "evenodd", d: "M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z" }), | ||||
|     fork: react_1.default.createElement("path", { fillRule: "evenodd", d: "M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z" }) | ||||
| }; | ||||
| exports.default = icons; | ||||
							
								
								
									
										63
									
								
								dist/src/common/retryer.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										63
									
								
								dist/src/common/retryer.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,63 +0,0 @@ | |||
| "use strict"; | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var utils_1 = require("./utils"); | ||||
| function retryer(fetcher, data, retries, err) { | ||||
|     if (retries === void 0) { retries = 0; } | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var err_1; | ||||
|         return __generator(this, function (_a) { | ||||
|             switch (_a.label) { | ||||
|                 case 0: | ||||
|                     if (retries > 7) { | ||||
|                         throw new utils_1.CustomError('Maximum retries exceeded. ' + err, 'MAX_RETRY'); | ||||
|                     } | ||||
|                     _a.label = 1; | ||||
|                 case 1: | ||||
|                     _a.trys.push([1, 3, , 4]); | ||||
|                     return [4 /*yield*/, fetcher(data)]; | ||||
|                 case 2: return [2 /*return*/, _a.sent()]; | ||||
|                 case 3: | ||||
|                     err_1 = _a.sent(); | ||||
|                     return [2 /*return*/, retryer(fetcher, data, ++retries, err_1)]; | ||||
|                 case 4: return [2 /*return*/]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| exports.default = retryer; | ||||
							
								
								
									
										267
									
								
								dist/src/common/utils.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										267
									
								
								dist/src/common/utils.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,267 +0,0 @@ | |||
| "use strict"; | ||||
| var __extends = (this && this.__extends) || (function () { | ||||
|     var extendStatics = function (d, b) { | ||||
|         extendStatics = Object.setPrototypeOf || | ||||
|             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||||
|             function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||||
|         return extendStatics(d, b); | ||||
|     }; | ||||
|     return function (d, b) { | ||||
|         if (typeof b !== "function" && b !== null) | ||||
|             throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||||
|         extendStatics(d, b); | ||||
|         function __() { this.constructor = d; } | ||||
|         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||||
|     }; | ||||
| })(); | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.getColorOfLanguage = exports.formatDate = exports.formatDateNumber = exports.lowercaseTrim = exports.setCache = exports.prepareResponse = exports.calculateCircleProgress = exports.parseNumber = exports.trunc = exports.getPercent = exports.getProgress = exports.getLevel = exports.CustomError = exports.SECONDARY_ERROR_MESSAGES = exports.CONSTANTS = exports.wrapTextMultiline = exports.getColor = exports.profileGraphRequest = exports.request = exports.clampValue = exports.parseArray = exports.parseBoolean = exports.kFormatter = exports.encodeHTML = void 0; | ||||
| var node_fetch_1 = __importDefault(require("node-fetch")); | ||||
| var word_wrap_1 = __importDefault(require("word-wrap")); | ||||
| var themes_json_1 = __importDefault(require("../../themes/themes.json")); | ||||
| var language_bar_json_1 = __importDefault(require("../../themes/language-bar.json")); | ||||
| /** | ||||
|  * Encode a string to escape HTML | ||||
|  * | ||||
|  * https://stackoverflow.com/a/48073476/10629172
 | ||||
|  * @param str the string to encode | ||||
|  */ | ||||
| function encodeHTML(str) { | ||||
|     return str | ||||
|         .replace(/[\u00A0-\u9999<>&](?!#)/gim, function (i) { | ||||
|         return '&#' + i.charCodeAt(0) + ';'; | ||||
|     }); | ||||
| } | ||||
| exports.encodeHTML = encodeHTML; | ||||
| function kFormatter(num) { | ||||
|     return Math.abs(num) > 999 ? | ||||
|         trunc(num / 1000) + 'k' : | ||||
|         num; | ||||
| } | ||||
| exports.kFormatter = kFormatter; | ||||
| /** | ||||
|  * Transform the `value` query string into a Boolean | ||||
|  * @param value the value to transform | ||||
|  */ | ||||
| function parseBoolean(value) { | ||||
|     return value === 'true' || value === '' || value === true; | ||||
| } | ||||
| exports.parseBoolean = parseBoolean; | ||||
| function parseArray(str) { | ||||
|     if (!str) | ||||
|         return []; | ||||
|     return str.split(','); | ||||
| } | ||||
| exports.parseArray = parseArray; | ||||
| function clampValue(number, min, max) { | ||||
|     return Math.max(min, max ? Math.min(number, max) : number); | ||||
| } | ||||
| exports.clampValue = clampValue; | ||||
| function request(username) { | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var resp; | ||||
|         return __generator(this, function (_a) { | ||||
|             switch (_a.label) { | ||||
|                 case 0: return [4 /*yield*/, (0, node_fetch_1.default)("https://codestats.net/api/users/".concat(username))]; | ||||
|                 case 1: | ||||
|                     resp = _a.sent(); | ||||
|                     return [2 /*return*/, resp.json()]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| exports.request = request; | ||||
| function profileGraphRequest(body) { | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var resp; | ||||
|         return __generator(this, function (_a) { | ||||
|             switch (_a.label) { | ||||
|                 case 0: return [4 /*yield*/, (0, node_fetch_1.default)('https://codestats.net/profile-graph', { | ||||
|                         body: body, | ||||
|                         method: 'POST' | ||||
|                     })]; | ||||
|                 case 1: | ||||
|                     resp = _a.sent(); | ||||
|                     return [2 /*return*/, resp.json()]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| exports.profileGraphRequest = profileGraphRequest; | ||||
| function getColor(color, replacementColor, theme) { | ||||
|     if (theme === void 0) { theme = 'default'; } | ||||
|     return '#' + (replacementColor ? replacementColor : themes_json_1.default[theme][color]); | ||||
| } | ||||
| exports.getColor = getColor; | ||||
| function wrapTextMultiline(text, width, maxLines) { | ||||
|     if (width === void 0) { width = 60; } | ||||
|     if (maxLines === void 0) { maxLines = 3; } | ||||
|     var wrapped = (0, word_wrap_1.default)(encodeHTML(text), { width: width }) | ||||
|         .split('\n') // Split wrapped lines to get an array of lines
 | ||||
|         .map(function (line) { return line.trim(); }); // Remove leading and trailing whitespace of each line
 | ||||
|     var lines = wrapped.slice(0, maxLines); // Only consider maxLines lines
 | ||||
|     // Add "..." to the last line if the text exceeds maxLines
 | ||||
|     if (wrapped.length > maxLines) { | ||||
|         lines[maxLines - 1] += '...'; | ||||
|     } | ||||
|     // Remove empty lines if text fits in less than maxLines lines
 | ||||
|     return lines.filter(Boolean); | ||||
| } | ||||
| exports.wrapTextMultiline = wrapTextMultiline; | ||||
| exports.CONSTANTS = { | ||||
|     THIRTY_MINUTES: 1800, | ||||
|     TWO_HOURS: 7200, | ||||
|     FOUR_HOURS: 14400, | ||||
|     ONE_DAY: 86400, | ||||
|     LEVEL_FACTOR: 0.025 | ||||
| }; | ||||
| exports.SECONDARY_ERROR_MESSAGES = { | ||||
|     MAX_RETRY: 'Make sure your profile is not private' | ||||
| }; | ||||
| var CustomError = /** @class */ (function (_super) { | ||||
|     __extends(CustomError, _super); | ||||
|     function CustomError(message, type) { | ||||
|         var _this = _super.call(this, message) || this; | ||||
|         _this.type = type; | ||||
|         _this.secondaryMessage = exports.SECONDARY_ERROR_MESSAGES[type] || 'adsad'; | ||||
|         return _this; | ||||
|     } | ||||
|     CustomError.MAX_RETRY = 'MAX_RETRY'; | ||||
|     CustomError.USER_NOT_FOUND = 'USER_NOT_FOUND'; | ||||
|     return CustomError; | ||||
| }(Error)); | ||||
| exports.CustomError = CustomError; | ||||
| /** | ||||
|  * Return the level depending on the xp | ||||
|  * | ||||
|  * https://codestats.net/api-docs
 | ||||
|  * @param xp the xp count | ||||
|  */ | ||||
| function getLevel(xp) { | ||||
|     return Math.trunc(Math.floor(exports.CONSTANTS.LEVEL_FACTOR * Math.sqrt(xp))); | ||||
| } | ||||
| exports.getLevel = getLevel; | ||||
| /** | ||||
|  * Return the progress (0-99)% til next level | ||||
|  * @param xp Xp number | ||||
|  */ | ||||
| function getProgress(xp) { | ||||
|     var currentLvl = getLevel(xp); | ||||
|     return trunc((exports.CONSTANTS.LEVEL_FACTOR * Math.sqrt(xp) - currentLvl) * 100, 2); | ||||
| } | ||||
| exports.getProgress = getProgress; | ||||
| function getPercent(number, total) { | ||||
|     return trunc(number * 100 / total, 2); | ||||
| } | ||||
| exports.getPercent = getPercent; | ||||
| /** | ||||
|  * Round a number without moving it to a string and reparsing it | ||||
|  * | ||||
|  * https://stackoverflow.com/a/29494612/7335674
 | ||||
|  * @param number the number to truncate | ||||
|  * @param digits the number of digits after the dot | ||||
|  */ | ||||
| function trunc(number, digits) { | ||||
|     if (digits === void 0) { digits = 0; } | ||||
|     var pow = Math.pow(10, digits); | ||||
|     return Math.round(number * pow) / pow; | ||||
| } | ||||
| exports.trunc = trunc; | ||||
| function parseNumber(number) { | ||||
|     if (typeof number === 'undefined' || typeof number === 'number') { | ||||
|         return 0; | ||||
|     } | ||||
|     var n = parseFloat(number); | ||||
|     if (isNaN(n)) { | ||||
|         return 0; | ||||
|     } | ||||
|     return n; | ||||
| } | ||||
| exports.parseNumber = parseNumber; | ||||
| function calculateCircleProgress(percent, radius) { | ||||
|     if (radius === void 0) { radius = 40; } | ||||
|     var c = Math.PI * radius * 2; | ||||
|     percent = clampValue(percent, 0, 100); | ||||
|     return ((100 - percent) / 100) * c; | ||||
| } | ||||
| exports.calculateCircleProgress = calculateCircleProgress; | ||||
| /** | ||||
|  * Prepare the response | ||||
|  * @param res the response object | ||||
|  */ | ||||
| function prepareResponse(res) { | ||||
|     res.setHeader('Content-Type', 'image/svg+xml'); | ||||
| } | ||||
| exports.prepareResponse = prepareResponse; | ||||
| /** | ||||
|  * set the cache in the response | ||||
|  * @param res the Response object | ||||
|  * @param cache The cache time in seconds | ||||
|  */ | ||||
| function setCache(res, cache) { | ||||
|     if (cache === void 0) { cache = exports.CONSTANTS.THIRTY_MINUTES; } | ||||
|     if (isNaN(cache)) { | ||||
|         cache = exports.CONSTANTS.THIRTY_MINUTES; | ||||
|     } | ||||
|     var clampedCache = clampValue(cache, exports.CONSTANTS.THIRTY_MINUTES, exports.CONSTANTS.ONE_DAY); | ||||
|     res.setHeader('Cache-Control', "public, stale-while-revalidate, max-age=".concat(clampedCache, " s-maxage=").concat(clampedCache)); | ||||
| } | ||||
| exports.setCache = setCache; | ||||
| function lowercaseTrim(str) { | ||||
|     return str.toLowerCase().trim(); | ||||
| } | ||||
| exports.lowercaseTrim = lowercaseTrim; | ||||
| function formatDateNumber(number) { | ||||
|     if (number < 10) { | ||||
|         return '0' + number; | ||||
|     } | ||||
|     return number + ''; | ||||
| } | ||||
| exports.formatDateNumber = formatDateNumber; | ||||
| function formatDate(date) { | ||||
|     return "".concat(date.getFullYear(), "-").concat(formatDateNumber(date.getMonth() + 1), "-").concat(formatDateNumber(date.getDate())); | ||||
| } | ||||
| exports.formatDate = formatDate; | ||||
| function getColorOfLanguage(name) { | ||||
|     return name in language_bar_json_1.default ? language_bar_json_1.default[name].color || '#3e4053' : '#3e4053'; | ||||
| } | ||||
| exports.getColorOfLanguage = getColorOfLanguage; | ||||
							
								
								
									
										38
									
								
								dist/src/components/Error.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								dist/src/components/Error.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,38 +0,0 @@ | |||
| "use strict"; | ||||
| var __extends = (this && this.__extends) || (function () { | ||||
|     var extendStatics = function (d, b) { | ||||
|         extendStatics = Object.setPrototypeOf || | ||||
|             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||||
|             function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||||
|         return extendStatics(d, b); | ||||
|     }; | ||||
|     return function (d, b) { | ||||
|         if (typeof b !== "function" && b !== null) | ||||
|             throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||||
|         extendStatics(d, b); | ||||
|         function __() { this.constructor = d; } | ||||
|         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||||
|     }; | ||||
| })(); | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var utils_1 = require("../common/utils"); | ||||
| var Error = /** @class */ (function (_super) { | ||||
|     __extends(Error, _super); | ||||
|     function Error() { | ||||
|         var _this = _super !== null && _super.apply(this, arguments) || this; | ||||
|         _this.render = function () { return (react_1.default.createElement("svg", { width: "495", height: "120", viewBox: "0 0 495 120", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, | ||||
|             react_1.default.createElement("style", null, "\n\t\t\t\t.text { font: 600 16px 'Segoe UI', Ubuntu, Sans-Serif; fill: #2F80ED }\n\t\t\t\t.small { font: 600 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: #252525 }\n\t\t\t\t.gray { fill: #858585 }\n\t\t\t"), | ||||
|             react_1.default.createElement("rect", { x: "0.5", y: "0.5", width: "494", height: "99%", rx: "4.5", fill: "#FFFEFE", stroke: "#E4E2E2" }), | ||||
|             react_1.default.createElement("text", { x: "25", y: "45", className: "text" }, "Something went wrong!"), | ||||
|             react_1.default.createElement("text", { "data-testid": "message", x: "25", y: "55", className: "text small" }, | ||||
|                 react_1.default.createElement("tspan", { x: "25", dy: "18" }, (0, utils_1.encodeHTML)(_this.props.message)), | ||||
|                 react_1.default.createElement("tspan", { x: "25", dy: "18", className: "gray" }, _this.props.secondaryMessage)))); }; | ||||
|         return _this; | ||||
|     } | ||||
|     return Error; | ||||
| }(react_1.default.Component)); | ||||
| exports.default = Error; | ||||
							
								
								
									
										41
									
								
								dist/src/components/FlexLayout.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								dist/src/components/FlexLayout.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,41 +0,0 @@ | |||
| "use strict"; | ||||
| var __extends = (this && this.__extends) || (function () { | ||||
|     var extendStatics = function (d, b) { | ||||
|         extendStatics = Object.setPrototypeOf || | ||||
|             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||||
|             function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||||
|         return extendStatics(d, b); | ||||
|     }; | ||||
|     return function (d, b) { | ||||
|         if (typeof b !== "function" && b !== null) | ||||
|             throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||||
|         extendStatics(d, b); | ||||
|         function __() { this.constructor = d; } | ||||
|         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||||
|     }; | ||||
| })(); | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var react_1 = __importDefault(require("react")); | ||||
| var FlexLayout = /** @class */ (function (_super) { | ||||
|     __extends(FlexLayout, _super); | ||||
|     function FlexLayout() { | ||||
|         return _super !== null && _super.apply(this, arguments) || this; | ||||
|     } | ||||
|     FlexLayout.prototype.render = function () { | ||||
|         var _this = this; | ||||
|         return this.props.items.filter(Boolean).map(function (item, index) { return (react_1.default.createElement("g", { key: index, transform: _this.getGap(index) }, item)); }); | ||||
|     }; | ||||
|     FlexLayout.prototype.getGap = function (index) { | ||||
|         var gap = this.props.gap * index; | ||||
|         var transform = "translate(".concat(gap, ", 0)"); | ||||
|         if (this.props.direction === 'column') { | ||||
|             transform = "translate(0, ".concat(gap, ")"); | ||||
|         } | ||||
|         return transform; | ||||
|     }; | ||||
|     return FlexLayout; | ||||
| }(react_1.default.Component)); | ||||
| exports.default = FlexLayout; | ||||
							
								
								
									
										159
									
								
								dist/src/fetcher/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										159
									
								
								dist/src/fetcher/index.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,159 +0,0 @@ | |||
| "use strict"; | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __generator = (this && this.__generator) || function (thisArg, body) { | ||||
|     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||||
|     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||||
|     function verb(n) { return function (v) { return step([n, v]); }; } | ||||
|     function step(op) { | ||||
|         if (f) throw new TypeError("Generator is already executing."); | ||||
|         while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||||
|             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; | ||||
|             if (y = 0, t) op = [op[0] & 2, t.value]; | ||||
|             switch (op[0]) { | ||||
|                 case 0: case 1: t = op; break; | ||||
|                 case 4: _.label++; return { value: op[1], done: false }; | ||||
|                 case 5: _.label++; y = op[1]; op = [0]; continue; | ||||
|                 case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||||
|                 default: | ||||
|                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||||
|                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||||
|                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||||
|                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||||
|                     if (t[2]) _.ops.pop(); | ||||
|                     _.trys.pop(); continue; | ||||
|             } | ||||
|             op = body.call(thisArg, _); | ||||
|         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||||
|         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||||
|     } | ||||
| }; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.fetchTopLanguages = exports.fetchHistory = exports.fetchProfile = void 0; | ||||
| var utils_1 = require("../common/utils"); | ||||
| var retryer_1 = __importDefault(require("../common/retryer")); | ||||
| function fetchProfile(username) { | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var response; | ||||
|         return __generator(this, function (_a) { | ||||
|             switch (_a.label) { | ||||
|                 case 0: | ||||
|                     if (!username) | ||||
|                         throw Error('Invalid Username'); | ||||
|                     return [4 /*yield*/, (0, retryer_1.default)(utils_1.request, username)]; | ||||
|                 case 1: | ||||
|                     response = _a.sent(); | ||||
|                     return [2 /*return*/, { | ||||
|                             username: username, | ||||
|                             xp: response.total_xp, | ||||
|                             recentXp: response.new_xp, | ||||
|                             level: (0, utils_1.getLevel)(response.total_xp) | ||||
|                         }]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| exports.fetchProfile = fetchProfile; | ||||
| function fetchHistory(username, days) { | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var date, body, response, result, languagesData, _i, _a, data, day, keys, _b, keys_1, day, item, date2, oldDate; | ||||
|         return __generator(this, function (_c) { | ||||
|             switch (_c.label) { | ||||
|                 case 0: | ||||
|                     if (!username) | ||||
|                         throw Error('Invalid Username'); | ||||
|                     date = new Date(); | ||||
|                     date.setDate(date.getDate() - (days - 1)); | ||||
|                     body = "{\n\t\tprofile(username: \"".concat(username, "\") {\n\t\t\tday_language_xps: dayLanguageXps(since: \"").concat((0, utils_1.formatDate)(date), "\") {date language xp}\n\t\t}\n\t}"); | ||||
|                     return [4 /*yield*/, (0, retryer_1.default)(utils_1.profileGraphRequest, body)]; | ||||
|                 case 1: | ||||
|                     response = _c.sent(); | ||||
|                     if (response.errors) { | ||||
|                         throw new utils_1.CustomError(response.errors[0].message, 'MAX_RETRY'); | ||||
|                     } | ||||
|                     result = {}; | ||||
|                     languagesData = {}; | ||||
|                     for (_i = 0, _a = response.data.profile.day_language_xps; _i < _a.length; _i++) { | ||||
|                         data = _a[_i]; | ||||
|                         day = result[data.date]; | ||||
|                         if (!day) { | ||||
|                             day = []; | ||||
|                         } | ||||
|                         day.push({ | ||||
|                             xp: data.xp, | ||||
|                             language: data.language | ||||
|                         }); | ||||
|                         if (!(data.language in languagesData)) { | ||||
|                             languagesData[data.language] = 0; | ||||
|                         } | ||||
|                         languagesData[data.language] += data.xp; | ||||
|                         result[data.date] = day; | ||||
|                     } | ||||
|                     keys = Object.keys(result); | ||||
|                     for (_b = 0, keys_1 = keys; _b < keys_1.length; _b++) { | ||||
|                         day = keys_1[_b]; | ||||
|                         item = result[day]; | ||||
|                         result[day] = item.sort(function (a, b) { return languagesData[b.language] - languagesData[a.language]; }); | ||||
|                         if (keys.indexOf(day) === 0 && day === (0, utils_1.formatDate)(date)) { | ||||
|                             continue; | ||||
|                         } | ||||
|                         date2 = new Date(day); | ||||
|                         date2.setDate(date2.getDate() - 1); | ||||
|                         oldDate = (0, utils_1.formatDate)(date2); | ||||
|                         if (!(oldDate in result)) { | ||||
|                             result[oldDate] = []; | ||||
|                         } | ||||
|                     } | ||||
|                     return [2 /*return*/, Object.keys(result).map(function (el) { return ({ | ||||
|                             data: result[el], | ||||
|                             day: el, | ||||
|                             total: result[el].reduce(function (prvs, crnt) { return prvs + crnt.xp; }, 0) | ||||
|                         }); }).sort(function (a, b) { return a.day < b.day ? 1 : -1; })]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| exports.fetchHistory = fetchHistory; | ||||
| function fetchTopLanguages(username) { | ||||
|     return __awaiter(this, void 0, void 0, function () { | ||||
|         var res, langs, resp; | ||||
|         return __generator(this, function (_a) { | ||||
|             switch (_a.label) { | ||||
|                 case 0: | ||||
|                     if (!username) | ||||
|                         throw Error('Invalid username'); | ||||
|                     return [4 /*yield*/, (0, retryer_1.default)(utils_1.request, username)]; | ||||
|                 case 1: | ||||
|                     res = _a.sent(); | ||||
|                     langs = res.languages; | ||||
|                     resp = Object.keys(langs) | ||||
|                         .map(function (key) { | ||||
|                         var item = langs[key]; | ||||
|                         return { | ||||
|                             xp: item.xps, | ||||
|                             recentXp: item.new_xps, | ||||
|                             color: (0, utils_1.getColorOfLanguage)(key), | ||||
|                             name: key, | ||||
|                             level: (0, utils_1.getLevel)(item.xps) | ||||
|                         }; | ||||
|                     }) | ||||
|                         .sort(function (a, b) { return (b.xp + b.recentXp) - (a.xp + a.recentXp); }); | ||||
|                     return [2 /*return*/, { | ||||
|                             username: username, | ||||
|                             langs: resp | ||||
|                         }]; | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| } | ||||
| exports.fetchTopLanguages = fetchTopLanguages; | ||||
							
								
								
									
										1713
									
								
								dist/themes/language-bar.json
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1713
									
								
								dist/themes/language-bar.json
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										218
									
								
								dist/themes/themes.json
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										218
									
								
								dist/themes/themes.json
									
										
									
									
										vendored
									
									
								
							|  | @ -1,218 +0,0 @@ | |||
| { | ||||
|     "default": { | ||||
|         "title_color": "2f80ed", | ||||
|         "icon_color": "4c71f2", | ||||
|         "text_color": "333", | ||||
|         "bg_color": "fffefe" | ||||
|     }, | ||||
|     "dark": { | ||||
|         "title_color": "fff", | ||||
|         "icon_color": "79ff97", | ||||
|         "text_color": "9f9f9f", | ||||
|         "bg_color": "151515" | ||||
|     }, | ||||
|     "radical": { | ||||
|         "title_color": "fe428e", | ||||
|         "icon_color": "f8d847", | ||||
|         "text_color": "a9fef7", | ||||
|         "bg_color": "141321" | ||||
|     }, | ||||
|     "merko": { | ||||
|         "title_color": "abd200", | ||||
|         "icon_color": "b7d364", | ||||
|         "text_color": "68b587", | ||||
|         "bg_color": "0a0f0b" | ||||
|     }, | ||||
|     "gruvbox": { | ||||
|         "title_color": "fabd2f", | ||||
|         "icon_color": "fe8019", | ||||
|         "text_color": "8ec07c", | ||||
|         "bg_color": "282828" | ||||
|     }, | ||||
|     "tokyonight": { | ||||
|         "title_color": "70a5fd", | ||||
|         "icon_color": "bf91f3", | ||||
|         "text_color": "38bdae", | ||||
|         "bg_color": "1a1b27" | ||||
|     }, | ||||
|     "onedark": { | ||||
|         "title_color": "e4bf7a", | ||||
|         "icon_color": "8eb573", | ||||
|         "text_color": "df6d74", | ||||
|         "bg_color": "282c34" | ||||
|     }, | ||||
|     "cobalt": { | ||||
|         "title_color": "e683d9", | ||||
|         "icon_color": "0480ef", | ||||
|         "text_color": "75eeb2", | ||||
|         "bg_color": "193549" | ||||
|     }, | ||||
|     "synthwave": { | ||||
|         "title_color": "e2e9ec", | ||||
|         "icon_color": "ef8539", | ||||
|         "text_color": "e5289e", | ||||
|         "bg_color": "2b213a" | ||||
|     }, | ||||
|     "highcontrast": { | ||||
|         "title_color": "e7f216", | ||||
|         "icon_color": "00ffff", | ||||
|         "text_color": "fff", | ||||
|         "bg_color": "000" | ||||
|     }, | ||||
|     "dracula": { | ||||
|         "title_color": "ff6e96", | ||||
|         "icon_color": "79dafa", | ||||
|         "text_color": "f8f8f2", | ||||
|         "bg_color": "282a36" | ||||
|     }, | ||||
|     "prussian": { | ||||
|         "title_color": "bddfff", | ||||
|         "icon_color": "38a0ff", | ||||
|         "text_color": "6e93b5", | ||||
|         "bg_color": "172f45" | ||||
|     }, | ||||
|     "monokai": { | ||||
|         "title_color": "eb1f6a", | ||||
|         "icon_color": "e28905", | ||||
|         "text_color": "f1f1eb", | ||||
|         "bg_color": "272822" | ||||
|     }, | ||||
|     "vue": { | ||||
|         "title_color": "41b883", | ||||
|         "icon_color": "41b883", | ||||
|         "text_color": "273849", | ||||
|         "bg_color": "fffefe" | ||||
|     }, | ||||
|     "vue-dark": { | ||||
|         "title_color": "41b883", | ||||
|         "icon_color": "41b883", | ||||
|         "text_color": "fffefe", | ||||
|         "bg_color": "273849" | ||||
|     }, | ||||
|     "shades-of-purple": { | ||||
|         "title_color": "fad000", | ||||
|         "icon_color": "b362ff", | ||||
|         "text_color": "a599e9", | ||||
|         "bg_color": "2d2b55" | ||||
|     }, | ||||
|     "nightowl": { | ||||
|         "title_color": "c792ea", | ||||
|         "icon_color": "ffeb95", | ||||
|         "text_color": "7fdbca", | ||||
|         "bg_color": "011627" | ||||
|     }, | ||||
|     "buefy": { | ||||
|         "title_color": "7957d5", | ||||
|         "icon_color": "ff3860", | ||||
|         "text_color": "363636", | ||||
|         "bg_color": "ffffff" | ||||
|     }, | ||||
|     "blue-green": { | ||||
|         "title_color": "2f97c1", | ||||
|         "icon_color": "f5b700", | ||||
|         "text_color": "0cf574", | ||||
|         "bg_color": "040f0f" | ||||
|     }, | ||||
|     "algolia": { | ||||
|         "title_color": "00AEFF", | ||||
|         "icon_color": "2DDE98", | ||||
|         "text_color": "FFFFFF", | ||||
|         "bg_color": "050F2C" | ||||
|     }, | ||||
|     "great-gatsby": { | ||||
|         "title_color": "ffa726", | ||||
|         "icon_color": "ffb74d", | ||||
|         "text_color": "ffd95b", | ||||
|         "bg_color": "000000" | ||||
|     }, | ||||
|     "darcula": { | ||||
|         "title_color": "BA5F17", | ||||
|         "icon_color": "84628F", | ||||
|         "text_color": "BEBEBE", | ||||
|         "bg_color": "242424" | ||||
|     }, | ||||
|     "bear": { | ||||
|         "title_color": "e03c8a", | ||||
|         "icon_color": "00AEFF", | ||||
|         "text_color": "bcb28d", | ||||
|         "bg_color": "1f2023" | ||||
|     }, | ||||
|     "solarized-dark": { | ||||
|         "title_color": "268bd2", | ||||
|         "icon_color": "b58900", | ||||
|         "text_color": "859900", | ||||
|         "bg_color": "002b36" | ||||
|     }, | ||||
|     "solarized-light": { | ||||
|         "title_color": "268bd2", | ||||
|         "icon_color": "b58900", | ||||
|         "text_color": "859900", | ||||
|         "bg_color": "fdf6e3" | ||||
|     }, | ||||
|     "chartreuse-dark": { | ||||
|         "title_color": "7fff00", | ||||
|         "icon_color": "00AEFF", | ||||
|         "text_color": "fff", | ||||
|         "bg_color": "000" | ||||
|     }, | ||||
|     "nord": { | ||||
|         "title_color": "81a1c1", | ||||
|         "text_color": "d8dee9", | ||||
|         "icon_color": "88c0d0", | ||||
|         "bg_color": "2e3440" | ||||
|     }, | ||||
|     "gotham": { | ||||
|         "title_color": "2aa889", | ||||
|         "icon_color": "599cab", | ||||
|         "text_color": "99d1ce", | ||||
|         "bg_color": "0c1014" | ||||
|     }, | ||||
|     "material-palenight": { | ||||
|         "title_color": "c792ea", | ||||
|         "icon_color": "89ddff", | ||||
|         "text_color": "a6accd", | ||||
|         "bg_color": "292d3e" | ||||
|     }, | ||||
|     "graywhite": { | ||||
|         "title_color": "24292e", | ||||
|         "icon_color": "24292e", | ||||
|         "text_color": "24292e", | ||||
|         "bg_color": "ffffff" | ||||
|     }, | ||||
|     "vision-friendly-dark": { | ||||
|         "title_color": "ffb000", | ||||
|         "icon_color": "785ef0", | ||||
|         "text_color": "ffffff", | ||||
|         "bg_color": "000000" | ||||
|     }, | ||||
|     "ayu-mirage": { | ||||
|         "title_color": "f4cd7c", | ||||
|         "icon_color": "73d0ff", | ||||
|         "text_color": "c7c8c2", | ||||
|         "bg_color": "1f2430" | ||||
|     }, | ||||
|     "midnight-purple": { | ||||
|         "title_color": "9745f5", | ||||
|         "icon_color": "9f4bff", | ||||
|         "text_color": "ffffff", | ||||
|         "bg_color": "000000" | ||||
|     }, | ||||
|     "calm": { | ||||
|         "title_color": "e07a5f", | ||||
|         "icon_color": "edae49", | ||||
|         "text_color": "ebcfb2", | ||||
|         "bg_color": "373f51" | ||||
|     }, | ||||
|     "omni": { | ||||
|         "title_color": "FF79C6", | ||||
|         "icon_color": "e7de79", | ||||
|         "text_color": "E1E1E6", | ||||
|         "bg_color": "191622" | ||||
|     }, | ||||
|     "react": { | ||||
|         "title_color": "61dafb", | ||||
|         "icon_color": "61dafb", | ||||
|         "text_color": "ffffff", | ||||
|         "bg_color": "20232a" | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Ava Gaiety W
						Ava Gaiety W