koffing 0.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +64 -151
- package/dist/data-CP51LAc9.cjs +404 -0
- package/dist/data-CRHBhbCJ.js +345 -0
- package/dist/index.cjs +441 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +433 -0
- package/dist/types-BVzP_Ko4.d.cts +62 -0
- package/dist/types-BVzP_Ko4.d.ts +62 -0
- package/dist/validator.cjs +3563 -0
- package/dist/validator.d.cts +14 -0
- package/dist/validator.d.ts +14 -0
- package/dist/validator.js +3562 -0
- package/package.json +46 -41
- package/Makefile +0 -21
- package/build/asset-manifest.json +0 -22
- package/build/favicon.png +0 -0
- package/build/index.html +0 -1
- package/build/precache-manifest.5382b78dea2866c8a94cee003da35d84.js +0 -26
- package/build/robots.txt +0 -3
- package/build/service-worker.js +0 -39
- package/build/static/css/main.102b9840.chunk.css +0 -2
- package/build/static/css/main.102b9840.chunk.css.map +0 -1
- package/build/static/js/2.4b3dd85a.chunk.js +0 -3
- package/build/static/js/2.4b3dd85a.chunk.js.LICENSE.txt +0 -67
- package/build/static/js/2.4b3dd85a.chunk.js.map +0 -1
- package/build/static/js/main.07f66bec.chunk.js +0 -2
- package/build/static/js/main.07f66bec.chunk.js.map +0 -1
- package/build/static/js/runtime-main.525bb0ff.js +0 -2
- package/build/static/js/runtime-main.525bb0ff.js.map +0 -1
- package/public/favicon.png +0 -0
- package/public/index.html +0 -30
- package/public/robots.txt +0 -3
- package/src/App.test.js +0 -9
- package/src/components/App.js +0 -18
- package/src/components/AppFooter/AppFooter.css.js +0 -12
- package/src/components/AppFooter/AppFooter.js +0 -31
- package/src/components/AppFooter/index.js +0 -3
- package/src/components/AppHeader/AppHeader.css.js +0 -21
- package/src/components/AppHeader/AppHeader.js +0 -34
- package/src/components/AppHeader/index.js +0 -3
- package/src/components/Board/Board.css.js +0 -21
- package/src/components/Board/Board.js +0 -110
- package/src/components/Board/index.js +0 -3
- package/src/components/BoardInput/BoardInput.css.js +0 -14
- package/src/components/BoardInput/BoardInput.js +0 -36
- package/src/components/BoardInput/index.js +0 -3
- package/src/components/BoardOutput/BoardOutput.css.js +0 -17
- package/src/components/BoardOutput/BoardOutput.js +0 -36
- package/src/components/BoardOutput/index.js +0 -3
- package/src/components/Code/Code.css.js +0 -10
- package/src/components/Code/Code.js +0 -28
- package/src/components/Code/index.js +0 -3
- package/src/components/StyledComponent.js +0 -24
- package/src/components/ThemedApp.js +0 -25
- package/src/core/Koffing.js +0 -71
- package/src/core/Pokemon.js +0 -181
- package/src/core/PokemonTeam.js +0 -78
- package/src/core/PokemonTeamSet.js +0 -52
- package/src/core/ShowdownParser.js +0 -280
- package/src/core/index.js +0 -7
- package/src/img/koffing-shiny.png +0 -0
- package/src/img/koffing.png +0 -0
- package/src/index.css +0 -42
- package/src/index.js +0 -17
- package/src/serviceWorker.js +0 -141
- package/src/setupTests.js +0 -5
- package/src/teams/example.koffing.js +0 -25
- package/src/tools/base64.js +0 -25
- package/src/tools/history.js +0 -17
- package/src/tools/index.js +0 -4
- package/src/variables.json +0 -5
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import Pokemon from "./Pokemon";
|
|
2
|
-
import PokemonTeam from "./PokemonTeam";
|
|
3
|
-
import PokemonTeamSet from "./PokemonTeamSet";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Ported from Pokemon Showdown Client's exportTeam/importTeam functions.
|
|
7
|
-
*
|
|
8
|
-
* @see https://github.com/Zarel/Pokemon-Showdown-Client/blob/8994e9e/js/storage.js
|
|
9
|
-
*/
|
|
10
|
-
class ShowdownParser {
|
|
11
|
-
/**
|
|
12
|
-
* @param {String} code
|
|
13
|
-
*/
|
|
14
|
-
constructor(code) {
|
|
15
|
-
/**
|
|
16
|
-
* @type {String}
|
|
17
|
-
*/
|
|
18
|
-
this.code = code.trim() + "";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @returns {PokemonTeamSet}
|
|
23
|
-
*/
|
|
24
|
-
parse() {
|
|
25
|
-
const regexes = ShowdownParser.regexes;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @type {PokemonTeam[]}
|
|
29
|
-
*/
|
|
30
|
-
let teams = [];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @type {{team: PokemonTeam, pokemon: Pokemon}}
|
|
34
|
-
*/
|
|
35
|
-
let current = {
|
|
36
|
-
team: null,
|
|
37
|
-
pokemon: null
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @type {string[]}
|
|
42
|
-
*/
|
|
43
|
-
let lines = this.code
|
|
44
|
-
.trim()
|
|
45
|
-
.split("\n")
|
|
46
|
-
.map(function (line) {
|
|
47
|
-
return line.trim();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
let $this = this;
|
|
51
|
-
|
|
52
|
-
lines.forEach(function (line) {
|
|
53
|
-
// New Team
|
|
54
|
-
if (line.match(regexes.team)) {
|
|
55
|
-
// Start new team
|
|
56
|
-
current.team = new PokemonTeam();
|
|
57
|
-
$this._parseTeam(line, current.team);
|
|
58
|
-
teams.push(current.team);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Separator
|
|
63
|
-
if (line === '' || line.match(/^[- ]+$/)) {
|
|
64
|
-
// Line break (empty or as dashes separator), previous Pokemon definition ended.
|
|
65
|
-
$this._saveCurrent(teams, current);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// New Pokemon + nickname, name, gender and item
|
|
70
|
-
if (!current.pokemon) {
|
|
71
|
-
current.pokemon = new Pokemon();
|
|
72
|
-
$this._parseNameLine(line, current.pokemon);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Ability, Level, etc.
|
|
77
|
-
if ($this._parseKeyValuePairs(line, current.pokemon)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// EVs and IVs
|
|
82
|
-
if ($this._parseEvsIvs(line, current.pokemon)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Moves
|
|
87
|
-
if ((current.pokemon.moves.length < 4) && line.match(regexes.move)) {
|
|
88
|
-
current.pokemon.moves.push(regexes.move.exec(line)[1].trim());
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
this._saveCurrent(teams, current);
|
|
93
|
-
|
|
94
|
-
return new PokemonTeamSet(teams);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @param {string} line
|
|
99
|
-
* @param {PokemonTeam} team
|
|
100
|
-
* @private
|
|
101
|
-
*/
|
|
102
|
-
_parseTeam(line, team) {
|
|
103
|
-
const rg = ShowdownParser.regexes;
|
|
104
|
-
|
|
105
|
-
let teamData = rg.team.exec(line);
|
|
106
|
-
let teamNames = teamData[2].split('/');
|
|
107
|
-
let teamName, teamFolder;
|
|
108
|
-
|
|
109
|
-
if (teamNames.length > 1) {
|
|
110
|
-
teamFolder = teamNames.shift();
|
|
111
|
-
teamName = teamNames.join('/');
|
|
112
|
-
} else {
|
|
113
|
-
teamName = teamData[2];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
team.format = teamData[1].trim();
|
|
117
|
-
team.name = teamName.trim();
|
|
118
|
-
team.folder = teamFolder ? teamFolder.trim() : undefined;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} line
|
|
123
|
-
* @param {Pokemon} pokemon
|
|
124
|
-
* @private
|
|
125
|
-
*/
|
|
126
|
-
_parseNameLine(line, pokemon) {
|
|
127
|
-
const rg = ShowdownParser.regexes;
|
|
128
|
-
|
|
129
|
-
if (line.match(rg.nickname_name)) { // has nickname?
|
|
130
|
-
let nameMatches = rg.nickname_name.exec(line);
|
|
131
|
-
pokemon.nickname = nameMatches[1].trim();
|
|
132
|
-
pokemon.name = nameMatches[2].trim();
|
|
133
|
-
} else if (line.match(rg.name)) {
|
|
134
|
-
let nameMatches = rg.name.exec(line);
|
|
135
|
-
pokemon.name = nameMatches[1].trim();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (line.match(rg.gender)) {
|
|
139
|
-
pokemon.gender = rg.gender.exec(line)[1].toUpperCase().trim();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (line.match(rg.item)) {
|
|
143
|
-
pokemon.item = rg.item.exec(line)[1].trim();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @param {string} line
|
|
149
|
-
* @param {Pokemon} pokemon
|
|
150
|
-
* @returns {boolean} True if it matched some, false otherwise
|
|
151
|
-
* @private
|
|
152
|
-
*/
|
|
153
|
-
_parseEvsIvs(line, pokemon) {
|
|
154
|
-
const rg = ShowdownParser.regexes;
|
|
155
|
-
|
|
156
|
-
if (line.match(rg.eivs)) {
|
|
157
|
-
let data = rg.eivs.exec(line);
|
|
158
|
-
let prop = data[1].toLowerCase();
|
|
159
|
-
let values = data[2].split('/');
|
|
160
|
-
let limit = prop === 'evs' ? 255 : 31;
|
|
161
|
-
|
|
162
|
-
values.forEach(function (stat) {
|
|
163
|
-
let statData = rg.eivs_value.exec(stat.trim().toLowerCase());
|
|
164
|
-
if (!statData) {
|
|
165
|
-
console.error("Invalid syntax for " + prop + ": " + stat);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (!pokemon[prop]) {
|
|
169
|
-
pokemon[prop] = {};
|
|
170
|
-
}
|
|
171
|
-
pokemon[prop][statData[2]] = parseFloat(statData[1]);
|
|
172
|
-
|
|
173
|
-
if (pokemon[prop][statData[2]] > limit) {
|
|
174
|
-
pokemon[prop][statData[2]] = limit;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @param {string} line
|
|
184
|
-
* @param {Pokemon} pokemon
|
|
185
|
-
* @returns {boolean} True if it matched some, false otherwise
|
|
186
|
-
* @private
|
|
187
|
-
*/
|
|
188
|
-
_parseKeyValuePairs(line, pokemon) {
|
|
189
|
-
const rg = ShowdownParser.regexes;
|
|
190
|
-
|
|
191
|
-
return ['ability', 'level', 'shiny', 'happiness', 'teratype', 'nature'].some(
|
|
192
|
-
function (key) {
|
|
193
|
-
if (line.match(rg[key])) {
|
|
194
|
-
pokemon[key] = rg[key].exec(line)[1].trim();
|
|
195
|
-
|
|
196
|
-
if (!isNaN(pokemon[key])) {
|
|
197
|
-
pokemon[key] = parseFloat(pokemon[key]);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (key === 'happiness' && pokemon[key] > 255) {
|
|
201
|
-
pokemon[key] = 255;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (key === 'level' && pokemon[key] < 1) {
|
|
205
|
-
pokemon[key] = 1;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (key === 'level' && pokemon[key] > 100) {
|
|
209
|
-
pokemon[key] = 100;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (key === 'shiny') {
|
|
213
|
-
pokemon[key] = !!pokemon[key].match(/yes/i);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Saves the current state of the parsed team.
|
|
225
|
-
*
|
|
226
|
-
* @param {Array} teams
|
|
227
|
-
* @param {{team: PokemonTeam, pokemon: Pokemon}} current
|
|
228
|
-
* @returns {ShowdownParser}
|
|
229
|
-
* @private
|
|
230
|
-
*/
|
|
231
|
-
_saveCurrent(teams, current) {
|
|
232
|
-
if (!current.team) {
|
|
233
|
-
// Create a team if there is no current one
|
|
234
|
-
current.team = new PokemonTeam();
|
|
235
|
-
teams.push(current.team);
|
|
236
|
-
}
|
|
237
|
-
if (current.pokemon) {
|
|
238
|
-
// Create a team if there is no current one
|
|
239
|
-
current.team.pokemon.push(current.pokemon);
|
|
240
|
-
current.pokemon = null;
|
|
241
|
-
}
|
|
242
|
-
return this;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Sanitizes and re-formats / prettifies the Showdown code
|
|
247
|
-
*
|
|
248
|
-
* @returns {ShowdownParser}
|
|
249
|
-
*/
|
|
250
|
-
format() {
|
|
251
|
-
this.code = this.parse().toString();
|
|
252
|
-
return this;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* @returns {string}
|
|
257
|
-
*/
|
|
258
|
-
toString() {
|
|
259
|
-
return this.code;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
ShowdownParser.regexes = {
|
|
264
|
-
team: /^===\s+\[(.*)\]\s+(.*)\s+===$/,
|
|
265
|
-
gender: /\((F|M)\)/i,
|
|
266
|
-
item: /@\s?(.*)$/i,
|
|
267
|
-
name: /^([^()=@]{2,})/i,
|
|
268
|
-
nickname_name: /^([^()=@]*)\s+\(([^()=@]{2,})\)/i,
|
|
269
|
-
ability: /^Ability:\s?(.*)$/i,
|
|
270
|
-
level: /^Level:\s?([0-9]{1,3})$/i,
|
|
271
|
-
shiny: /^Shiny:\s?(Yes|No)$/i,
|
|
272
|
-
happiness: /^Happiness:\s?([0-9]{1,3})$/i,
|
|
273
|
-
teratype: /^Tera Type:\s?(.*)$/i,
|
|
274
|
-
eivs: /^([EI]Vs):\s?(.*)$/i,
|
|
275
|
-
eivs_value: /^([0-9]+)\s+(hp|atk|def|spa|spd|spe)$/i,
|
|
276
|
-
nature: /^(.*)\s+Nature$/,
|
|
277
|
-
move: /^[-~]\s?(.*)$/i
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
export default ShowdownParser;
|
package/src/core/index.js
DELETED
|
Binary file
|
package/src/img/koffing.png
DELETED
|
Binary file
|
package/src/index.css
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
html {
|
|
2
|
-
box-sizing: border-box;
|
|
3
|
-
-webkit-font-smoothing: antialiased;
|
|
4
|
-
-moz-osx-font-smoothing: grayscale;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
*, *::before, *::after {
|
|
8
|
-
box-sizing: inherit;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
body {
|
|
12
|
-
margin: 0;
|
|
13
|
-
background-color: #fafafa;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@media print {
|
|
17
|
-
body {
|
|
18
|
-
background-color: #fff;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
a {
|
|
23
|
-
color: #6B71B8;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.koffing-sprite {
|
|
27
|
-
animation-name: koffing-animation;
|
|
28
|
-
animation-duration: 700ms;
|
|
29
|
-
animation-iteration-count: infinite;
|
|
30
|
-
animation-direction: alternate;
|
|
31
|
-
animation-timing-function: ease-in-out;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* Standard syntax */
|
|
35
|
-
@keyframes koffing-animation {
|
|
36
|
-
0% {
|
|
37
|
-
transform: translate(0px, 0px);
|
|
38
|
-
}
|
|
39
|
-
100% {
|
|
40
|
-
transform: translate(-2px, -3px);
|
|
41
|
-
}
|
|
42
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import './index.css';
|
|
4
|
-
import ThemedApp from './components/ThemedApp';
|
|
5
|
-
import * as serviceWorker from './serviceWorker';
|
|
6
|
-
|
|
7
|
-
ReactDOM.render(
|
|
8
|
-
<React.StrictMode>
|
|
9
|
-
<ThemedApp/>
|
|
10
|
-
</React.StrictMode>,
|
|
11
|
-
document.getElementById('root')
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
// If you want your app to work offline and load faster, you can change
|
|
15
|
-
// unregister() to register() below. Note this comes with some pitfalls.
|
|
16
|
-
// Learn more about service workers: https://bit.ly/CRA-PWA
|
|
17
|
-
serviceWorker.unregister();
|
package/src/serviceWorker.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// This optional code is used to register a service worker.
|
|
2
|
-
// register() is not called by default.
|
|
3
|
-
|
|
4
|
-
// This lets the app load faster on subsequent visits in production, and gives
|
|
5
|
-
// it offline capabilities. However, it also means that developers (and users)
|
|
6
|
-
// will only see deployed updates on subsequent visits to a page, after all the
|
|
7
|
-
// existing tabs open on the page have been closed, since previously cached
|
|
8
|
-
// teams are updated in the background.
|
|
9
|
-
|
|
10
|
-
// To learn more about the benefits of this model and instructions on how to
|
|
11
|
-
// opt-in, read https://bit.ly/CRA-PWA
|
|
12
|
-
|
|
13
|
-
const isLocalhost = Boolean(
|
|
14
|
-
window.location.hostname === 'localhost' ||
|
|
15
|
-
// [::1] is the IPv6 localhost address.
|
|
16
|
-
window.location.hostname === '[::1]' ||
|
|
17
|
-
// 127.0.0.0/8 are considered localhost for IPv4.
|
|
18
|
-
window.location.hostname.match(
|
|
19
|
-
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
|
20
|
-
)
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export function register(config) {
|
|
24
|
-
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
|
25
|
-
// The URL constructor is available in all browsers that support SW.
|
|
26
|
-
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
|
27
|
-
if (publicUrl.origin !== window.location.origin) {
|
|
28
|
-
// Our service worker won't work if PUBLIC_URL is on a different origin
|
|
29
|
-
// from what our page is served on. This might happen if a CDN is used to
|
|
30
|
-
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
window.addEventListener('load', () => {
|
|
35
|
-
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
|
36
|
-
|
|
37
|
-
if (isLocalhost) {
|
|
38
|
-
// This is running on localhost. Let's check if a service worker still exists or not.
|
|
39
|
-
checkValidServiceWorker(swUrl, config);
|
|
40
|
-
|
|
41
|
-
// Add some additional logging to localhost, pointing developers to the
|
|
42
|
-
// service worker/PWA documentation.
|
|
43
|
-
navigator.serviceWorker.ready.then(() => {
|
|
44
|
-
console.log(
|
|
45
|
-
'This web app is being served cache-first by a service ' +
|
|
46
|
-
'worker. To learn more, visit https://bit.ly/CRA-PWA'
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
// Is not localhost. Just register service worker
|
|
51
|
-
registerValidSW(swUrl, config);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function registerValidSW(swUrl, config) {
|
|
58
|
-
navigator.serviceWorker
|
|
59
|
-
.register(swUrl)
|
|
60
|
-
.then(registration => {
|
|
61
|
-
registration.onupdatefound = () => {
|
|
62
|
-
const installingWorker = registration.installing;
|
|
63
|
-
if (installingWorker == null) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
installingWorker.onstatechange = () => {
|
|
67
|
-
if (installingWorker.state === 'installed') {
|
|
68
|
-
if (navigator.serviceWorker.controller) {
|
|
69
|
-
// At this point, the updated precached content has been fetched,
|
|
70
|
-
// but the previous service worker will still serve the older
|
|
71
|
-
// content until all client tabs are closed.
|
|
72
|
-
console.log(
|
|
73
|
-
'New content is available and will be used when all ' +
|
|
74
|
-
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Execute callback
|
|
78
|
-
if (config && config.onUpdate) {
|
|
79
|
-
config.onUpdate(registration);
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
// At this point, everything has been precached.
|
|
83
|
-
// It's the perfect time to display a
|
|
84
|
-
// "Content is cached for offline use." message.
|
|
85
|
-
console.log('Content is cached for offline use.');
|
|
86
|
-
|
|
87
|
-
// Execute callback
|
|
88
|
-
if (config && config.onSuccess) {
|
|
89
|
-
config.onSuccess(registration);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
})
|
|
96
|
-
.catch(error => {
|
|
97
|
-
console.error('Error during service worker registration:', error);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function checkValidServiceWorker(swUrl, config) {
|
|
102
|
-
// Check if the service worker can be found. If it can't reload the page.
|
|
103
|
-
fetch(swUrl, {
|
|
104
|
-
headers: { 'Service-Worker': 'script' },
|
|
105
|
-
})
|
|
106
|
-
.then(response => {
|
|
107
|
-
// Ensure service worker exists, and that we really are getting a JS file.
|
|
108
|
-
const contentType = response.headers.get('content-type');
|
|
109
|
-
if (
|
|
110
|
-
response.status === 404 ||
|
|
111
|
-
(contentType != null && contentType.indexOf('javascript') === -1)
|
|
112
|
-
) {
|
|
113
|
-
// No service worker found. Probably a different app. Reload the page.
|
|
114
|
-
navigator.serviceWorker.ready.then(registration => {
|
|
115
|
-
registration.unregister().then(() => {
|
|
116
|
-
window.location.reload();
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
} else {
|
|
120
|
-
// Service worker found. Proceed as normal.
|
|
121
|
-
registerValidSW(swUrl, config);
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
.catch(() => {
|
|
125
|
-
console.log(
|
|
126
|
-
'No internet connection found. App is running in offline mode.'
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function unregister() {
|
|
132
|
-
if ('serviceWorker' in navigator) {
|
|
133
|
-
navigator.serviceWorker.ready
|
|
134
|
-
.then(registration => {
|
|
135
|
-
registration.unregister();
|
|
136
|
-
})
|
|
137
|
-
.catch(error => {
|
|
138
|
-
console.error(error.message);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
package/src/setupTests.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export default `
|
|
2
|
-
=== [gen7] Folder 1/Example Team ===
|
|
3
|
-
|
|
4
|
-
Smogon (Koffing) (F) @ Eviolite
|
|
5
|
-
Level: 5
|
|
6
|
-
Ability: Levitate
|
|
7
|
-
Shiny: Yes
|
|
8
|
-
Happiness: 255
|
|
9
|
-
EVs: 36 HP / 236 Def / 236 SpD
|
|
10
|
-
IVs: 31 HP / 30 Atk / 31 SpA / 30 SpD / 31 Spe
|
|
11
|
-
Bold Nature
|
|
12
|
-
- Will-O-Wisp
|
|
13
|
-
- Pain Split
|
|
14
|
-
- Sludge Bomb
|
|
15
|
-
- Fire Blast
|
|
16
|
-
|
|
17
|
-
Weezing @ Black Sludge
|
|
18
|
-
Ability: Levitate
|
|
19
|
-
EVs: 252 HP / 160 Def / 96 Spe
|
|
20
|
-
Bold Nature
|
|
21
|
-
- Sludge Bomb
|
|
22
|
-
- Will-O-Wisp
|
|
23
|
-
- Toxic Spikes
|
|
24
|
-
- Taunt
|
|
25
|
-
`;
|
package/src/tools/base64.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
class base64 {
|
|
2
|
-
static encode = function (unencoded) {
|
|
3
|
-
return new Buffer(unencoded || '').toString('base64');
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
static decode = function (encoded) {
|
|
7
|
-
return new Buffer(encoded || '', 'base64').toString('utf8');
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
static urlEncode = function (unencoded) {
|
|
12
|
-
let encoded = base64.encode(unencoded);
|
|
13
|
-
return encoded.replace('+', '-')
|
|
14
|
-
.replace('/', '_').replace(/=+$/, '');
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
static urlDecode = function (encoded) {
|
|
18
|
-
encoded = encoded.replace('-', '+').replace('_', '/');
|
|
19
|
-
while (encoded.length % 4)
|
|
20
|
-
encoded += '=';
|
|
21
|
-
return base64.decode(encoded);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default base64;
|
package/src/tools/history.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
getState() {
|
|
3
|
-
return window.location.hash.replace(/^#/, '');
|
|
4
|
-
},
|
|
5
|
-
createStateUrl(state) {
|
|
6
|
-
return window.location.origin + window.location.pathname + '#' + state;
|
|
7
|
-
},
|
|
8
|
-
pushState(state) {
|
|
9
|
-
window.history.pushState(null, null, state);
|
|
10
|
-
},
|
|
11
|
-
addListener(callback) {
|
|
12
|
-
window.addEventListener("popstate", callback, false);
|
|
13
|
-
},
|
|
14
|
-
removeListener(callback) {
|
|
15
|
-
window.removeEventListener("popstate", callback, false);
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/tools/index.js
DELETED