arcadible 1.0.22 → 1.0.24
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/README.md +2 -1
- package/bin/arc.js +1 -85
- package/dist/account.js +197 -0
- package/dist/action/build/tool.js +65 -0
- package/dist/action/delete/tool.js +46 -0
- package/dist/action/deploy/rebuilt.js +25 -0
- package/dist/action/deploy/result.js +36 -0
- package/dist/action/deploy/timeout.js +18 -0
- package/dist/action/deploy/tool-git.js +54 -0
- package/dist/action/deploy/tool.js +54 -0
- package/dist/action/deploy/wait.js +104 -0
- package/dist/action/function/tool.js +127 -0
- package/dist/action/game.js +61 -0
- package/dist/action/init/manifest.js +64 -0
- package/dist/action/init/tool-patch.js +15 -0
- package/dist/action/init/tool.js +64 -0
- package/dist/action/inspect/tool.js +13 -0
- package/dist/action/key/tool.js +87 -0
- package/dist/action/login/flow.js +69 -0
- package/dist/action/login/tool.js +8 -0
- package/dist/action/logout/tool.js +8 -0
- package/dist/action/open/tool.js +29 -0
- package/dist/action/pack/limits.js +46 -0
- package/dist/action/pack/tool.js +150 -0
- package/dist/action/pack/unsound.js +51 -0
- package/dist/action/play/tool.js +83 -0
- package/dist/action/predeploy/ac.js +75 -0
- package/dist/action/predeploy/game.js +12 -0
- package/dist/action/predeploy/git.js +151 -0
- package/dist/action/predeploy/pm.js +20 -0
- package/dist/action/predeploy/published.js +54 -0
- package/dist/action/predeploy/secrets.js +35 -0
- package/dist/action/predeploy/tool-git.js +108 -0
- package/dist/action/predeploy/tool.js +16 -0
- package/dist/action/secret/tool.js +91 -0
- package/dist/action/serve/tool.js +249 -0
- package/dist/action/validate/checked.js +28 -0
- package/dist/action/validate/tool.js +56 -0
- package/dist/action/validate/unknown.js +58 -0
- package/dist/action/validate/unsound.js +99 -0
- package/dist/action/whoami/tool.js +7 -0
- package/dist/api.js +160 -0
- package/dist/arc.js +41 -0
- package/dist/cli/argv.js +61 -0
- package/dist/cli/channel.js +29 -0
- package/dist/cli/command.js +163 -0
- package/dist/cli/confirm.js +39 -0
- package/dist/cli/options.js +62 -0
- package/dist/cli/rc.js +103 -0
- package/dist/cli/yargs.js +40 -0
- package/dist/command/build.js +68 -0
- package/dist/command/delete.js +66 -0
- package/dist/command/deploy.js +308 -0
- package/dist/command/function/index.js +17 -0
- package/dist/command/function/pause.js +18 -0
- package/dist/command/function/resume.js +18 -0
- package/dist/command/function/run.js +41 -0
- package/dist/command/function/secret/index.js +15 -0
- package/dist/command/function/secret/list.js +27 -0
- package/dist/command/function/secret/name.js +8 -0
- package/dist/command/function/secret/remove.js +26 -0
- package/dist/command/function/secret/run.js +52 -0
- package/dist/command/function/secret/set.js +48 -0
- package/dist/command/function/status.js +40 -0
- package/dist/command/init.js +128 -0
- package/dist/command/inspect.js +38 -0
- package/dist/command/login.js +108 -0
- package/dist/command/logout.js +24 -0
- package/dist/command/open.js +48 -0
- package/dist/command/pack.js +90 -0
- package/dist/command/play.js +80 -0
- package/dist/command/serve.js +176 -0
- package/dist/command/server/index.js +17 -0
- package/dist/command/server/key/create.js +36 -0
- package/dist/command/server/key/index.js +15 -0
- package/dist/command/server/key/list.js +34 -0
- package/dist/command/server/key/revoke.js +24 -0
- package/dist/command/server/key/run.js +54 -0
- package/dist/command/validate.js +47 -0
- package/dist/command/whoami.js +55 -0
- package/dist/commands.js +93 -0
- package/dist/config/ai.js +2 -0
- package/dist/config/art.js +13 -0
- package/dist/config/audience.js +2 -0
- package/dist/config/code.js +129 -0
- package/dist/config/file.js +13 -0
- package/dist/config/genre.js +19 -0
- package/{src → dist}/config/html.js +2 -7
- package/dist/config/image.js +5 -0
- package/dist/config/input.js +11 -0
- package/dist/config/json.js +23 -0
- package/dist/config/limit.js +14 -0
- package/dist/config/orientation.js +11 -0
- package/dist/config/package.js +8 -0
- package/dist/config/product.js +14 -0
- package/dist/config/template.js +37 -0
- package/dist/config/uri.js +18 -0
- package/dist/config/url.js +11 -0
- package/dist/config/video.js +5 -0
- package/dist/config/visibility.js +2 -0
- package/dist/config/workflow.js +7 -0
- package/dist/parser/env.js +61 -0
- package/dist/parser/given.js +8 -0
- package/dist/parser/manifest.js +45 -0
- package/dist/parser/media.js +57 -0
- package/dist/parser/project.js +129 -0
- package/dist/parser/readme-file.js +44 -0
- package/dist/parser/readme.js +70 -0
- package/dist/parser/sections.js +92 -0
- package/dist/parser/self.js +16 -0
- package/dist/phrase/account.js +35 -0
- package/dist/phrase/common.js +130 -0
- package/dist/phrase/deploy.js +184 -0
- package/dist/phrase/function.js +135 -0
- package/dist/phrase/game.js +27 -0
- package/dist/phrase/index.js +15 -0
- package/dist/phrase/init.js +53 -0
- package/dist/phrase/internal.js +61 -0
- package/dist/phrase/manifest.js +120 -0
- package/dist/phrase/media.js +90 -0
- package/dist/phrase/pack.js +69 -0
- package/dist/phrase/serve.js +84 -0
- package/dist/phrase/server.js +38 -0
- package/dist/runner/bundle.js +95 -0
- package/dist/runner/outbound.js +69 -0
- package/dist/schema/check/game.js +29 -0
- package/dist/schema/check/workflow.js +57 -0
- package/dist/schema/game.js +462 -0
- package/dist/schema/message.js +61 -0
- package/dist/schema/readme.js +27 -0
- package/dist/schema/runner.js +43 -0
- package/dist/schema/server.js +91 -0
- package/dist/schema/workflow.js +99 -0
- package/dist/serve/files.js +39 -0
- package/dist/serve/game.js +172 -0
- package/dist/serve/page.js +490 -0
- package/dist/serve/reload.js +55 -0
- package/dist/serve/remote.js +114 -0
- package/dist/serve/runner.js +296 -0
- package/dist/serve/server.js +163 -0
- package/dist/serve/ticket.js +232 -0
- package/dist/util/bytes.js +16 -0
- package/dist/util/chars.js +19 -0
- package/dist/util/command.js +11 -0
- package/dist/util/delay.js +36 -0
- package/dist/util/doc.js +59 -0
- package/dist/util/error.js +35 -0
- package/dist/util/http.js +13 -0
- package/dist/util/image.js +64 -0
- package/dist/util/links.js +45 -0
- package/dist/util/lockfile.js +17 -0
- package/dist/util/log.js +101 -0
- package/dist/util/md.js +37 -0
- package/dist/util/media.js +27 -0
- package/dist/util/objs.js +29 -0
- package/dist/util/os.js +13 -0
- package/dist/util/output.js +133 -0
- package/dist/util/paths.js +8 -0
- package/dist/util/progress.js +57 -0
- package/dist/util/promise.js +18 -0
- package/dist/util/request.js +91 -0
- package/dist/util/s3.js +67 -0
- package/dist/util/schema.js +151 -0
- package/dist/util/screenshot.js +24 -0
- package/dist/util/shell.js +64 -0
- package/dist/util/size.js +32 -0
- package/dist/util/spinner.js +35 -0
- package/dist/util/strs.js +46 -0
- package/dist/util/table.js +18 -0
- package/dist/util/term.js +21 -0
- package/dist/util/time.js +16 -0
- package/dist/util/toml.js +28 -0
- package/{src → dist}/util/uris.js +8 -14
- package/dist/util/video.js +113 -0
- package/dist/util/zip.js +62 -0
- package/npm-shrinkwrap.json +3256 -0
- package/package.json +42 -40
- package/bin/arc-build.js +0 -139
- package/bin/arc-default.js +0 -65
- package/bin/arc-deploy.js +0 -456
- package/bin/arc-init.js +0 -187
- package/bin/arc-inspect.js +0 -97
- package/bin/arc-login.js +0 -165
- package/bin/arc-logout.js +0 -75
- package/bin/arc-open.js +0 -104
- package/bin/arc-pack.js +0 -146
- package/bin/arc-play.js +0 -140
- package/bin/arc-serve.js +0 -214
- package/bin/arc-validate.js +0 -112
- package/bin/arc-whoami.js +0 -119
- package/src/account.js +0 -249
- package/src/action/build/tool.js +0 -80
- package/src/action/deploy/tool-git.js +0 -90
- package/src/action/deploy/tool.js +0 -88
- package/src/action/deploy/wait.js +0 -151
- package/src/action/init/manifest.js +0 -83
- package/src/action/init/tool-patch.js +0 -32
- package/src/action/init/tool.js +0 -97
- package/src/action/inspect/tool.js +0 -26
- package/src/action/login/flow.js +0 -101
- package/src/action/login/tool.js +0 -16
- package/src/action/logout/tool.js +0 -15
- package/src/action/open/tool.js +0 -38
- package/src/action/pack/limits.js +0 -51
- package/src/action/pack/tool.js +0 -171
- package/src/action/pack/unsound.js +0 -69
- package/src/action/play/tool.js +0 -109
- package/src/action/predeploy/ac.js +0 -112
- package/src/action/predeploy/git.js +0 -223
- package/src/action/predeploy/pm.js +0 -37
- package/src/action/predeploy/published.js +0 -82
- package/src/action/predeploy/tool-git.js +0 -154
- package/src/action/predeploy/tool.js +0 -29
- package/src/action/serve/tool.js +0 -209
- package/src/action/validate/checked.js +0 -37
- package/src/action/validate/tool.js +0 -67
- package/src/action/validate/unknown.js +0 -86
- package/src/action/validate/unsound.js +0 -138
- package/src/action/whoami/tool.js +0 -15
- package/src/api.js +0 -163
- package/src/cli/build.js +0 -15
- package/src/cli/deploy.js +0 -21
- package/src/cli/init.js +0 -17
- package/src/cli/inspect.js +0 -15
- package/src/cli/login.js +0 -15
- package/src/cli/logout.js +0 -15
- package/src/cli/open.js +0 -15
- package/src/cli/pack.js +0 -15
- package/src/cli/play.js +0 -15
- package/src/cli/predeploy.js +0 -21
- package/src/cli/serve.js +0 -15
- package/src/cli/validate.js +0 -15
- package/src/cli/whoami.js +0 -15
- package/src/config/ai.js +0 -5
- package/src/config/art.js +0 -16
- package/src/config/audience.js +0 -5
- package/src/config/code.js +0 -142
- package/src/config/file.js +0 -23
- package/src/config/genre.js +0 -22
- package/src/config/image.js +0 -7
- package/src/config/input.js +0 -14
- package/src/config/limit.js +0 -21
- package/src/config/orientation.js +0 -14
- package/src/config/package.js +0 -5
- package/src/config/product.js +0 -5
- package/src/config/template.js +0 -45
- package/src/config/uri.js +0 -27
- package/src/config/url.js +0 -20
- package/src/config/video.js +0 -7
- package/src/config/visibility.js +0 -5
- package/src/config/workflow.js +0 -18
- package/src/parser/env.js +0 -84
- package/src/parser/given.js +0 -17
- package/src/parser/manifest.js +0 -80
- package/src/parser/media.js +0 -90
- package/src/parser/project.js +0 -166
- package/src/parser/readme-file.js +0 -76
- package/src/parser/readme.js +0 -96
- package/src/parser/sections.js +0 -107
- package/src/parser/self.js +0 -27
- package/src/phrase.js +0 -1294
- package/src/schema/check/game.js +0 -61
- package/src/schema/check/workflow.js +0 -99
- package/src/schema/game.js +0 -649
- package/src/schema/message.js +0 -85
- package/src/schema/readme.js +0 -44
- package/src/schema/workflow.js +0 -150
- package/src/serve/files.js +0 -61
- package/src/serve/game.js +0 -191
- package/src/serve/page.js +0 -345
- package/src/serve/reload.js +0 -68
- package/src/serve/remote.js +0 -121
- package/src/serve/server.js +0 -128
- package/src/util/argv.js +0 -116
- package/src/util/bytes.js +0 -25
- package/src/util/chars.js +0 -30
- package/src/util/command.js +0 -18
- package/src/util/delay.js +0 -52
- package/src/util/doc.js +0 -72
- package/src/util/error.js +0 -50
- package/src/util/http.js +0 -25
- package/src/util/image.js +0 -93
- package/src/util/links.js +0 -78
- package/src/util/lockfile.js +0 -35
- package/src/util/log.js +0 -149
- package/src/util/md.js +0 -61
- package/src/util/media.js +0 -40
- package/src/util/objs.js +0 -45
- package/src/util/os.js +0 -27
- package/src/util/output.js +0 -174
- package/src/util/paths.js +0 -21
- package/src/util/progress.js +0 -85
- package/src/util/promise.js +0 -29
- package/src/util/rc.js +0 -144
- package/src/util/request.js +0 -89
- package/src/util/s3.js +0 -92
- package/src/util/schema.js +0 -189
- package/src/util/screenshot.js +0 -37
- package/src/util/shell.js +0 -84
- package/src/util/size.js +0 -53
- package/src/util/spinner.js +0 -52
- package/src/util/strs.js +0 -73
- package/src/util/term.js +0 -28
- package/src/util/time.js +0 -29
- package/src/util/toml.js +0 -14
- package/src/util/video.js +0 -157
- package/src/util/zip.js +0 -88
- /package/{src/serve → assets}/favicon.ico +0 -0
package/src/util/spinner.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const cliSpinner = require("cli-spinner");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const term = require("./term");
|
|
10
|
-
|
|
11
|
-
// [use]
|
|
12
|
-
|
|
13
|
-
const Spinner = cliSpinner.Spinner;
|
|
14
|
-
|
|
15
|
-
// [class]
|
|
16
|
-
|
|
17
|
-
// a spinner on stderr, shown only on a terminal. `stop` only clears the line
|
|
18
|
-
// when the spinner ran, so nothing is written when it didn't.
|
|
19
|
-
const SpinnerWheel = class {
|
|
20
|
-
|
|
21
|
-
// [constructor]
|
|
22
|
-
|
|
23
|
-
constructor(text) {
|
|
24
|
-
this.running = false;
|
|
25
|
-
this.wheel = new Spinner({ stream: process.stderr, text });
|
|
26
|
-
this.wheel.setSpinnerString(2);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// [method]
|
|
30
|
-
|
|
31
|
-
start(quiet) {
|
|
32
|
-
if (!quiet && !this.running && term.interactive()) {
|
|
33
|
-
this.wheel.start();
|
|
34
|
-
this.running = true;
|
|
35
|
-
}
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// [method]
|
|
40
|
-
|
|
41
|
-
stop(clear) {
|
|
42
|
-
if (this.running) {
|
|
43
|
-
this.wheel.stop(clear);
|
|
44
|
-
this.running = false;
|
|
45
|
-
}
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// [export]
|
|
51
|
-
|
|
52
|
-
module.exports = { SpinnerWheel };
|
package/src/util/strs.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [function]
|
|
4
|
-
|
|
5
|
-
// the number of single-character edits between two strings (Levenshtein).
|
|
6
|
-
const distance = function (a, b) {
|
|
7
|
-
let row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
8
|
-
for (let i = 1; i <= a.length; i += 1) {
|
|
9
|
-
const next = [i];
|
|
10
|
-
for (let j = 1; j <= b.length; j += 1) {
|
|
11
|
-
next[j] = Math.min(
|
|
12
|
-
row[j] + 1,
|
|
13
|
-
next[j - 1] + 1,
|
|
14
|
-
row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1),
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
row = next;
|
|
18
|
-
}
|
|
19
|
-
return row[b.length];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// [function]
|
|
23
|
-
|
|
24
|
-
// the candidate nearest `str`, for "Did you mean", or null when none is
|
|
25
|
-
// within two edits.
|
|
26
|
-
const closest = function (str, candidates) {
|
|
27
|
-
let best = null;
|
|
28
|
-
let min = 3;
|
|
29
|
-
for (const candidate of candidates) {
|
|
30
|
-
const d = distance(str, candidate);
|
|
31
|
-
if (d < min) {
|
|
32
|
-
best = candidate;
|
|
33
|
-
min = d;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return best;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// [function]
|
|
40
|
-
|
|
41
|
-
const indentLines = function (strs, spaces = 2) {
|
|
42
|
-
const pad = " ".repeat(spaces);
|
|
43
|
-
return strs
|
|
44
|
-
.split("\n")
|
|
45
|
-
.map((str) => pad + str)
|
|
46
|
-
.join("\n");
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// [function]
|
|
50
|
-
|
|
51
|
-
const stripLeadingInvisible = function (str) {
|
|
52
|
-
return String(str).replace(
|
|
53
|
-
// eslint-disable-next-line no-misleading-character-class
|
|
54
|
-
/^[\u200B\u200C\u200D\u2060\u2061\u2062\u2063\uFEFF]+/u,
|
|
55
|
-
"",
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// [function]
|
|
60
|
-
|
|
61
|
-
const trimWhitespace = function (str) {
|
|
62
|
-
return String(str).trim();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// [export]
|
|
66
|
-
|
|
67
|
-
module.exports = {
|
|
68
|
-
closest,
|
|
69
|
-
distance,
|
|
70
|
-
indentLines,
|
|
71
|
-
stripLeadingInvisible,
|
|
72
|
-
trimWhitespace,
|
|
73
|
-
};
|
package/src/util/term.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const chalk = require("chalk");
|
|
6
|
-
|
|
7
|
-
// [function]
|
|
8
|
-
|
|
9
|
-
// whether to show progress: spinners and progress bars are written to stderr,
|
|
10
|
-
// and only when it's a terminal. Piped, in CI, or read by an agent, the
|
|
11
|
-
// output is only the results and messages, with no control codes.
|
|
12
|
-
const interactive = function () {
|
|
13
|
-
return Boolean(process.stderr.isTTY);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// [function]
|
|
17
|
-
|
|
18
|
-
// turns colour off when NO_COLOR is set to anything but an empty string, as
|
|
19
|
-
// no-color.org describes. chalk already leaves it off without a terminal.
|
|
20
|
-
const configureColor = function () {
|
|
21
|
-
if (process.env.NO_COLOR) {
|
|
22
|
-
chalk.level = 0;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// [export]
|
|
27
|
-
|
|
28
|
-
module.exports = { configureColor, interactive };
|
package/src/util/time.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [function]
|
|
4
|
-
|
|
5
|
-
const ms = function (value) {
|
|
6
|
-
return value;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// [function]
|
|
10
|
-
|
|
11
|
-
const s = function (value) {
|
|
12
|
-
return value * 1000;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// [function]
|
|
16
|
-
|
|
17
|
-
const m = function (value) {
|
|
18
|
-
return s(value * 60);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// [function]
|
|
22
|
-
|
|
23
|
-
const h = function (value) {
|
|
24
|
-
return m(value * 60);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// [export]
|
|
28
|
-
|
|
29
|
-
module.exports = { h, m, ms, s };
|
package/src/util/toml.js
DELETED
package/src/util/video.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const fs = require("fs-extra");
|
|
10
|
-
const mp4box = require("mp4box");
|
|
11
|
-
|
|
12
|
-
// [import]
|
|
13
|
-
|
|
14
|
-
const bytes = require("./bytes");
|
|
15
|
-
const cfgvideo = require("../config/video");
|
|
16
|
-
const media = require("./media");
|
|
17
|
-
const phrase = require("../phrase");
|
|
18
|
-
|
|
19
|
-
// [use]
|
|
20
|
-
|
|
21
|
-
const createFile = mp4box.createFile;
|
|
22
|
-
const checkAspect = media.checkAspect;
|
|
23
|
-
const checkSize = media.checkSize;
|
|
24
|
-
const extname = path.extname;
|
|
25
|
-
const formatBytes = bytes.formatBytes;
|
|
26
|
-
const MAX_READ = media.MAX_READ;
|
|
27
|
-
const readFileSync = fs.readFileSync; // eslint-disable-line no-sync
|
|
28
|
-
const statSync = fs.statSync; // eslint-disable-line no-sync
|
|
29
|
-
|
|
30
|
-
// [declare]
|
|
31
|
-
|
|
32
|
-
const NO_TRACK = "no-video-track";
|
|
33
|
-
|
|
34
|
-
// [configure]
|
|
35
|
-
|
|
36
|
-
// mp4box prints what it recovers from at its error level, which setLogLevel
|
|
37
|
-
// can't turn down: its colr parser misreads an ICC profile by the box's
|
|
38
|
-
// header, and says so for a video it reads correctly. arc reports a bad video
|
|
39
|
-
// itself, so mp4box only passes on the errors it sends to the file's onError.
|
|
40
|
-
mp4box.Log.error = (mod, msg, isofile) => isofile?.onError?.(mod, msg);
|
|
41
|
-
mp4box.Log.warn = () => {};
|
|
42
|
-
|
|
43
|
-
// [function]
|
|
44
|
-
|
|
45
|
-
const readMp4 = function (file) {
|
|
46
|
-
const data = readFileSync(file);
|
|
47
|
-
const mp4 = createFile();
|
|
48
|
-
let err = null;
|
|
49
|
-
let video = null;
|
|
50
|
-
mp4.onReady = (info) => {
|
|
51
|
-
const track = info.tracks.find((t) => t.video);
|
|
52
|
-
if (!track?.video) {
|
|
53
|
-
err = Object.assign(new Error(phrase.noVideoTrack()), { code: NO_TRACK });
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
video = {
|
|
57
|
-
duration: info.duration / info.timescale,
|
|
58
|
-
height: track.video.height,
|
|
59
|
-
width: track.video.width,
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
mp4.onError = (mod, msg) => {
|
|
63
|
-
err = new Error(msg);
|
|
64
|
-
};
|
|
65
|
-
const buffer = data.buffer.slice(
|
|
66
|
-
data.byteOffset,
|
|
67
|
-
data.byteOffset + data.byteLength,
|
|
68
|
-
);
|
|
69
|
-
buffer.fileStart = 0;
|
|
70
|
-
mp4.appendBuffer(buffer);
|
|
71
|
-
mp4.flush();
|
|
72
|
-
if (err) {
|
|
73
|
-
throw err;
|
|
74
|
-
}
|
|
75
|
-
if (!video) {
|
|
76
|
-
throw new Error(phrase.noVideoMetadata());
|
|
77
|
-
}
|
|
78
|
-
return video;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// [function]
|
|
82
|
-
|
|
83
|
-
// every rule the video breaks, after what it is, so one run reports them all.
|
|
84
|
-
// only a file that can't be read as an MP4 with a video track stops the
|
|
85
|
-
// checks.
|
|
86
|
-
const checkMp4 = function (
|
|
87
|
-
file,
|
|
88
|
-
{
|
|
89
|
-
aspect,
|
|
90
|
-
maxDuration,
|
|
91
|
-
maxHeight,
|
|
92
|
-
maxSize,
|
|
93
|
-
maxWidth,
|
|
94
|
-
minDuration,
|
|
95
|
-
minHeight,
|
|
96
|
-
minWidth,
|
|
97
|
-
},
|
|
98
|
-
) {
|
|
99
|
-
const fileSize = statSync(file).size;
|
|
100
|
-
const issues = checkSize(fileSize, maxSize)
|
|
101
|
-
? []
|
|
102
|
-
: [phrase.videoSizeMax(formatBytes(maxSize))];
|
|
103
|
-
if (fileSize > MAX_READ) {
|
|
104
|
-
return issues;
|
|
105
|
-
}
|
|
106
|
-
let video = null;
|
|
107
|
-
try {
|
|
108
|
-
video = readMp4(file);
|
|
109
|
-
} catch (ex) {
|
|
110
|
-
// a readable MP4 without a video track says so; anything else is invalid.
|
|
111
|
-
return [
|
|
112
|
-
...issues,
|
|
113
|
-
ex.code === NO_TRACK ? ex.message : phrase.videoInvalid(),
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
const { duration, height, width } = video;
|
|
117
|
-
if (minWidth && width < minWidth) {
|
|
118
|
-
issues.push(phrase.videoWidthMin(minWidth));
|
|
119
|
-
}
|
|
120
|
-
if (minHeight && height < minHeight) {
|
|
121
|
-
issues.push(phrase.videoHeightMin(minHeight));
|
|
122
|
-
}
|
|
123
|
-
if (maxWidth && width > maxWidth) {
|
|
124
|
-
issues.push(phrase.videoWidthMax(maxWidth));
|
|
125
|
-
}
|
|
126
|
-
if (maxHeight && height > maxHeight) {
|
|
127
|
-
issues.push(phrase.videoHeightMax(maxHeight));
|
|
128
|
-
}
|
|
129
|
-
if (minDuration && duration < minDuration) {
|
|
130
|
-
issues.push(phrase.videoDurationMin(minDuration));
|
|
131
|
-
}
|
|
132
|
-
if (maxDuration && duration > maxDuration) {
|
|
133
|
-
issues.push(phrase.videoDurationMax(maxDuration));
|
|
134
|
-
}
|
|
135
|
-
if (!checkAspect(width, height, aspect)) {
|
|
136
|
-
issues.push(phrase.videoAspect(aspect));
|
|
137
|
-
}
|
|
138
|
-
return issues.length
|
|
139
|
-
? [phrase.videoFound(width, height, duration), ...issues]
|
|
140
|
-
: [];
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// [function]
|
|
144
|
-
|
|
145
|
-
const check = function (file, { type, ...opts }) {
|
|
146
|
-
const checks = {
|
|
147
|
-
[cfgvideo[".mp4"]]: checkMp4,
|
|
148
|
-
};
|
|
149
|
-
const checkVideo = checks[type];
|
|
150
|
-
return checkVideo && cfgvideo[extname(file)] === type
|
|
151
|
-
? checkVideo(file, opts)
|
|
152
|
-
: [phrase.videoUnsupported()];
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// [export]
|
|
156
|
-
|
|
157
|
-
module.exports = { check };
|
package/src/util/zip.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const crypto = require("node:crypto");
|
|
6
|
-
const path = require("node:path");
|
|
7
|
-
|
|
8
|
-
// [import]
|
|
9
|
-
|
|
10
|
-
const AdmZip = require("adm-zip");
|
|
11
|
-
|
|
12
|
-
// [import]
|
|
13
|
-
|
|
14
|
-
const objs = require("./objs");
|
|
15
|
-
|
|
16
|
-
// [use]
|
|
17
|
-
|
|
18
|
-
const createHash = crypto.createHash;
|
|
19
|
-
const deepSort = objs.deepSort;
|
|
20
|
-
const join = path.posix.join;
|
|
21
|
-
|
|
22
|
-
// [class]
|
|
23
|
-
|
|
24
|
-
const Zip = class {
|
|
25
|
-
|
|
26
|
-
// [constructor]
|
|
27
|
-
|
|
28
|
-
constructor(prefix) {
|
|
29
|
-
this.prefix = prefix;
|
|
30
|
-
this.zip = new AdmZip();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// [method]
|
|
34
|
-
|
|
35
|
-
addDir(dir, name = "") {
|
|
36
|
-
this.zip.addLocalFolder(dir, name ? join(this.prefix, name) : this.prefix);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// [method]
|
|
40
|
-
|
|
41
|
-
addJson(name, value) {
|
|
42
|
-
const entry = join(this.prefix, name);
|
|
43
|
-
const content = Buffer.from(
|
|
44
|
-
JSON.stringify(deepSort(value), null, 2),
|
|
45
|
-
"utf8",
|
|
46
|
-
);
|
|
47
|
-
this.zip.addFile(entry, content);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// [method]
|
|
51
|
-
|
|
52
|
-
// the files in the zip, with their uncompressed sizes. Directories aren't
|
|
53
|
-
// counted. Names are relative to the zip's folder.
|
|
54
|
-
entries() {
|
|
55
|
-
const start = this.prefix.length + 1;
|
|
56
|
-
return this.zip
|
|
57
|
-
.getEntries()
|
|
58
|
-
.filter((entry) => !entry.isDirectory)
|
|
59
|
-
.map((entry) => ({
|
|
60
|
-
name: entry.entryName.slice(start),
|
|
61
|
-
size: entry.header.size,
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// [method]
|
|
66
|
-
|
|
67
|
-
has(name) {
|
|
68
|
-
return this.zip.getEntry(join(this.prefix, name)) !== null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// [method]
|
|
72
|
-
|
|
73
|
-
stat() {
|
|
74
|
-
const buffer = this.zip.toBuffer();
|
|
75
|
-
const hash = createHash("sha256").update(buffer).digest("hex");
|
|
76
|
-
return { sha256: hash, size: buffer.length };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// [method]
|
|
80
|
-
|
|
81
|
-
write(outPath) {
|
|
82
|
-
this.zip.writeZip(outPath);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// [export]
|
|
87
|
-
|
|
88
|
-
module.exports = Zip;
|
|
File without changes
|