arcadible 0.1.21 → 0.1.23
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/bin/arc-login.js +2 -2
- package/package.json +1 -1
- package/src/action/inspect/media.js +2 -12
- package/src/action/login/flow.js +6 -6
- package/src/action/pack/tool.js +4 -3
- package/src/config/art.js +16 -0
- package/src/config/image.js +8 -0
- package/src/config/video.js +7 -0
- package/src/parser/media.js +6 -13
- package/src/schema/game.js +12 -11
- package/src/util/image.js +17 -8
- package/src/util/video.js +13 -6
package/bin/arc-login.js
CHANGED
|
@@ -68,9 +68,9 @@ const onLoginEnter = function (fn) {
|
|
|
68
68
|
|
|
69
69
|
const handler = function ({ browser, qrcode: qr, sw }) {
|
|
70
70
|
return {
|
|
71
|
-
onLoginCreated({ code: dac,
|
|
71
|
+
onLoginCreated({ code: dac, secret, url }) {
|
|
72
72
|
sw.stop(true);
|
|
73
|
-
const link = `${url}/${
|
|
73
|
+
const link = `${url}/${secret}`;
|
|
74
74
|
log.p("Logging in...");
|
|
75
75
|
qrcode.generate(link, { small: true }, (code) => {
|
|
76
76
|
if (qr) {
|
package/package.json
CHANGED
|
@@ -2,22 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
+
const cfgart = require("../../config/art");
|
|
5
6
|
const cfgproduct = require("../../config/product");
|
|
6
7
|
|
|
7
8
|
// [declare]
|
|
8
9
|
|
|
9
|
-
const ART = [
|
|
10
|
-
"banner",
|
|
11
|
-
"banner_video",
|
|
12
|
-
"cover",
|
|
13
|
-
"cover_video",
|
|
14
|
-
"icon",
|
|
15
|
-
"icon_video",
|
|
16
|
-
"poster",
|
|
17
|
-
"poster_video",
|
|
18
|
-
"wordmark",
|
|
19
|
-
"wordmark_animated",
|
|
20
|
-
];
|
|
10
|
+
const ART = cfgart.map((file) => file.split(".")[0]);
|
|
21
11
|
|
|
22
12
|
// [declare]
|
|
23
13
|
|
package/src/action/login/flow.js
CHANGED
|
@@ -20,10 +20,10 @@ const randomUUID = crypto.randomUUID;
|
|
|
20
20
|
// [declare]
|
|
21
21
|
|
|
22
22
|
const POLL = {
|
|
23
|
-
delay: time.s(
|
|
24
|
-
factor:
|
|
25
|
-
interval: time.s(
|
|
26
|
-
maxDelay: time.s(
|
|
23
|
+
delay: time.s(1.5),
|
|
24
|
+
factor: 1.5,
|
|
25
|
+
interval: time.s(15),
|
|
26
|
+
maxDelay: time.s(5),
|
|
27
27
|
timeoutError: phrase.loginExpired(),
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -48,7 +48,7 @@ const flow = function ({ id, secret: token }) {
|
|
|
48
48
|
const createFlow = function ({ expiresAt, secret, type }, onLoginCreated) {
|
|
49
49
|
return postFlow({ expiresAt, secret, type }).then(({ code, id }) => {
|
|
50
50
|
if (onLoginCreated) {
|
|
51
|
-
onLoginCreated({ code,
|
|
51
|
+
onLoginCreated({ code, secret, url: cfgurl.LINK });
|
|
52
52
|
}
|
|
53
53
|
return { id };
|
|
54
54
|
});
|
|
@@ -77,7 +77,7 @@ const pollFlow = function (value, onLoginPoll) {
|
|
|
77
77
|
// [function]
|
|
78
78
|
|
|
79
79
|
const main = function ({ onLoginCreated, onLoginPoll }) {
|
|
80
|
-
const expiresAt = new Date(Date.now() + time.m(
|
|
80
|
+
const expiresAt = new Date(Date.now() + time.m(10));
|
|
81
81
|
const secret = randomUUID();
|
|
82
82
|
return createFlow(
|
|
83
83
|
{
|
package/src/action/pack/tool.js
CHANGED
|
@@ -68,10 +68,11 @@ const pack = function (name, game, { inputPath, mediaPath, outputPath }) {
|
|
|
68
68
|
const zip = new Zip(name);
|
|
69
69
|
return pathExists(inputPath)
|
|
70
70
|
.then((existsInput) => {
|
|
71
|
-
if (existsInput) {
|
|
72
|
-
|
|
71
|
+
if (!existsInput) {
|
|
72
|
+
throw new Error(phrase.unableToFind(inputPath));
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
zip.addDir(inputPath);
|
|
75
|
+
return zip;
|
|
75
76
|
})
|
|
76
77
|
.then(verifyPartial)
|
|
77
78
|
.then(() => pathExists(mediaPath))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [export]
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
"banner.png",
|
|
7
|
+
"banner_video.mp4",
|
|
8
|
+
"cover.png",
|
|
9
|
+
"cover_video.mp4",
|
|
10
|
+
"icon.png",
|
|
11
|
+
"icon_video.mp4",
|
|
12
|
+
"poster.png",
|
|
13
|
+
"poster_video.mp4",
|
|
14
|
+
"wordmark.svg",
|
|
15
|
+
"wordmark_animated.svg",
|
|
16
|
+
];
|
package/src/parser/media.js
CHANGED
|
@@ -10,7 +10,10 @@ const fs = require("fs-extra");
|
|
|
10
10
|
|
|
11
11
|
// [import]
|
|
12
12
|
|
|
13
|
+
const cfgart = require("../config/art");
|
|
14
|
+
const cfgimage = require("../config/image");
|
|
13
15
|
const cfgproduct = require("../config/product");
|
|
16
|
+
const cfgvideo = require("../config/video");
|
|
14
17
|
const objs = require("../util/objs");
|
|
15
18
|
|
|
16
19
|
// [use]
|
|
@@ -24,18 +27,7 @@ const readdir = fs.promises.readdir;
|
|
|
24
27
|
|
|
25
28
|
// [declare]
|
|
26
29
|
|
|
27
|
-
const ART =
|
|
28
|
-
"banner.png",
|
|
29
|
-
"banner_video.mp4",
|
|
30
|
-
"cover.png",
|
|
31
|
-
"cover_video.mp4",
|
|
32
|
-
"icon.png",
|
|
33
|
-
"icon_video.mp4",
|
|
34
|
-
"poster.png",
|
|
35
|
-
"poster_video.mp4",
|
|
36
|
-
"wordmark.svg",
|
|
37
|
-
"wordmark_animated.svg",
|
|
38
|
-
];
|
|
30
|
+
const ART = cfgart;
|
|
39
31
|
|
|
40
32
|
// [declare]
|
|
41
33
|
|
|
@@ -62,8 +54,9 @@ const art = function (root) {
|
|
|
62
54
|
// [function]
|
|
63
55
|
|
|
64
56
|
const handleGallery = function (entries) {
|
|
57
|
+
const exts = [...Object.keys(cfgimage), ...Object.keys(cfgvideo)];
|
|
65
58
|
return entries
|
|
66
|
-
.filter((f) => extname(f).toLowerCase()
|
|
59
|
+
.filter((f) => exts.includes(extname(f).toLowerCase()))
|
|
67
60
|
.map((f) => join(MEDIA, "gallery", f))
|
|
68
61
|
.sort();
|
|
69
62
|
};
|
package/src/schema/game.js
CHANGED
|
@@ -11,10 +11,12 @@ const z = require("zod");
|
|
|
11
11
|
const cfgaudience = require("../config/audience");
|
|
12
12
|
const cfggenre = require("../config/genre");
|
|
13
13
|
const cfghtml = require("../config/html");
|
|
14
|
+
const cfgimage = require("../config/image");
|
|
14
15
|
const cfginput = require("../config/input");
|
|
15
16
|
const cfgorientation = require("../config/orientation");
|
|
16
17
|
const cfgproduct = require("../config/product");
|
|
17
18
|
const cfgurl = require("../config/url");
|
|
19
|
+
const cfgvideo = require("../config/video");
|
|
18
20
|
const cfgvisibility = require("../config/visibility");
|
|
19
21
|
const check = require("./check/game");
|
|
20
22
|
const dom = require("../util/dom");
|
|
@@ -95,7 +97,7 @@ const zMedia = function (field, root) {
|
|
|
95
97
|
|
|
96
98
|
const zPng = function (field, root, opts) {
|
|
97
99
|
return zMedia(field, root).refine(
|
|
98
|
-
(file) => imageCheck(root, file, { ...opts, type: "
|
|
100
|
+
(file) => imageCheck(root, file, { ...opts, type: cfgimage[".png"] }),
|
|
99
101
|
message(field, ["Invalid PNG."]),
|
|
100
102
|
);
|
|
101
103
|
};
|
|
@@ -104,7 +106,7 @@ const zPng = function (field, root, opts) {
|
|
|
104
106
|
|
|
105
107
|
const zSvg = function (field, root, opts) {
|
|
106
108
|
return zMedia(field, root).refine(
|
|
107
|
-
(file) => imageCheck(root, file, { ...opts, type: "
|
|
109
|
+
(file) => imageCheck(root, file, { ...opts, type: cfgimage[".svg"] }),
|
|
108
110
|
message(field, ["Invalid SVG."]),
|
|
109
111
|
);
|
|
110
112
|
};
|
|
@@ -115,9 +117,9 @@ const zMp4 = function (field, root, opts) {
|
|
|
115
117
|
return zMedia(field, root).refine(
|
|
116
118
|
(file) =>
|
|
117
119
|
videoCheck(root, file, {
|
|
118
|
-
maxDuration:
|
|
120
|
+
maxDuration: 30,
|
|
119
121
|
...opts,
|
|
120
|
-
type: "
|
|
122
|
+
type: cfgvideo[".mp4"],
|
|
121
123
|
}),
|
|
122
124
|
message(field, ["Invalid MP4."]),
|
|
123
125
|
);
|
|
@@ -171,7 +173,7 @@ const zBannerVideo = function (root) {
|
|
|
171
173
|
return z.optional(
|
|
172
174
|
zMp4(field, root, {
|
|
173
175
|
aspect: "2:1",
|
|
174
|
-
maxSize: size.mb(
|
|
176
|
+
maxSize: size.mb(15),
|
|
175
177
|
minHeight: 512,
|
|
176
178
|
minWidth: 1024,
|
|
177
179
|
}),
|
|
@@ -206,7 +208,7 @@ const zCoverVideo = function (root) {
|
|
|
206
208
|
return z.optional(
|
|
207
209
|
zMp4(field, root, {
|
|
208
210
|
aspect: "3:2",
|
|
209
|
-
maxSize: size.mb(
|
|
211
|
+
maxSize: size.mb(15),
|
|
210
212
|
minHeight: 512,
|
|
211
213
|
minWidth: 768,
|
|
212
214
|
}),
|
|
@@ -243,7 +245,8 @@ const zGallery = function (root) {
|
|
|
243
245
|
.array(
|
|
244
246
|
z.union([
|
|
245
247
|
zPng(field, root, { maxSize: size.mb(2) }),
|
|
246
|
-
|
|
248
|
+
zSvg(field, root, { maxSize: size.mb(1) }),
|
|
249
|
+
zMp4(field, root, { maxSize: size.mb(15) }),
|
|
247
250
|
]),
|
|
248
251
|
)
|
|
249
252
|
.min(1)
|
|
@@ -293,7 +296,7 @@ const zIconVideo = function (root) {
|
|
|
293
296
|
return z.optional(
|
|
294
297
|
zMp4(field, root, {
|
|
295
298
|
aspect: "1:1",
|
|
296
|
-
maxSize: size.mb(
|
|
299
|
+
maxSize: size.mb(15),
|
|
297
300
|
minHeight: 512,
|
|
298
301
|
minWidth: 512,
|
|
299
302
|
}),
|
|
@@ -353,7 +356,7 @@ const zPosterVideo = function (root) {
|
|
|
353
356
|
return z.optional(
|
|
354
357
|
zMp4(field, root, {
|
|
355
358
|
aspect: "2:3",
|
|
356
|
-
maxSize: size.mb(
|
|
359
|
+
maxSize: size.mb(15),
|
|
357
360
|
minHeight: 768,
|
|
358
361
|
minWidth: 512,
|
|
359
362
|
}),
|
|
@@ -437,7 +440,6 @@ const zWordmark = function (root) {
|
|
|
437
440
|
const field = "wordmark";
|
|
438
441
|
return z.optional(
|
|
439
442
|
zSvg(field, root, {
|
|
440
|
-
aspect: "1:1",
|
|
441
443
|
maxSize: size.kb(512),
|
|
442
444
|
}),
|
|
443
445
|
);
|
|
@@ -449,7 +451,6 @@ const zWordmarkAnimated = function (root) {
|
|
|
449
451
|
const field = "wordmark_animated";
|
|
450
452
|
return z.optional(
|
|
451
453
|
zSvg(field, root, {
|
|
452
|
-
aspect: "1:1",
|
|
453
454
|
maxSize: size.mb(1),
|
|
454
455
|
}),
|
|
455
456
|
);
|
package/src/util/image.js
CHANGED
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
5
9
|
const fs = require("fs-extra");
|
|
6
10
|
const imageSize = require("image-size").imageSize;
|
|
7
11
|
|
|
12
|
+
// [import]
|
|
13
|
+
|
|
14
|
+
const cfgimage = require("../config/image");
|
|
15
|
+
|
|
8
16
|
// [use]
|
|
9
17
|
|
|
18
|
+
const extname = path.extname;
|
|
10
19
|
const readFileSync = fs.readFileSync; // eslint-disable-line no-sync
|
|
11
20
|
const statSync = fs.statSync; // eslint-disable-line no-sync
|
|
12
21
|
|
|
@@ -69,14 +78,14 @@ const checkSvg = function (file, { maxSize }) {
|
|
|
69
78
|
// [function]
|
|
70
79
|
|
|
71
80
|
const check = function (file, { type, ...opts }) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
const checks = {
|
|
82
|
+
[cfgimage[".png"]]: checkPng,
|
|
83
|
+
[cfgimage[".svg"]]: checkSvg,
|
|
84
|
+
};
|
|
85
|
+
const checkImage = checks[type];
|
|
86
|
+
return checkImage && cfgimage[extname(file)] === type
|
|
87
|
+
? checkImage(file, opts)
|
|
88
|
+
: false;
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
// [export]
|
package/src/util/video.js
CHANGED
|
@@ -2,15 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
5
9
|
const createFile = require("mp4box").createFile;
|
|
6
10
|
const fs = require("fs-extra");
|
|
7
11
|
|
|
8
12
|
// [import]
|
|
9
13
|
|
|
14
|
+
const cfgvideo = require("../config/video");
|
|
10
15
|
const phrase = require("../phrase");
|
|
11
16
|
|
|
12
17
|
// [use]
|
|
13
18
|
|
|
19
|
+
const extname = path.extname;
|
|
14
20
|
const readFileSync = fs.readFileSync; // eslint-disable-line no-sync
|
|
15
21
|
const statSync = fs.statSync; // eslint-disable-line no-sync
|
|
16
22
|
|
|
@@ -113,12 +119,13 @@ const checkMp4 = function (
|
|
|
113
119
|
// [function]
|
|
114
120
|
|
|
115
121
|
const check = function (file, { type, ...opts }) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
const checks = {
|
|
123
|
+
[cfgvideo[".mp4"]]: checkMp4,
|
|
124
|
+
};
|
|
125
|
+
const checkVideo = checks[type];
|
|
126
|
+
return checkVideo && cfgvideo[extname(file)] === type
|
|
127
|
+
? checkVideo(file, opts)
|
|
128
|
+
: false;
|
|
122
129
|
};
|
|
123
130
|
|
|
124
131
|
// [export]
|