koffing 0.1.0 → 0.5.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.
Files changed (76) hide show
  1. package/Makefile +21 -0
  2. package/README.md +181 -4
  3. package/build/asset-manifest.json +22 -0
  4. package/build/favicon.png +0 -0
  5. package/build/index.html +1 -0
  6. package/build/precache-manifest.5382b78dea2866c8a94cee003da35d84.js +26 -0
  7. package/build/robots.txt +3 -0
  8. package/build/service-worker.js +39 -0
  9. package/build/static/css/main.102b9840.chunk.css +2 -0
  10. package/build/static/css/main.102b9840.chunk.css.map +1 -0
  11. package/build/static/js/2.4b3dd85a.chunk.js +3 -0
  12. package/build/static/js/2.4b3dd85a.chunk.js.LICENSE.txt +67 -0
  13. package/build/static/js/2.4b3dd85a.chunk.js.map +1 -0
  14. package/build/static/js/main.07f66bec.chunk.js +2 -0
  15. package/build/static/js/main.07f66bec.chunk.js.map +1 -0
  16. package/build/static/js/runtime-main.525bb0ff.js +2 -0
  17. package/build/static/js/runtime-main.525bb0ff.js.map +1 -0
  18. package/package.json +42 -30
  19. package/public/favicon.png +0 -0
  20. package/public/index.html +30 -0
  21. package/public/robots.txt +3 -0
  22. package/src/App.test.js +9 -0
  23. package/src/components/App.js +18 -0
  24. package/src/components/AppFooter/AppFooter.css.js +12 -0
  25. package/src/components/AppFooter/AppFooter.js +31 -0
  26. package/src/components/AppFooter/index.js +3 -0
  27. package/src/components/AppHeader/AppHeader.css.js +21 -0
  28. package/src/components/AppHeader/AppHeader.js +34 -0
  29. package/src/components/AppHeader/index.js +3 -0
  30. package/src/components/Board/Board.css.js +21 -0
  31. package/src/components/Board/Board.js +110 -0
  32. package/src/components/Board/index.js +3 -0
  33. package/src/components/BoardInput/BoardInput.css.js +14 -0
  34. package/src/components/BoardInput/BoardInput.js +36 -0
  35. package/src/components/BoardInput/index.js +3 -0
  36. package/src/components/BoardOutput/BoardOutput.css.js +17 -0
  37. package/src/components/BoardOutput/BoardOutput.js +36 -0
  38. package/src/components/BoardOutput/index.js +3 -0
  39. package/src/components/Code/Code.css.js +10 -0
  40. package/src/components/Code/Code.js +28 -0
  41. package/src/components/Code/index.js +3 -0
  42. package/src/components/StyledComponent.js +24 -0
  43. package/src/components/ThemedApp.js +25 -0
  44. package/src/core/Koffing.js +71 -0
  45. package/src/core/Pokemon.js +181 -0
  46. package/src/core/PokemonTeam.js +78 -0
  47. package/src/core/PokemonTeamSet.js +52 -0
  48. package/src/core/ShowdownParser.js +280 -0
  49. package/src/core/index.js +7 -0
  50. package/src/img/koffing-shiny.png +0 -0
  51. package/src/img/koffing.png +0 -0
  52. package/src/index.css +42 -0
  53. package/src/index.js +15 -53
  54. package/src/serviceWorker.js +141 -0
  55. package/src/setupTests.js +5 -0
  56. package/src/teams/example.koffing.js +25 -0
  57. package/src/tools/base64.js +25 -0
  58. package/src/tools/history.js +17 -0
  59. package/src/tools/index.js +4 -0
  60. package/src/variables.json +5 -0
  61. package/.babelrc +0 -6
  62. package/.editorconfig +0 -13
  63. package/.idea/jsLibraryMappings.xml +0 -6
  64. package/.idea/misc.xml +0 -6
  65. package/.idea/modules.xml +0 -8
  66. package/.idea/smogon-parser.iml +0 -8
  67. package/.idea/vcs.xml +0 -6
  68. package/.idea/watcherTasks.xml +0 -4
  69. package/.idea/workspace.xml +0 -792
  70. package/dist/koffing.js +0 -1
  71. package/src/Parser.js +0 -131
  72. package/src/Pokemon.js +0 -24
  73. package/src/Set.js +0 -15
  74. package/src/Team.js +0 -21
  75. package/webpack.config-docs.js +0 -30
  76. package/webpack.config.js +0 -25
package/Makefile ADDED
@@ -0,0 +1,21 @@
1
+ default:build
2
+
3
+ clean:
4
+ rm -rf ./build
5
+
6
+ build:
7
+ yarn build
8
+
9
+ audit-fix:
10
+ rm -rf package-lock.json ./node_modules
11
+ npm i --package-lock-only
12
+ npm audit fix
13
+ rm -f yarn.lock
14
+ yarn import
15
+ rm -f package-lock.json
16
+
17
+ gh-pages: build
18
+ npx gh-pages-publish
19
+
20
+ $(V).SILENT:
21
+ .PHONY: build
package/README.md CHANGED
@@ -1,10 +1,187 @@
1
1
  # Koffing
2
-
3
- Koffing is a Pokemon Showdown Team parser that converts your strategies to
2
+ Koffing is a Pokemon Showdown Team parser that converts your strategies to
4
3
  machine-readable JSON code.
5
4
 
6
- ## Usage
5
+ ![koffing](src/img/koffing.png) 🔁![koffing](src/img/koffing-shiny.png)
6
+
7
+ [Pokémon Showdown](https://www.pokemonshowdown.com/) is the most popular online Pokémon battle simulator,
8
+ one of the best ways to quickly try your strategies for the official Pokémon VGC Championships. This library is just
9
+ a parser for the teams generated by the [Showdown Team Builder](https://play.pokemonshowdown.com/teambuilder) exports.
10
+
11
+ This repository holds the source code for the library as well as the code for the Online Parser.
12
+ The [Online Parser](https://itsjavi.github.io/koffing) does not require you to download
13
+ any library or script, it is recommended if all you want is to sanitize, prettify or convert to JSON your
14
+ Showdown team exports.
15
+
16
+ ## Features
17
+
18
+ - Compatible with web browsers and NodeJS, including ES6+ imports
19
+ - Converts from Showdown code to JSON
20
+ - Converts from JSON to Showdown code
21
+ - Sanitizes Showdown code (removing invalid data, applying max and mins values, etc.)
22
+ - Prettifies Showdown code (proper indentation, line breaks and sorting of the data, etc.)
23
+ - [Online Parser](https://itsjavi.github.io/koffing), which is using the library
24
+ featuring all the above mentioned.
25
+
26
+ ## Installation
7
27
 
28
+ As a package:
8
29
  ```bash
9
30
  npm i --save koffing
10
- ```
31
+ ```
32
+
33
+ In the browser, using a CDN:
34
+ ```html
35
+ <script src="https://cdn.rawgit.com/itsjavi/koffing/0.4.0/dist/koffing.min.js"></script>
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Javascript (ES5, web)
41
+ ```html
42
+ <script src="dist/koffing.min.js"></script>
43
+ <script>
44
+ var teamCode = `=== [gen7] Folder 1/Example Team ===`;
45
+ var parsedTeam = Koffing.parse(teamCode);
46
+ console.log(parsedTeam);
47
+
48
+ // Note that the ShowdownParser class, which is used internally by the Koffing class
49
+ // is also exposed in the global scope:
50
+ console.log(new ShowdownParser(teamCode).parse());
51
+ </script>
52
+ ```
53
+
54
+ ### Javascript (ES6+, universal)
55
+ ```js
56
+ "use strict";
57
+
58
+ import {Koffing} from 'koffing';
59
+
60
+ const teamCode = `
61
+ === [gen7] Folder 1/Example Team ===
62
+
63
+ Smogon (Koffing) (F) @ Eviolite
64
+ Level: 5
65
+ Ability: Levitate
66
+ Shiny: Yes
67
+ Happiness: 255
68
+ EVs: 36 HP / 236 Def / 236 SpD
69
+ IVs: 31 HP / 30 Atk / 31 SpA / 30 SpD / 31 Spe
70
+ Bold Nature
71
+ - Will-O-Wisp
72
+ - Pain Split
73
+ - Sludge Bomb
74
+ - Fire Blast`;
75
+
76
+
77
+ let parsedTeam = Koffing.parse(teamCode);
78
+
79
+ // This will log a PokémonTeamSet object:
80
+ console.log(parsedTeam);
81
+ // Convert it back to the Showdown format (prettified):
82
+ console.log(parsedTeam.toShowdown());
83
+ // which is the same as:
84
+ console.log(parsedTeam.toString());
85
+ // and the same as:
86
+ console.log(parsedTeam + "");
87
+ // You can also convert the object to JSON:
88
+ console.log(parsedTeam.toJson());
89
+ // which is the same as:
90
+ console.log(Koffing.toJson(teamCode));
91
+ ```
92
+
93
+ ### NodeJS
94
+ ```js
95
+ const Koffing = require('koffing').Koffing;
96
+
97
+ const teamCode = `=== [gen7] Folder 1/Example Team ===`;
98
+ let parsedTeam = Koffing.parse(teamCode);
99
+ console.log(parsedTeam);
100
+ ```
101
+
102
+
103
+ ## Class Reference
104
+ The `Koffing` class is basically a wrapper of the `ShowdownParser` class, the difference is that it can be used statically.
105
+
106
+ `ShowdownParser` class methods:
107
+ - `parse(): PokemonTeamSet`: Parses the Showdown code and returns a `PokemonTeamSet` object.
108
+ - `format(): String`: Parses the Showdown code and returns a prettified and sanitized version of it.
109
+ - `toString(): String`: Basically returns the internal Showdown code string as it is.
110
+
111
+ `Koffing` class methods:
112
+ - `static parse(showdownCode): PokemonTeamSet`: Wrapper for `ShowdownParser.prototype.parse()`
113
+ - `static format(showdownCode): String`: Wrapper for `ShowdownParser.prototype.format()`
114
+ - `static toJson(showdownCode): String`: Wrapper for `ShowdownParser.prototype.parse().toJson()`
115
+ - `static toShowdown(jsonCode): String`: Wrapper for `ShowdownParser.prototype.parse().toShowdown()`
116
+
117
+
118
+ ## React App
119
+
120
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
121
+
122
+ ### Available Scripts
123
+
124
+ In the project directory, you can run:
125
+
126
+ #### `yarn start`
127
+
128
+ Runs the app in the development mode.<br />
129
+ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
130
+
131
+ The page will reload if you make edits.<br />
132
+ You will also see any lint errors in the console.
133
+
134
+ #### `yarn test`
135
+
136
+ Launches the test runner in the interactive watch mode.<br />
137
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
138
+
139
+ #### `yarn build`
140
+
141
+ Builds the app for production to the `build` folder.<br />
142
+ It correctly bundles React in production mode and optimizes the build for the best performance.
143
+
144
+ The build is minified and the filenames include the hashes.<br />
145
+ Your app is ready to be deployed!
146
+
147
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
148
+
149
+ #### `yarn eject`
150
+
151
+ **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
152
+
153
+ If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
154
+
155
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
156
+
157
+ You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
158
+
159
+ ### Learn More
160
+
161
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
162
+
163
+ To learn React, check out the [React documentation](https://reactjs.org/).
164
+
165
+
166
+ ## License
167
+
168
+ This software is copyrighted and licensed under the
169
+ [MIT license](https://github.com/itsjavi/koffing/LICENSE).
170
+
171
+ ### Disclaimer
172
+
173
+ This software comes bundled with data and graphics extracted from the
174
+ Pokémon series of video games. Some terminology from the Pokémon franchise is
175
+ also necessarily used within the software itself. This is all the intellectual
176
+ property of Nintendo, Creatures, inc., and GAME FREAK, inc. and is protected by
177
+ various copyrights and trademarks.
178
+
179
+ The authors believe that the use of this intellectual property for a fan reference
180
+ is covered by fair use and that the software is significantly impaired without said
181
+ property included. Any use of this copyrighted property is at your own legal risk.
182
+
183
+ This software is not affiliated in any way with Nintendo,
184
+ Pokémon or any other game company.
185
+
186
+ A complete revision history of this software is available from
187
+ https://github.com/itsjavi/koffing
@@ -0,0 +1,22 @@
1
+ {
2
+ "files": {
3
+ "main.css": "/koffing/static/css/main.102b9840.chunk.css",
4
+ "main.js": "/koffing/static/js/main.07f66bec.chunk.js",
5
+ "main.js.map": "/koffing/static/js/main.07f66bec.chunk.js.map",
6
+ "runtime-main.js": "/koffing/static/js/runtime-main.525bb0ff.js",
7
+ "runtime-main.js.map": "/koffing/static/js/runtime-main.525bb0ff.js.map",
8
+ "static/js/2.4b3dd85a.chunk.js": "/koffing/static/js/2.4b3dd85a.chunk.js",
9
+ "static/js/2.4b3dd85a.chunk.js.map": "/koffing/static/js/2.4b3dd85a.chunk.js.map",
10
+ "index.html": "/koffing/index.html",
11
+ "precache-manifest.5382b78dea2866c8a94cee003da35d84.js": "/koffing/precache-manifest.5382b78dea2866c8a94cee003da35d84.js",
12
+ "service-worker.js": "/koffing/service-worker.js",
13
+ "static/css/main.102b9840.chunk.css.map": "/koffing/static/css/main.102b9840.chunk.css.map",
14
+ "static/js/2.4b3dd85a.chunk.js.LICENSE.txt": "/koffing/static/js/2.4b3dd85a.chunk.js.LICENSE.txt"
15
+ },
16
+ "entrypoints": [
17
+ "static/js/runtime-main.525bb0ff.js",
18
+ "static/js/2.4b3dd85a.chunk.js",
19
+ "static/css/main.102b9840.chunk.css",
20
+ "static/js/main.07f66bec.chunk.js"
21
+ ]
22
+ }
Binary file
@@ -0,0 +1 @@
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Koffing - Pokemon Showdown Team parser | Online Pokemon Showdown Team parser</title><link rel="shortcut icon" type="image/png" href="/koffing/favicon.png"/><script async src="https://www.googletagmanager.com/gtag/js?id=UA-85082661-2"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-85082661-2")</script><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Exo+2:300,400,500"><link href="https://use.fontawesome.com/releases/v5.14.0/css/all.css" rel="stylesheet"><link href="/koffing/static/css/main.102b9840.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript and a modern browser to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,i=r[0],l=r[1],a=r[2],c=0,s=[];c<i.length;c++)f=i[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var l=t[i];0!==o[l]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/koffing/";var i=this.webpackJsonpkoffing=this.webpackJsonpkoffing||[],l=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var p=l;t()}([])</script><script src="/koffing/static/js/2.4b3dd85a.chunk.js"></script><script src="/koffing/static/js/main.07f66bec.chunk.js"></script></body></html>
@@ -0,0 +1,26 @@
1
+ self.__precacheManifest = (self.__precacheManifest || []).concat([
2
+ {
3
+ "revision": "98f25614ba5fe5e04f1e0233a92a26c7",
4
+ "url": "/koffing/index.html"
5
+ },
6
+ {
7
+ "revision": "c500eb4a5760ca0bb4bc",
8
+ "url": "/koffing/static/css/main.102b9840.chunk.css"
9
+ },
10
+ {
11
+ "revision": "a3524f4864f51e0ac239",
12
+ "url": "/koffing/static/js/2.4b3dd85a.chunk.js"
13
+ },
14
+ {
15
+ "revision": "3f0e7270d9361d86cdedbbc2d6ca185f",
16
+ "url": "/koffing/static/js/2.4b3dd85a.chunk.js.LICENSE.txt"
17
+ },
18
+ {
19
+ "revision": "c500eb4a5760ca0bb4bc",
20
+ "url": "/koffing/static/js/main.07f66bec.chunk.js"
21
+ },
22
+ {
23
+ "revision": "95c593fd36946693659b",
24
+ "url": "/koffing/static/js/runtime-main.525bb0ff.js"
25
+ }
26
+ ]);
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Welcome to your Workbox-powered service worker!
3
+ *
4
+ * You'll need to register this file in your web app and you should
5
+ * disable HTTP caching for this file too.
6
+ * See https://goo.gl/nhQhGp
7
+ *
8
+ * The rest of the code is auto-generated. Please don't update this file
9
+ * directly; instead, make changes to your Workbox build configuration
10
+ * and re-run your build process.
11
+ * See https://goo.gl/2aRDsh
12
+ */
13
+
14
+ importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15
+
16
+ importScripts(
17
+ "/koffing/precache-manifest.5382b78dea2866c8a94cee003da35d84.js"
18
+ );
19
+
20
+ self.addEventListener('message', (event) => {
21
+ if (event.data && event.data.type === 'SKIP_WAITING') {
22
+ self.skipWaiting();
23
+ }
24
+ });
25
+
26
+ workbox.core.clientsClaim();
27
+
28
+ /**
29
+ * The workboxSW.precacheAndRoute() method efficiently caches and responds to
30
+ * requests for URLs in the manifest.
31
+ * See https://goo.gl/S9QRab
32
+ */
33
+ self.__precacheManifest = [].concat(self.__precacheManifest || []);
34
+ workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
35
+
36
+ workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/koffing/index.html"), {
37
+
38
+ blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
39
+ });
@@ -0,0 +1,2 @@
1
+ html{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,:after,:before{box-sizing:inherit}body{margin:0;background-color:#fafafa}@media print{body{background-color:#fff}}a{color:#6b71b8}.koffing-sprite{-webkit-animation-name:koffing-animation;animation-name:koffing-animation;-webkit-animation-duration:.7s;animation-duration:.7s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-direction:alternate;animation-direction:alternate;-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}@-webkit-keyframes koffing-animation{0%{-webkit-transform:translate(0);transform:translate(0)}to{-webkit-transform:translate(-2px,-3px);transform:translate(-2px,-3px)}}@keyframes koffing-animation{0%{-webkit-transform:translate(0);transform:translate(0)}to{-webkit-transform:translate(-2px,-3px);transform:translate(-2px,-3px)}}
2
+ /*# sourceMappingURL=main.102b9840.chunk.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.css"],"names":[],"mappings":"AAAA,KACE,qBAAsB,CACtB,kCAAmC,CACnC,iCACF,CAEA,iBACE,kBACF,CAEA,KACE,QAAS,CACT,wBACF,CAEA,aACE,KACE,qBACF,CACF,CAEA,EACE,aACF,CAEA,gBACE,wCAAiC,CAAjC,gCAAiC,CACjC,8BAAyB,CAAzB,sBAAyB,CACzB,0CAAmC,CAAnC,kCAAmC,CACnC,qCAA8B,CAA9B,6BAA8B,CAC9B,6CAAsC,CAAtC,qCACF,CAGA,qCACE,GACE,8BAA8B,CAA9B,sBACF,CACA,GACE,sCAAgC,CAAhC,8BACF,CACF,CAPA,6BACE,GACE,8BAA8B,CAA9B,sBACF,CACA,GACE,sCAAgC,CAAhC,8BACF,CACF","file":"main.102b9840.chunk.css","sourcesContent":["html {\n box-sizing: border-box;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n*, *::before, *::after {\n box-sizing: inherit;\n}\n\nbody {\n margin: 0;\n background-color: #fafafa;\n}\n\n@media print {\n body {\n background-color: #fff;\n }\n}\n\na {\n color: #6B71B8;\n}\n\n.koffing-sprite {\n animation-name: koffing-animation;\n animation-duration: 700ms;\n animation-iteration-count: infinite;\n animation-direction: alternate;\n animation-timing-function: ease-in-out;\n}\n\n/* Standard syntax */\n@keyframes koffing-animation {\n 0% {\n transform: translate(0px, 0px);\n }\n 100% {\n transform: translate(-2px, -3px);\n }\n}\n"]}