pacman-contribution-graph 1.0.2 → 1.0.3
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/dist/pacman-contribution-graph.js +40 -20
- package/dist/pacman-contribution-graph.js.map +1 -1
- package/dist/pacman-contribution-graph.min.js +1 -1
- package/embeded/canvas.html +1 -1
- package/github-action/action.yml +16 -0
- package/github-action/dist/index.js +26899 -0
- package/github-action/package.json +14 -0
- package/github-action/pnpm-lock.yaml +146 -0
- package/github-action/src/index.js +45 -0
- package/index.html +61 -19
- package/package.json +4 -2
- package/src/game.ts +6 -8
- package/src/index.ts +2 -2
- package/src/music-player.ts +4 -4
- package/src/svg.ts +1 -0
- package/src/types.ts +3 -0
- package/src/utils.ts +28 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pacman-contribution-graph/action",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "ncc build src/index.js -o dist --external canvas"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@actions/core": "1.10.1",
|
|
9
|
+
"pacman-contribution-graph": "^1.0.2"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@vercel/ncc": "^0.38.3"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
lockfileVersion: '9.0'
|
|
2
|
+
|
|
3
|
+
settings:
|
|
4
|
+
autoInstallPeers: true
|
|
5
|
+
excludeLinksFromLockfile: false
|
|
6
|
+
|
|
7
|
+
importers:
|
|
8
|
+
|
|
9
|
+
.:
|
|
10
|
+
dependencies:
|
|
11
|
+
'@actions/core':
|
|
12
|
+
specifier: 1.10.1
|
|
13
|
+
version: 1.10.1
|
|
14
|
+
pacman-contribution-graph:
|
|
15
|
+
specifier: ^1.0.2
|
|
16
|
+
version: 1.0.2
|
|
17
|
+
devDependencies:
|
|
18
|
+
'@vercel/ncc':
|
|
19
|
+
specifier: ^0.38.3
|
|
20
|
+
version: 0.38.3
|
|
21
|
+
|
|
22
|
+
packages:
|
|
23
|
+
|
|
24
|
+
'@actions/core@1.10.1':
|
|
25
|
+
resolution: {integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==}
|
|
26
|
+
|
|
27
|
+
'@actions/http-client@2.2.3':
|
|
28
|
+
resolution: {integrity: sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==}
|
|
29
|
+
|
|
30
|
+
'@fastify/busboy@2.1.1':
|
|
31
|
+
resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==}
|
|
32
|
+
engines: {node: '>=14'}
|
|
33
|
+
|
|
34
|
+
'@vercel/ncc@0.38.3':
|
|
35
|
+
resolution: {integrity: sha512-rnK6hJBS6mwc+Bkab+PGPs9OiS0i/3kdTO+CkI8V0/VrW3vmz7O2Pxjw/owOlmo6PKEIxRSeZKv/kuL9itnpYA==}
|
|
36
|
+
hasBin: true
|
|
37
|
+
|
|
38
|
+
clone-deep@4.0.1:
|
|
39
|
+
resolution: {integrity: sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==}
|
|
40
|
+
engines: {node: '>=6'}
|
|
41
|
+
|
|
42
|
+
flat@5.0.2:
|
|
43
|
+
resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==}
|
|
44
|
+
hasBin: true
|
|
45
|
+
|
|
46
|
+
is-plain-object@2.0.4:
|
|
47
|
+
resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==}
|
|
48
|
+
engines: {node: '>=0.10.0'}
|
|
49
|
+
|
|
50
|
+
isobject@3.0.1:
|
|
51
|
+
resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==}
|
|
52
|
+
engines: {node: '>=0.10.0'}
|
|
53
|
+
|
|
54
|
+
kind-of@6.0.3:
|
|
55
|
+
resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==}
|
|
56
|
+
engines: {node: '>=0.10.0'}
|
|
57
|
+
|
|
58
|
+
pacman-contribution-graph@1.0.2:
|
|
59
|
+
resolution: {integrity: sha512-6PS9pYAEsUiNSXMZaRc0rYOpciGM4OJ8E45Q2cMA1fRbzkKxO8UChvfHJ0cDCT4SE3j/h5KMQWAS884OKY4a2w==}
|
|
60
|
+
|
|
61
|
+
prettier@3.4.2:
|
|
62
|
+
resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==}
|
|
63
|
+
engines: {node: '>=14'}
|
|
64
|
+
hasBin: true
|
|
65
|
+
|
|
66
|
+
shallow-clone@3.0.1:
|
|
67
|
+
resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==}
|
|
68
|
+
engines: {node: '>=8'}
|
|
69
|
+
|
|
70
|
+
tunnel@0.0.6:
|
|
71
|
+
resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==}
|
|
72
|
+
engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'}
|
|
73
|
+
|
|
74
|
+
undici@5.28.5:
|
|
75
|
+
resolution: {integrity: sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==}
|
|
76
|
+
engines: {node: '>=14.0'}
|
|
77
|
+
|
|
78
|
+
uuid@8.3.2:
|
|
79
|
+
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
|
80
|
+
hasBin: true
|
|
81
|
+
|
|
82
|
+
webpack-merge@6.0.1:
|
|
83
|
+
resolution: {integrity: sha512-hXXvrjtx2PLYx4qruKl+kyRSLc52V+cCvMxRjmKwoA+CBbbF5GfIBtR6kCvl0fYGqTUPKB+1ktVmTHqMOzgCBg==}
|
|
84
|
+
engines: {node: '>=18.0.0'}
|
|
85
|
+
|
|
86
|
+
wildcard@2.0.1:
|
|
87
|
+
resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==}
|
|
88
|
+
|
|
89
|
+
snapshots:
|
|
90
|
+
|
|
91
|
+
'@actions/core@1.10.1':
|
|
92
|
+
dependencies:
|
|
93
|
+
'@actions/http-client': 2.2.3
|
|
94
|
+
uuid: 8.3.2
|
|
95
|
+
|
|
96
|
+
'@actions/http-client@2.2.3':
|
|
97
|
+
dependencies:
|
|
98
|
+
tunnel: 0.0.6
|
|
99
|
+
undici: 5.28.5
|
|
100
|
+
|
|
101
|
+
'@fastify/busboy@2.1.1': {}
|
|
102
|
+
|
|
103
|
+
'@vercel/ncc@0.38.3': {}
|
|
104
|
+
|
|
105
|
+
clone-deep@4.0.1:
|
|
106
|
+
dependencies:
|
|
107
|
+
is-plain-object: 2.0.4
|
|
108
|
+
kind-of: 6.0.3
|
|
109
|
+
shallow-clone: 3.0.1
|
|
110
|
+
|
|
111
|
+
flat@5.0.2: {}
|
|
112
|
+
|
|
113
|
+
is-plain-object@2.0.4:
|
|
114
|
+
dependencies:
|
|
115
|
+
isobject: 3.0.1
|
|
116
|
+
|
|
117
|
+
isobject@3.0.1: {}
|
|
118
|
+
|
|
119
|
+
kind-of@6.0.3: {}
|
|
120
|
+
|
|
121
|
+
pacman-contribution-graph@1.0.2:
|
|
122
|
+
dependencies:
|
|
123
|
+
prettier: 3.4.2
|
|
124
|
+
webpack-merge: 6.0.1
|
|
125
|
+
|
|
126
|
+
prettier@3.4.2: {}
|
|
127
|
+
|
|
128
|
+
shallow-clone@3.0.1:
|
|
129
|
+
dependencies:
|
|
130
|
+
kind-of: 6.0.3
|
|
131
|
+
|
|
132
|
+
tunnel@0.0.6: {}
|
|
133
|
+
|
|
134
|
+
undici@5.28.5:
|
|
135
|
+
dependencies:
|
|
136
|
+
'@fastify/busboy': 2.1.1
|
|
137
|
+
|
|
138
|
+
uuid@8.3.2: {}
|
|
139
|
+
|
|
140
|
+
webpack-merge@6.0.1:
|
|
141
|
+
dependencies:
|
|
142
|
+
clone-deep: 4.0.1
|
|
143
|
+
flat: 5.0.2
|
|
144
|
+
wildcard: 2.0.1
|
|
145
|
+
|
|
146
|
+
wildcard@2.0.1: {}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as core from '@actions/core';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { PacmanRenderer } from 'pacman-contribution-graph';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
|
|
6
|
+
const generateSvg = async (userName, githubToken,) => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const conf = {
|
|
9
|
+
platform: "github",
|
|
10
|
+
username: userName,
|
|
11
|
+
outputFormat: "svg",
|
|
12
|
+
gameSpeed: 1,
|
|
13
|
+
gameTheme: theme,
|
|
14
|
+
githubSettings: {
|
|
15
|
+
accessToken: githubToken
|
|
16
|
+
},
|
|
17
|
+
svgCallback: (animatedSVG) => {
|
|
18
|
+
resolve(animatedSVG);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const pr = new PacmanRenderer(conf)
|
|
23
|
+
pr.start()
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
(async () => {
|
|
28
|
+
try {
|
|
29
|
+
let svgContent = ''
|
|
30
|
+
const userName = core.getInput('github_user_name');
|
|
31
|
+
const githubToken = core.getInput('github_token');
|
|
32
|
+
|
|
33
|
+
svgContent = await generateSvg(userName, githubToken, "github")
|
|
34
|
+
console.log(`💾 writing to dist/pacman-contribution-graph.svg`);
|
|
35
|
+
fs.mkdirSync(path.dirname('dist/pacman-contribution-graph.svg'), { recursive: true });
|
|
36
|
+
fs.writeFileSync('dist/pacman-contribution-graph.svg', svgContent);
|
|
37
|
+
|
|
38
|
+
svgContent = await generateSvg(userName, githubToken, "github-dark")
|
|
39
|
+
console.log(`💾 writing to dist/pacman-contribution-graph-dark.svg`);
|
|
40
|
+
fs.mkdirSync(path.dirname('dist/pacman-contribution-graph-dark.svg'), { recursive: true });
|
|
41
|
+
fs.writeFileSync('dist/pacman-contribution-graph-dark.svg', svgContent);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
core.setFailed(`Action failed with "${e.message}"`);
|
|
44
|
+
}
|
|
45
|
+
})();
|
package/index.html
CHANGED
|
@@ -102,6 +102,8 @@
|
|
|
102
102
|
<option value="gitlab">GitLab</option>
|
|
103
103
|
</select>
|
|
104
104
|
</div>
|
|
105
|
+
</div>
|
|
106
|
+
<div class="col-md-6">
|
|
105
107
|
<div class="mb-3">
|
|
106
108
|
<label for="output" class="form-label">Output format</label>
|
|
107
109
|
<select id="output" class="form-select">
|
|
@@ -109,6 +111,10 @@
|
|
|
109
111
|
<option value="svg">SVG</option>
|
|
110
112
|
</select>
|
|
111
113
|
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="row">
|
|
117
|
+
<div class="col-md-6">
|
|
112
118
|
<div class="mb-3">
|
|
113
119
|
<label for="username" class="form-label">Username:</label>
|
|
114
120
|
<div class="input-group">
|
|
@@ -125,11 +131,6 @@
|
|
|
125
131
|
</div>
|
|
126
132
|
</div>
|
|
127
133
|
<div class="col-md-6">
|
|
128
|
-
<div class="mb-3">
|
|
129
|
-
<label for="gameSpeed" class="form-label">Game Speed:</label>
|
|
130
|
-
<input type="range" class="form-range" id="gameSpeed" min="1" max="10" value="1" />
|
|
131
|
-
<span id="gameSpeedValue">1</span>
|
|
132
|
-
</div>
|
|
133
134
|
<div class="mb-3">
|
|
134
135
|
<label for="theme" class="form-label">Theme:</label>
|
|
135
136
|
<select id="theme" class="form-select">
|
|
@@ -139,16 +140,50 @@
|
|
|
139
140
|
<option value="gitlab-dark">GitLab Dark</option>
|
|
140
141
|
</select>
|
|
141
142
|
</div>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
<div class="mb-5">
|
|
146
|
+
<button class="btn btn-secondary mb-1" data-bs-toggle="collapse" data-bs-target="#additionalSettings">
|
|
147
|
+
Toggle Additional Settings
|
|
148
|
+
</button>
|
|
149
|
+
<div id="additionalSettings" class="collapse">
|
|
150
|
+
<div class="row">
|
|
151
|
+
<div class="col-md-6">
|
|
152
|
+
<div class="mb-3">
|
|
153
|
+
<label for="enableSounds" class="form-label">Sounds:</label>
|
|
154
|
+
<select id="enableSounds" class="form-select">
|
|
155
|
+
<option value="disabled">Disabled</option>
|
|
156
|
+
<option value="enabled">Enabled</option>
|
|
157
|
+
</select>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="col-md-6">
|
|
161
|
+
<div class="mb-3">
|
|
162
|
+
<label for="gameSpeed" class="form-label">Game Speed:</label>
|
|
163
|
+
<input type="range" class="form-range" id="gameSpeed" min="1" max="10" value="1" />
|
|
164
|
+
<span id="gameSpeedValue">1</span>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
<div class="row">
|
|
169
|
+
<div class="col-md-6">
|
|
170
|
+
<div class="mb-3">
|
|
171
|
+
<label for="githubAccessToken" class="form-label"
|
|
172
|
+
>Github Access Token(<a target="__blank" href="https://github.com/settings/tokens">Generate one</a
|
|
173
|
+
>):
|
|
174
|
+
</label>
|
|
175
|
+
<input
|
|
176
|
+
type="text"
|
|
177
|
+
id="githubAccessToken"
|
|
178
|
+
class="form-control"
|
|
179
|
+
placeholder="Enter Github Access Token"
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
148
183
|
</div>
|
|
149
184
|
</div>
|
|
150
185
|
</div>
|
|
151
|
-
<button id="generate" class="btn btn-primary">Generate</button>
|
|
186
|
+
<button id="generate" class="btn btn-primary">Generate</button> It might take a second or two
|
|
152
187
|
</div>
|
|
153
188
|
|
|
154
189
|
<div class="section">
|
|
@@ -191,7 +226,7 @@
|
|
|
191
226
|
<tr>
|
|
192
227
|
<td><code>svgCallback</code></td>
|
|
193
228
|
<td>A callback function that will get called when SVG picture is generated</td>
|
|
194
|
-
<td><code>(
|
|
229
|
+
<td><code>(animatedSVG: string) => void</code></td>
|
|
195
230
|
</tr>
|
|
196
231
|
<tr>
|
|
197
232
|
<td><code>gameOverCallback</code></td>
|
|
@@ -241,7 +276,7 @@ pr.start();
|
|
|
241
276
|
|
|
242
277
|
<h3>Method 2: Script loading</h3>
|
|
243
278
|
<pre><code><script type="module">
|
|
244
|
-
import { PacmanRenderer } from 'https://cdn.jsdelivr.net/
|
|
279
|
+
import { PacmanRenderer } from 'https://cdn.jsdelivr.net/npm/pacman-contribution-graph/dist/pacman-contribution-graph.min.js';
|
|
245
280
|
const pr = new PacmanRenderer({
|
|
246
281
|
platform: 'github',
|
|
247
282
|
username: 'yourusername',
|
|
@@ -293,6 +328,7 @@ pr.start();
|
|
|
293
328
|
const userAvatar = document.getElementById('userAvatar');
|
|
294
329
|
const userNotFound = document.getElementById('userNotFound');
|
|
295
330
|
const points = document.getElementById('points');
|
|
331
|
+
const githubAccessToken = document.getElementById('githubAccessToken');
|
|
296
332
|
|
|
297
333
|
generateButton.disabled = true;
|
|
298
334
|
|
|
@@ -376,7 +412,10 @@ pr.start();
|
|
|
376
412
|
outputFormat: outputSelect.value,
|
|
377
413
|
gameSpeed: parseInt(gameSpeedInput.value),
|
|
378
414
|
gameTheme: themeSelect.value,
|
|
379
|
-
enableSounds: enableSounds.value === 'enabled'
|
|
415
|
+
enableSounds: enableSounds.value === 'enabled',
|
|
416
|
+
githubSettings: {
|
|
417
|
+
accessToken: githubAccessToken.value
|
|
418
|
+
}
|
|
380
419
|
};
|
|
381
420
|
|
|
382
421
|
if (config.outputFormat === 'canvas') {
|
|
@@ -391,7 +430,6 @@ pr.start();
|
|
|
391
430
|
canvas: canvas,
|
|
392
431
|
gameOverCallback: () => {
|
|
393
432
|
console.log('Game Over');
|
|
394
|
-
setTimeout(() => pr.start(), 3000);
|
|
395
433
|
},
|
|
396
434
|
pointsIncreasedCallback: (pointsSum) => {
|
|
397
435
|
points.innerText = pointsSum;
|
|
@@ -407,9 +445,13 @@ pr.start();
|
|
|
407
445
|
}
|
|
408
446
|
pr = new PacmanRenderer({
|
|
409
447
|
...config,
|
|
410
|
-
svgCallback: (
|
|
411
|
-
|
|
412
|
-
|
|
448
|
+
svgCallback: (animatedSVG) => {
|
|
449
|
+
const svgBlob = new Blob([animatedSVG], {
|
|
450
|
+
type: 'image/svg+xml;charset=utf-8'
|
|
451
|
+
});
|
|
452
|
+
const svgUrl = URL.createObjectURL(svgBlob);
|
|
453
|
+
svgHolder.src = svgUrl;
|
|
454
|
+
currentSvgBlob = svgUrl;
|
|
413
455
|
},
|
|
414
456
|
gameOverCallback: () => {
|
|
415
457
|
console.log('Game Over');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacman-contribution-graph",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Generates a pacman game from a github or gitlab user contributions grid",
|
|
5
5
|
"repository": "github:abozanona/pacman-contribution-graph",
|
|
6
6
|
"homepage": "https://abozanona.github.io/pacman-contribution-graph/",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"main": "dist/pacman-contribution-graph.min.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "webpack --config webpack.prod.js",
|
|
11
|
-
"dev": "webpack --progress --config webpack.dev.js"
|
|
11
|
+
"dev": "webpack --progress --config webpack.dev.js",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"build-action": "pnpm run --prefix ./github-action build"
|
|
12
14
|
},
|
|
13
15
|
"devDependencies": {
|
|
14
16
|
"terser": "^5.37.0",
|
package/src/game.ts
CHANGED
|
@@ -114,8 +114,11 @@ const startGame = async (store: StoreType) => {
|
|
|
114
114
|
await MusicPlayer.getInstance().play(Sound.BEGINNING);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
const remainingCells = () => store.grid.some((row) => row.some((cell) => cell.intensity > 0));
|
|
118
|
+
if (remainingCells()) {
|
|
119
|
+
placePacman(store);
|
|
120
|
+
placeGhosts(store);
|
|
121
|
+
}
|
|
119
122
|
|
|
120
123
|
GHOSTS.blinky.img.src = GHOSTS.blinky.imgDate;
|
|
121
124
|
GHOSTS.clyde.img.src = GHOSTS.clyde.imgDate;
|
|
@@ -124,7 +127,6 @@ const startGame = async (store: StoreType) => {
|
|
|
124
127
|
GHOSTS.scared.img.src = GHOSTS.scared.imgDate;
|
|
125
128
|
|
|
126
129
|
if (store.config.outputFormat == 'svg') {
|
|
127
|
-
const remainingCells = () => store.grid.some((row) => row.some((cell) => cell.intensity > 0));
|
|
128
130
|
while (remainingCells()) {
|
|
129
131
|
await updateGame(store);
|
|
130
132
|
}
|
|
@@ -180,11 +182,7 @@ const updateGame = async (store: StoreType) => {
|
|
|
180
182
|
|
|
181
183
|
if (store.config.outputFormat == 'svg') {
|
|
182
184
|
const animatedSVG = SVG.generateAnimatedSVG(store);
|
|
183
|
-
|
|
184
|
-
type: 'image/svg+xml;charset=utf-8'
|
|
185
|
-
});
|
|
186
|
-
const svgUrl = URL.createObjectURL(svgBlob);
|
|
187
|
-
store.config.svgCallback(svgUrl);
|
|
185
|
+
store.config.svgCallback(animatedSVG);
|
|
188
186
|
}
|
|
189
187
|
|
|
190
188
|
store.config.gameOverCallback();
|
package/src/index.ts
CHANGED
|
@@ -29,11 +29,11 @@ export class PacmanRenderer {
|
|
|
29
29
|
|
|
30
30
|
switch (this.conf.platform) {
|
|
31
31
|
case 'gitlab':
|
|
32
|
-
this.store.contributions = await Utils.getGitlabContribution(this.
|
|
32
|
+
this.store.contributions = await Utils.getGitlabContribution(this.store);
|
|
33
33
|
break;
|
|
34
34
|
|
|
35
35
|
case 'github':
|
|
36
|
-
this.store.contributions = await Utils.getGithubContribution(this.
|
|
36
|
+
this.store.contributions = await Utils.getGithubContribution(this.store);
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
39
|
|
package/src/music-player.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export enum Sound {
|
|
2
|
-
DEFAULT = 'https://cdn.jsdelivr.net/
|
|
3
|
-
BEGINNING = 'https://cdn.jsdelivr.net/
|
|
4
|
-
GAME_OVER = 'https://cdn.jsdelivr.net/
|
|
5
|
-
EAT_GHOST = 'https://cdn.jsdelivr.net/
|
|
2
|
+
DEFAULT = 'https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_chomp.wav',
|
|
3
|
+
BEGINNING = 'https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_beginning.wav',
|
|
4
|
+
GAME_OVER = 'https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_death.wav',
|
|
5
|
+
EAT_GHOST = 'https://cdn.jsdelivr.net/npm/pacman-contribution-graph/src/assets/sounds/pacman_eatghost.wav'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export class MusicPlayer {
|
package/src/svg.ts
CHANGED
|
@@ -6,6 +6,7 @@ const generateAnimatedSVG = (store: StoreType) => {
|
|
|
6
6
|
const svgWidth = GRID_WIDTH * (CELL_SIZE + GAP_SIZE);
|
|
7
7
|
const svgHeight = GRID_HEIGHT * (CELL_SIZE + GAP_SIZE) + 20;
|
|
8
8
|
let svg = `<svg width="${svgWidth}" height="${svgHeight}" xmlns="http://www.w3.org/2000/svg">`;
|
|
9
|
+
svg += `<desc>Generated with https://github.com/abozanona/pacman-contribution-graph</desc>`;
|
|
9
10
|
svg += `<rect width="100%" height="100%" fill="${Utils.getCurrentTheme(store).gridBackground}"/>`;
|
|
10
11
|
|
|
11
12
|
svg += generateGhostsPredefinition();
|
package/src/types.ts
CHANGED
|
@@ -51,6 +51,9 @@ export interface Config {
|
|
|
51
51
|
gameSpeed: number;
|
|
52
52
|
enableSounds: boolean;
|
|
53
53
|
pointsIncreasedCallback: (pointsSum: number) => void;
|
|
54
|
+
githubSettings?: {
|
|
55
|
+
accessToken: string;
|
|
56
|
+
};
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export type ThemeKeys = 'github' | 'github-dark' | 'gitlab' | 'gitlab-dark';
|
package/src/utils.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GAME_THEMES } from './constants';
|
|
2
2
|
import type { Contribution, GameTheme, StoreType } from './types';
|
|
3
3
|
|
|
4
|
-
const getGitlabContribution = async (
|
|
4
|
+
const getGitlabContribution = async (store: StoreType): Promise<Contribution[]> => {
|
|
5
5
|
// const response = await fetch(`https://gitlab.com/users/${username}/calendar.json`);
|
|
6
6
|
const response = await fetch(
|
|
7
|
-
`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${username}`
|
|
7
|
+
`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}`
|
|
8
8
|
);
|
|
9
9
|
const contributionsList = await response.json();
|
|
10
10
|
return Object.entries(contributionsList).map(([date, count]) => ({
|
|
@@ -13,13 +13,33 @@ const getGitlabContribution = async (username: string): Promise<Contribution[]>
|
|
|
13
13
|
}));
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const getGithubContribution = async (
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const getGithubContribution = async (store: StoreType): Promise<Contribution[]> => {
|
|
17
|
+
const commits = [];
|
|
18
|
+
let isComplete: boolean = false;
|
|
19
|
+
let page = 1;
|
|
20
|
+
// TODO: Consider using GraphQL endpoint when user has an access token?
|
|
21
|
+
do {
|
|
22
|
+
try {
|
|
23
|
+
const headers: HeadersInit = {};
|
|
24
|
+
if (store.config.githubSettings?.accessToken) {
|
|
25
|
+
headers['Authorization'] = 'Bearer ' + store.config.githubSettings.accessToken;
|
|
26
|
+
}
|
|
27
|
+
const response = await fetch(
|
|
28
|
+
`https://api.github.com/search/commits?q=author:${store.config.username}&sort=author-date&order=desc&page=${page}&per_page=1000`,
|
|
29
|
+
{
|
|
30
|
+
headers
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
const contributionsList = await response.json();
|
|
34
|
+
isComplete = contributionsList.items.length === 0;
|
|
35
|
+
commits.push(...contributionsList.items);
|
|
36
|
+
page++;
|
|
37
|
+
} catch (ex) {
|
|
38
|
+
isComplete = true;
|
|
39
|
+
}
|
|
40
|
+
} while (!isComplete);
|
|
21
41
|
return Array.from(
|
|
22
|
-
|
|
42
|
+
commits
|
|
23
43
|
.reduce((map: any, item: any) => {
|
|
24
44
|
const dateString = item.commit.committer.date.split('T')[0];
|
|
25
45
|
const date = new Date(dateString);
|