@bitmagic/cli 0.1.53-dev.3 → 0.1.53-dev.4
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 +22 -1
- package/dist/cli.d.ts +4 -0
- package/dist/commands/publish.d.ts +12 -0
- package/dist/commands/publish.js +15 -0
- package/dist/commands/publish.js.map +1 -1
- package/dist/render/qr-terminal.d.ts +56 -0
- package/dist/render/qr-terminal.js +135 -0
- package/dist/render/qr-terminal.js.map +1 -0
- package/dist/render/qr.d.ts +51 -0
- package/dist/render/qr.js +516 -0
- package/dist/render/qr.js.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ browser reloads itself on every change and the assets panel shows each generatio
|
|
|
188
188
|
| `bitmagic reload [--port <port>]` | Tell a running `bitmagic dev` to reload the browser now. For agents: run it when you finish a round of edits. Exits 0 and does nothing when no dev server is running. |
|
|
189
189
|
| `bitmagic verify [--timeout <ms>] [--renderer webgpu\|webgl] [--platform desktop\|mobile\|both] [--fast] [--watch]` | Build, boot the game in a headless browser, press the engine's Play button like a player would, and report what broke. A game without the button passes as long as gameplay starts by itself (auto-starting genres, custom start UIs); a run where gameplay never starts fails. The settle is adaptive: the run ends as soon as the live engine proves stable gameplay (state, rendered frames, no fresh errors, player standing), with `--timeout` as the cap. The verdict includes live engine state — actual GPU backend, fps, player position, physics body count, gameplay events (see **Gameplay events** below) — recorded in `result.json`. `--renderer` pins the pipeline (default `webgpu`, what players run; a silent WebGPU→WebGL2 fallback **fails** the run, and `--renderer webgl` is the deliberate escape hatch). A run failing on a lost WebGL context retries once on software rendering automatically. `--fast` skips the screenshot pipeline (then there is no thumbnail candidate from this run). `--watch` keeps everything warm — incremental `tsc --watch`, one vite, one browser — and re-verifies on file change in seconds; `--fast` is the watch default (`--no-fast` restores the screenshot). `--platform` picks what the run emulates — see **Verifying the mobile path** below. Every run also reports the engine's mobile-parity check: a desktop action with no touch button is a warning, and a **failure** when `game.json` declares `primaryPlatform: "mobile"`. Writes the artifacts the publish gate reads (see below). |
|
|
190
190
|
| `bitmagic build` | Bundle the game into one self-contained `.bitmagic/build/index.html`. Rarely needs to be run by hand — `publish` builds automatically when the project changed. |
|
|
191
|
-
| `bitmagic publish [--visibility public\|private] [--name <name>] [--description <desc>] [--force]` | Verify-gate, build if needed, and upload straight to GCS. **Keeps the game's current visibility**; a new game is private until published with `--visibility public`. |
|
|
191
|
+
| `bitmagic publish [--visibility public\|private] [--name <name>] [--description <desc>] [--force] [--no-qr]` | Verify-gate, build if needed, and upload straight to GCS. **Keeps the game's current visibility**; a new game is private until published with `--visibility public`. Draws the published URL as a QR code so you can scan it onto a phone; `--no-qr` skips that. |
|
|
192
192
|
| `bitmagic upgrade [--engine <version>] [--force]` | Refresh vendored platform files and the CLI's own skills to the currently published engine. Refuses a dirty git tree unless `--force`. Also records the project's `environment` in `bitmagic.json` if it has none yet — the engine it just vendored came from that api-server — and says so when it does. |
|
|
193
193
|
| `bitmagic generate <skybox\|background\|block-type\|sound\|image\|character\|animation\|model\|prop\|vehicle> ...` | Generate one asset directly into `src/work/world.json`. Costs sparks. `model` mints a **new** 3D object from a prompt, `prop` upgrades an existing placeholder **in place**, `vehicle` adds a new drivable one, `animation` takes a parameter spec rather than a prompt, `block-type` registers a custom voxel block — see below. `skybox` and `background` write the **same** field: pick one. |
|
|
194
194
|
| `bitmagic assets add <file> [--name <n>] [--asset-id <id>] [--keep-glb] [--voxel-size <m>] [--max-voxel-size <m>] [--height <m>] [--hollow\|--solid] [--force]` | Upload **your own** file — `.glb`, `.vxl`, `.png/.jpg/.webp`, `.opus/.ogg/.m4a/.mp3`, `.json` — into the game's assets and write its entry into `src/work/world.json`. A `.glb` is voxelized in a headless browser (Chrome + a free port in 3000–3199, like `prop`) unless `--keep-glb`. Free — no sparks. See **Adding your own assets** below. |
|
|
@@ -750,6 +750,24 @@ from, so `bitmagic verify` must have produced at least one screenshot — `scree
|
|
|
750
750
|
stick — and note that writing them into `game.json` yourself would change the fingerprint and
|
|
751
751
|
invalidate the verify you just checked.
|
|
752
752
|
|
|
753
|
+
### Testing it on a phone
|
|
754
|
+
|
|
755
|
+
Publish draws the URL it just printed as a QR code, so you can point a phone at the terminal
|
|
756
|
+
instead of retyping a twelve-character game id into a mobile browser. Scan it and the game opens.
|
|
757
|
+
|
|
758
|
+
This is the pro lane's "try it on my phone" loop, and `--visibility private` is the whole of it: a
|
|
759
|
+
private game is *unlisted*, not access-controlled, so its URL works from any device while the game
|
|
760
|
+
stays off bitmagic.ai. Publish as often as you like and scan the code each time.
|
|
761
|
+
|
|
762
|
+
The code is extra, never a substitute — the URL is always printed as a plain line above it, and
|
|
763
|
+
everything still works if nothing is drawn. Nothing is drawn when output is redirected or piped,
|
|
764
|
+
under `--json`, with `--no-qr`, with `BITMAGIC_NO_QR` set, or when the terminal is narrower than
|
|
765
|
+
the code (37 columns for a typical publish URL), because a wrapped code cannot be scanned anyway.
|
|
766
|
+
|
|
767
|
+
`bitmagic dev` deliberately has no equivalent. Its servers bind `127.0.0.1`, and the asset CDN
|
|
768
|
+
only serves assets to `localhost` origins — a phone pointed at your machine's LAN address would
|
|
769
|
+
load the game with no terrain and drop the player through the floor. Publish privately instead.
|
|
770
|
+
|
|
753
771
|
### Which platform the game is catalogued as
|
|
754
772
|
|
|
755
773
|
Publish syncs two indicators from your project files, so bitmagic.ai lists the game as what it
|
|
@@ -873,6 +891,9 @@ parses one stream whether the command succeeded or not. The exit code remains au
|
|
|
873
891
|
|
|
874
892
|
Without `--json` nothing changes: prose goes to stdout as before and no JSON is emitted.
|
|
875
893
|
|
|
894
|
+
`--json` also suppresses `publish`'s QR code, which is drawn with terminal escape sequences: under
|
|
895
|
+
`--json` stdout carries the result document and nothing else.
|
|
896
|
+
|
|
876
897
|
The result shape is per-command — `publish` reports `url`/`visibility`/`publishVersion`/`manageUrl`, `init`
|
|
877
898
|
reports `gameId`/`root`/`dependenciesInstalled`/`packageManager`, `upgrade` reports `replaced` and any
|
|
878
899
|
`missingDependencies` as structured entries rather than only as a printed install command, plus
|
package/dist/cli.d.ts
CHANGED
|
@@ -348,6 +348,10 @@ declare const rawCommands: {
|
|
|
348
348
|
readonly type: "boolean";
|
|
349
349
|
readonly description: "Skip the post-publish render check. The game still publishes; it is simply not confirmed to render.";
|
|
350
350
|
};
|
|
351
|
+
readonly 'no-qr': {
|
|
352
|
+
readonly type: "boolean";
|
|
353
|
+
readonly description: "Do not draw the published URL as a QR code. `BITMAGIC_NO_QR` does the same for every run.";
|
|
354
|
+
};
|
|
351
355
|
readonly json: {
|
|
352
356
|
readonly type: "boolean";
|
|
353
357
|
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
@@ -34,6 +34,13 @@ export interface PublishRunDeps {
|
|
|
34
34
|
publishedUrl: string;
|
|
35
35
|
artifactDir: string;
|
|
36
36
|
}) => Promise<VerifyResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Draws the published URL as a scannable code. Returns whether the terminal actually drew it.
|
|
39
|
+
*
|
|
40
|
+
* Additional output, exactly like `bitmagic cover`'s inline image — never a failure, and never a
|
|
41
|
+
* replacement for the plain `Published …` line above it.
|
|
42
|
+
*/
|
|
43
|
+
renderQr: (url: string) => boolean;
|
|
37
44
|
}
|
|
38
45
|
export interface PublishArgs {
|
|
39
46
|
visibility?: string;
|
|
@@ -42,6 +49,7 @@ export interface PublishArgs {
|
|
|
42
49
|
force?: boolean;
|
|
43
50
|
/** Hyphenated to match the flag citty parses; there is no camelCase alias. */
|
|
44
51
|
'skip-smoke'?: boolean;
|
|
52
|
+
'no-qr'?: boolean;
|
|
45
53
|
json?: boolean;
|
|
46
54
|
}
|
|
47
55
|
/** One candidate for this publish's thumbnail, already read off disk. */
|
|
@@ -95,6 +103,10 @@ export declare const publishCommand: import("citty").CommandDef<{
|
|
|
95
103
|
readonly type: "boolean";
|
|
96
104
|
readonly description: "Skip the post-publish render check. The game still publishes; it is simply not confirmed to render.";
|
|
97
105
|
};
|
|
106
|
+
readonly 'no-qr': {
|
|
107
|
+
readonly type: "boolean";
|
|
108
|
+
readonly description: "Do not draw the published URL as a QR code. `BITMAGIC_NO_QR` does the same for every run.";
|
|
109
|
+
};
|
|
98
110
|
readonly json: {
|
|
99
111
|
readonly type: "boolean";
|
|
100
112
|
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
package/dist/commands/publish.js
CHANGED
|
@@ -34,6 +34,7 @@ import * as fs from 'fs';
|
|
|
34
34
|
import * as path from 'path';
|
|
35
35
|
import { CliError } from '../errors.js';
|
|
36
36
|
import { engineUpdateNotice } from '../project/engine-update.js';
|
|
37
|
+
import { renderTerminalQr } from '../render/qr-terminal.js';
|
|
37
38
|
import { createOutput } from '../output.js';
|
|
38
39
|
import { loadProjectContext } from '../project/context.js';
|
|
39
40
|
import { coverImagePath } from './cover.js';
|
|
@@ -84,6 +85,7 @@ function defaultDeps() {
|
|
|
84
85
|
const { runSmokeCheck } = await import('../smoke/run.js');
|
|
85
86
|
return runSmokeCheck(options);
|
|
86
87
|
},
|
|
88
|
+
renderQr: (url) => renderTerminalQr(url),
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
@@ -342,6 +344,15 @@ export async function runPublish(args, deps = defaultDeps()) {
|
|
|
342
344
|
// in the same ` warning:` shape the smoke check uses below so one prose convention covers both.
|
|
343
345
|
for (const warning of done.sourceChecks?.warnings ?? [])
|
|
344
346
|
log(` warning: ${warning}`);
|
|
347
|
+
// The URL is already printed above and stays there whatever happens here; this only saves the
|
|
348
|
+
// creator from retyping it into a phone. Drawn beside the URL rather than after the smoke check
|
|
349
|
+
// so it is there immediately, and on `--skip-smoke` too.
|
|
350
|
+
//
|
|
351
|
+
// `--json` is checked explicitly instead of leaning on the isTTY gate inside renderTerminalQr:
|
|
352
|
+
// `--json` on a terminal still HAS a TTY stdout, and stdout under `--json` must carry exactly
|
|
353
|
+
// one document.
|
|
354
|
+
if (args.json !== true && args['no-qr'] !== true)
|
|
355
|
+
deps.renderQr(done.url);
|
|
345
356
|
output.result({
|
|
346
357
|
ok: true,
|
|
347
358
|
url: done.url,
|
|
@@ -403,6 +414,10 @@ export const publishCommand = defineCommand({
|
|
|
403
414
|
type: 'boolean',
|
|
404
415
|
description: 'Skip the post-publish render check. The game still publishes; it is simply not confirmed to render.',
|
|
405
416
|
},
|
|
417
|
+
'no-qr': {
|
|
418
|
+
type: 'boolean',
|
|
419
|
+
description: 'Do not draw the published URL as a QR code. `BITMAGIC_NO_QR` does the same for every run.',
|
|
420
|
+
},
|
|
406
421
|
json: {
|
|
407
422
|
type: 'boolean',
|
|
408
423
|
description: 'Print the result as JSON on stdout; all progress goes to stderr.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAuB,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,O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AE,SAAS;QACf,WAAW,EAAE,0EAA0E;KACxF;IACD,IAAI,EAAE;QACJ,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,qFAAqF;kBACnF,6DAA6D;SAClE;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iFAAiF;SAC/F;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wFAAwF;SACtG;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,oFAAoF;SAClG;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,SAAS;YACf,WAAW,EACT,qGAAqG;SACxG;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,WAAW,EACT,2FAA2F;SAC9F;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,kEAAkE;SAChF;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawing a QR code into the terminal, so the URL `bitmagic publish` just printed can be scanned
|
|
3
|
+
* off the screen instead of retyped into a phone. The Creator has had this since it shipped — the
|
|
4
|
+
* publish dialog ends on a QR — and the CLI's publish is the same moment: `--visibility private`
|
|
5
|
+
* puts a real, phone-reachable URL on a game nobody else can find, which is exactly a "try it on
|
|
6
|
+
* my phone" build.
|
|
7
|
+
*
|
|
8
|
+
* The contract is `inline-image.ts`'s, deliberately: the code is strictly ADDITIONAL. The caller
|
|
9
|
+
* prints the URL first, unconditionally; this either draws underneath it or does nothing at all. It
|
|
10
|
+
* never replaces a line and it never reports failure as an error, because an agent tool is usually
|
|
11
|
+
* what reads this output.
|
|
12
|
+
*
|
|
13
|
+
* Where it DIVERGES from that file is the gate. `supportsInlineImage` is an allowlist of terminals
|
|
14
|
+
* known to implement the iTerm2 protocol, because the ones that do not print a screenful of raw
|
|
15
|
+
* base64. Nothing here is exotic: half-block characters and SGR colour are universal, and tmux
|
|
16
|
+
* passes both through rather than swallowing them. So the gate below asks what the terminal can do
|
|
17
|
+
* — is it a terminal at all, is it wide enough — and never who it is.
|
|
18
|
+
*/
|
|
19
|
+
export interface TerminalQrEnv {
|
|
20
|
+
TERM?: string | undefined;
|
|
21
|
+
BITMAGIC_NO_QR?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether this terminal can show a scannable code at all.
|
|
25
|
+
*
|
|
26
|
+
* Not an allowlist — see the file header. `TERM=dumb` is the one terminal that answers no on its
|
|
27
|
+
* own behalf, and a non-TTY means something is reading this rather than looking at it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function supportsTerminalQr(env: TerminalQrEnv, isTTY: boolean): boolean;
|
|
30
|
+
/** How many columns the drawn code occupies, quiet zone included. */
|
|
31
|
+
export declare function terminalQrWidth(matrix: boolean[][]): number;
|
|
32
|
+
/**
|
|
33
|
+
* The code as terminal lines, quiet zone included and each line self-contained.
|
|
34
|
+
*
|
|
35
|
+
* Exported so a test can read the output without a TTY. The padded symbol has an odd number of
|
|
36
|
+
* module rows — the module count is always odd and the quiet zone adds an even number — so the
|
|
37
|
+
* final terminal row pairs its top half against a light row that is not in the symbol. That is
|
|
38
|
+
* correct rather than a rounding artefact: it reads as one more row of quiet zone.
|
|
39
|
+
*/
|
|
40
|
+
export declare function terminalQrLines(matrix: boolean[][]): string[];
|
|
41
|
+
export interface RenderTerminalQrOptions {
|
|
42
|
+
env?: TerminalQrEnv;
|
|
43
|
+
isTTY?: boolean;
|
|
44
|
+
/** Terminal width. Undefined means unknown, which is treated as wide enough. */
|
|
45
|
+
columns?: number | undefined;
|
|
46
|
+
write?: (chunk: string) => void;
|
|
47
|
+
caption?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Draw `text` as a QR code if this terminal can show one. Returns whether anything was drawn, so a
|
|
51
|
+
* caller can decide what else to say — never throws, and never writes when unsupported.
|
|
52
|
+
*
|
|
53
|
+
* The caption and the code go out in a single write, so the creator never sees an invitation to
|
|
54
|
+
* scan with nothing under it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function renderTerminalQr(text: string, options?: RenderTerminalQrOptions): boolean;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawing a QR code into the terminal, so the URL `bitmagic publish` just printed can be scanned
|
|
3
|
+
* off the screen instead of retyped into a phone. The Creator has had this since it shipped — the
|
|
4
|
+
* publish dialog ends on a QR — and the CLI's publish is the same moment: `--visibility private`
|
|
5
|
+
* puts a real, phone-reachable URL on a game nobody else can find, which is exactly a "try it on
|
|
6
|
+
* my phone" build.
|
|
7
|
+
*
|
|
8
|
+
* The contract is `inline-image.ts`'s, deliberately: the code is strictly ADDITIONAL. The caller
|
|
9
|
+
* prints the URL first, unconditionally; this either draws underneath it or does nothing at all. It
|
|
10
|
+
* never replaces a line and it never reports failure as an error, because an agent tool is usually
|
|
11
|
+
* what reads this output.
|
|
12
|
+
*
|
|
13
|
+
* Where it DIVERGES from that file is the gate. `supportsInlineImage` is an allowlist of terminals
|
|
14
|
+
* known to implement the iTerm2 protocol, because the ones that do not print a screenful of raw
|
|
15
|
+
* base64. Nothing here is exotic: half-block characters and SGR colour are universal, and tmux
|
|
16
|
+
* passes both through rather than swallowing them. So the gate below asks what the terminal can do
|
|
17
|
+
* — is it a terminal at all, is it wide enough — and never who it is.
|
|
18
|
+
*/
|
|
19
|
+
import { encodeQr } from './qr.js';
|
|
20
|
+
/** Written as an escape rather than a literal control byte, so the source stays greppable. */
|
|
21
|
+
const ESC = '\u001b';
|
|
22
|
+
/**
|
|
23
|
+
* Black on bright white, and the reset that closes every line.
|
|
24
|
+
*
|
|
25
|
+
* Explicit on purpose. A scanner wants dark modules on a light field, and the creator's terminal is
|
|
26
|
+
* probably a dark theme — left to inherit, the code would come out inverted, which many scanners
|
|
27
|
+
* cope with and some do not. The reset ends each line so the colour cannot bleed into a wrapped
|
|
28
|
+
* line or the prompt. Bright white (107) rather than plain white (47) because the latter is a light
|
|
29
|
+
* grey in most palettes, and contrast is the one thing a scanner cannot make up for.
|
|
30
|
+
*/
|
|
31
|
+
const PAINT = `${ESC}[30;107m`;
|
|
32
|
+
const RESET = `${ESC}[0m`;
|
|
33
|
+
/**
|
|
34
|
+
* Quiet-zone width in modules, matching the `margin: 2` the Creator passes `QRCode.toDataURL` —
|
|
35
|
+
* a value already proven to scan in production. The spec asks for 4; if scans ever prove flaky,
|
|
36
|
+
* that is the knob, and it costs 4 columns and 1 line.
|
|
37
|
+
*/
|
|
38
|
+
const QUIET_ZONE = 2;
|
|
39
|
+
/**
|
|
40
|
+
* Two module rows per terminal row, drawn with half-blocks.
|
|
41
|
+
*
|
|
42
|
+
* This is what makes the code square. Terminal cells are roughly twice as tall as they are wide, so
|
|
43
|
+
* one module per cell would stretch the symbol into a rectangle no scanner would read; half-blocks
|
|
44
|
+
* put two module rows in one cell and bring the aspect ratio back to 1:1.
|
|
45
|
+
*/
|
|
46
|
+
const BOTH_DARK = '█'; // full block
|
|
47
|
+
const TOP_DARK = '▀'; // upper half block
|
|
48
|
+
const BOTTOM_DARK = '▄'; // lower half block
|
|
49
|
+
const BOTH_LIGHT = ' ';
|
|
50
|
+
/**
|
|
51
|
+
* Whether this terminal can show a scannable code at all.
|
|
52
|
+
*
|
|
53
|
+
* Not an allowlist — see the file header. `TERM=dumb` is the one terminal that answers no on its
|
|
54
|
+
* own behalf, and a non-TTY means something is reading this rather than looking at it.
|
|
55
|
+
*/
|
|
56
|
+
export function supportsTerminalQr(env, isTTY) {
|
|
57
|
+
if (!isTTY)
|
|
58
|
+
return false;
|
|
59
|
+
if (env.BITMAGIC_NO_QR)
|
|
60
|
+
return false;
|
|
61
|
+
return env.TERM !== 'dumb';
|
|
62
|
+
}
|
|
63
|
+
/** How many columns the drawn code occupies, quiet zone included. */
|
|
64
|
+
export function terminalQrWidth(matrix) {
|
|
65
|
+
return matrix.length + QUIET_ZONE * 2;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The code as terminal lines, quiet zone included and each line self-contained.
|
|
69
|
+
*
|
|
70
|
+
* Exported so a test can read the output without a TTY. The padded symbol has an odd number of
|
|
71
|
+
* module rows — the module count is always odd and the quiet zone adds an even number — so the
|
|
72
|
+
* final terminal row pairs its top half against a light row that is not in the symbol. That is
|
|
73
|
+
* correct rather than a rounding artefact: it reads as one more row of quiet zone.
|
|
74
|
+
*/
|
|
75
|
+
export function terminalQrLines(matrix) {
|
|
76
|
+
const width = terminalQrWidth(matrix);
|
|
77
|
+
const height = width;
|
|
78
|
+
const dark = (row, col) => {
|
|
79
|
+
const r = row - QUIET_ZONE;
|
|
80
|
+
const c = col - QUIET_ZONE;
|
|
81
|
+
if (r < 0 || c < 0 || r >= matrix.length || c >= matrix.length)
|
|
82
|
+
return false;
|
|
83
|
+
return matrix[r][c];
|
|
84
|
+
};
|
|
85
|
+
const lines = [];
|
|
86
|
+
for (let row = 0; row < height; row += 2) {
|
|
87
|
+
let line = '';
|
|
88
|
+
for (let col = 0; col < width; col += 1) {
|
|
89
|
+
const top = dark(row, col);
|
|
90
|
+
const bottom = row + 1 < height && dark(row + 1, col);
|
|
91
|
+
if (top && bottom)
|
|
92
|
+
line += BOTH_DARK;
|
|
93
|
+
else if (top)
|
|
94
|
+
line += TOP_DARK;
|
|
95
|
+
else if (bottom)
|
|
96
|
+
line += BOTTOM_DARK;
|
|
97
|
+
else
|
|
98
|
+
line += BOTH_LIGHT;
|
|
99
|
+
}
|
|
100
|
+
lines.push(`${PAINT}${line}${RESET}`);
|
|
101
|
+
}
|
|
102
|
+
return lines;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Draw `text` as a QR code if this terminal can show one. Returns whether anything was drawn, so a
|
|
106
|
+
* caller can decide what else to say — never throws, and never writes when unsupported.
|
|
107
|
+
*
|
|
108
|
+
* The caption and the code go out in a single write, so the creator never sees an invitation to
|
|
109
|
+
* scan with nothing under it.
|
|
110
|
+
*/
|
|
111
|
+
export function renderTerminalQr(text, options = {}) {
|
|
112
|
+
const env = options.env ?? process.env;
|
|
113
|
+
const isTTY = options.isTTY ?? process.stdout.isTTY === true;
|
|
114
|
+
if (!supportsTerminalQr(env, isTTY))
|
|
115
|
+
return false;
|
|
116
|
+
const matrix = encodeQr(text);
|
|
117
|
+
if (matrix === null)
|
|
118
|
+
return false;
|
|
119
|
+
// A code wider than the terminal wraps, and a wrapped code is not a code — it is noise that
|
|
120
|
+
// looks like output. Better to leave the plain URL standing on its own.
|
|
121
|
+
const columns = options.columns ?? process.stdout.columns;
|
|
122
|
+
if (typeof columns === 'number' && columns < terminalQrWidth(matrix))
|
|
123
|
+
return false;
|
|
124
|
+
const caption = options.caption ?? 'Scan to play on your phone:';
|
|
125
|
+
const write = options.write ?? ((chunk) => process.stdout.write(chunk));
|
|
126
|
+
try {
|
|
127
|
+
write(`\n${caption}\n\n${terminalQrLines(matrix).join('\n')}\n\n`);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// A closed or non-writable stdout is not worth failing a successful publish over.
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=qr-terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-terminal.js","sourceRoot":"","sources":["../../src/render/qr-terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,8FAA8F;AAC9F,MAAM,GAAG,GAAG,QAAQ,CAAC;AAErB;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG,GAAG,GAAG,UAAU,CAAC;AAC/B,MAAM,KAAK,GAAG,GAAG,GAAG,KAAK,C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M,CAAC,OAAO,CAAC;IAC1D,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACjE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChF,IAAI,CAAC;QACH,KAAK,CAAC,KAAK,OAAO,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,kFAAkF;QAClF,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A QR encoder, so `bitmagic publish` can hand the creator's phone the URL it just printed.
|
|
3
|
+
*
|
|
4
|
+
* The Creator does this server-side already — `PublishController.generateQRCode` calls the `qrcode`
|
|
5
|
+
* package and the publish dialog shows the PNG. The CLI cannot follow it there: `qrcode` drags in
|
|
6
|
+
* `dijkstrajs`, `pngjs` and `yargs@15`, and `@bitmagic/cli` is a published package with four
|
|
7
|
+
* deliberately-chosen runtime dependencies. So the encoder lives here instead, cut down to exactly
|
|
8
|
+
* what a published-game URL needs:
|
|
9
|
+
*
|
|
10
|
+
* - **Byte mode only.** A URL is bytes. Numeric, alphanumeric and kanji modes would encode it
|
|
11
|
+
* smaller in theory and never in practice, because `https://` alone rules out alphanumeric.
|
|
12
|
+
* - **Error correction level M only**, matching the Creator's `errorCorrectionLevel: 'M'` — a code
|
|
13
|
+
* scanned from this terminal and one scanned from the publish dialog then behave identically.
|
|
14
|
+
* - **Versions 1-9 only.** The character-count indicator is 8 bits up to version 9 and 16 bits
|
|
15
|
+
* from version 10, so stopping here removes a branch and four tables. Version 9 holds 180 bytes;
|
|
16
|
+
* the longest URL this ever sees is the dev portal's, around 60. Anything longer returns null
|
|
17
|
+
* rather than growing the tables — see `encodeQr`.
|
|
18
|
+
*
|
|
19
|
+
* Structure follows ISO/IEC 18004. Every table below is a literal with the spec's own name for it,
|
|
20
|
+
* and `__tests__/qr.test.ts` checks each one against fixtures generated by the `qrcode` package, so
|
|
21
|
+
* a transposed digit fails loudly instead of producing a code that scans as garbage.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The spec's four penalty rules (8.8.2), summed. Lower is better.
|
|
25
|
+
*
|
|
26
|
+
* Scored over the entire symbol including function patterns, as the spec requires — the finders'
|
|
27
|
+
* own 1:1:3:1:1 ratio is exactly what rule 3 hunts for elsewhere, and excluding them would let a
|
|
28
|
+
* mask hide a false finder against a real one.
|
|
29
|
+
*/
|
|
30
|
+
export declare function maskPenalty(matrix: boolean[][]): number;
|
|
31
|
+
/**
|
|
32
|
+
* Encode `text` with an explicitly chosen mask.
|
|
33
|
+
*
|
|
34
|
+
* Exported for the fixture tests, which pin the mask so they compare structure — codewords, ECC,
|
|
35
|
+
* interleaving, function patterns, format bits — rather than a mask heuristic. Callers outside the
|
|
36
|
+
* tests want `encodeQr`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function encodeQrWithMask(text: string, mask: number): boolean[][] | null;
|
|
39
|
+
/**
|
|
40
|
+
* Encode `text` as a matrix of modules, row-major, true meaning dark. Null when it does not fit.
|
|
41
|
+
*
|
|
42
|
+
* The mask is chosen by the spec's penalty rules. That choice is a legibility heuristic and not a
|
|
43
|
+
* correctness property — all eight masks produce a valid, scannable symbol, and a decoder reads the
|
|
44
|
+
* chosen one out of the format information either way.
|
|
45
|
+
*
|
|
46
|
+
* There is no quiet zone here: it belongs to whatever draws the symbol, which knows what it is
|
|
47
|
+
* drawing onto. `qr-terminal.ts` paints its own.
|
|
48
|
+
*/
|
|
49
|
+
export declare function encodeQr(text: string): boolean[][] | null;
|
|
50
|
+
/** The longest text this encoder can hold, in bytes. Exported so a caller can explain a refusal. */
|
|
51
|
+
export declare const MAX_BYTES: number;
|
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A QR encoder, so `bitmagic publish` can hand the creator's phone the URL it just printed.
|
|
3
|
+
*
|
|
4
|
+
* The Creator does this server-side already — `PublishController.generateQRCode` calls the `qrcode`
|
|
5
|
+
* package and the publish dialog shows the PNG. The CLI cannot follow it there: `qrcode` drags in
|
|
6
|
+
* `dijkstrajs`, `pngjs` and `yargs@15`, and `@bitmagic/cli` is a published package with four
|
|
7
|
+
* deliberately-chosen runtime dependencies. So the encoder lives here instead, cut down to exactly
|
|
8
|
+
* what a published-game URL needs:
|
|
9
|
+
*
|
|
10
|
+
* - **Byte mode only.** A URL is bytes. Numeric, alphanumeric and kanji modes would encode it
|
|
11
|
+
* smaller in theory and never in practice, because `https://` alone rules out alphanumeric.
|
|
12
|
+
* - **Error correction level M only**, matching the Creator's `errorCorrectionLevel: 'M'` — a code
|
|
13
|
+
* scanned from this terminal and one scanned from the publish dialog then behave identically.
|
|
14
|
+
* - **Versions 1-9 only.** The character-count indicator is 8 bits up to version 9 and 16 bits
|
|
15
|
+
* from version 10, so stopping here removes a branch and four tables. Version 9 holds 180 bytes;
|
|
16
|
+
* the longest URL this ever sees is the dev portal's, around 60. Anything longer returns null
|
|
17
|
+
* rather than growing the tables — see `encodeQr`.
|
|
18
|
+
*
|
|
19
|
+
* Structure follows ISO/IEC 18004. Every table below is a literal with the spec's own name for it,
|
|
20
|
+
* and `__tests__/qr.test.ts` checks each one against fixtures generated by the `qrcode` package, so
|
|
21
|
+
* a transposed digit fails loudly instead of producing a code that scans as garbage.
|
|
22
|
+
*/
|
|
23
|
+
import { Buffer } from 'buffer';
|
|
24
|
+
/** The largest symbol version this encoder builds. Above it the count indicator widens to 16 bits. */
|
|
25
|
+
const MAX_VERSION = 9;
|
|
26
|
+
/** Byte mode's 4-bit mode indicator (ISO/IEC 18004 table 2). */
|
|
27
|
+
const MODE_BYTE = 0b0100;
|
|
28
|
+
/** The two padding codewords, applied alternately to fill the data capacity (11.2.1). */
|
|
29
|
+
const PAD_CODEWORDS = [0xec, 0x11];
|
|
30
|
+
const BLOCKS_M = [
|
|
31
|
+
{ ecPerBlock: 10, group1Blocks: 1, group1Data: 16, group2Blocks: 0, group2Data: 0 }, // v1 = 26
|
|
32
|
+
{ ecPerBlock: 16, group1Blocks: 1, group1Data: 28, group2Blocks: 0, group2Data: 0 }, // v2 = 44
|
|
33
|
+
{ ecPerBlock: 26, group1Blocks: 1, group1Data: 44, group2Blocks: 0, group2Data: 0 }, // v3 = 70
|
|
34
|
+
{ ecPerBlock: 18, group1Blocks: 2, group1Data: 32, group2Blocks: 0, group2Data: 0 }, // v4 = 100
|
|
35
|
+
{ ecPerBlock: 24, group1Blocks: 2, group1Data: 43, group2Blocks: 0, group2Data: 0 }, // v5 = 134
|
|
36
|
+
{ ecPerBlock: 16, group1Blocks: 4, group1Data: 27, group2Blocks: 0, group2Data: 0 }, // v6 = 172
|
|
37
|
+
{ ecPerBlock: 18, group1Blocks: 4, group1Data: 31, group2Blocks: 0, group2Data: 0 }, // v7 = 196
|
|
38
|
+
{ ecPerBlock: 22, group1Blocks: 2, group1Data: 38, group2Blocks: 2, group2Data: 39 }, // v8 = 242
|
|
39
|
+
{ ecPerBlock: 22, group1Blocks: 3, group1Data: 36, group2Blocks: 2, group2Data: 37 }, // v9 = 292
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Alignment-pattern centre coordinates per version (ISO/IEC 18004 annex E).
|
|
43
|
+
*
|
|
44
|
+
* A pattern is drawn at every pairing of these coordinates except where it would collide with a
|
|
45
|
+
* finder — `drawAlignmentPatterns` skips those by checking whether the module is already set.
|
|
46
|
+
*/
|
|
47
|
+
const ALIGNMENT_POSITIONS = [
|
|
48
|
+
[], // v1 has none
|
|
49
|
+
[6, 18],
|
|
50
|
+
[6, 22],
|
|
51
|
+
[6, 26],
|
|
52
|
+
[6, 30],
|
|
53
|
+
[6, 34],
|
|
54
|
+
[6, 22, 38],
|
|
55
|
+
[6, 24, 42],
|
|
56
|
+
[6, 26, 46],
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* The 15-bit format-information strings for level M and mask 0-7 (ISO/IEC 18004 table C.1).
|
|
60
|
+
*
|
|
61
|
+
* Already BCH(15,5)-encoded and XORed with the 0b101010000010010 mask the spec applies, so nothing
|
|
62
|
+
* here has to be computed. Level M is the only row we need, which is why this is a flat array.
|
|
63
|
+
*/
|
|
64
|
+
const FORMAT_INFO_M = [0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0];
|
|
65
|
+
/**
|
|
66
|
+
* The 18-bit version-information strings, which only versions 7 and up carry (table D.1).
|
|
67
|
+
*
|
|
68
|
+
* Indexed by version, so entries 1-6 are zero and never read.
|
|
69
|
+
*/
|
|
70
|
+
const VERSION_INFO = { 7: 0x07c94, 8: 0x085bc, 9: 0x09a99 };
|
|
71
|
+
/** Penalty weights for the four mask-evaluation rules (ISO/IEC 18004 table 24). */
|
|
72
|
+
const PENALTY_N1 = 3;
|
|
73
|
+
const PENALTY_N2 = 3;
|
|
74
|
+
const PENALTY_N3 = 40;
|
|
75
|
+
const PENALTY_N4 = 10;
|
|
76
|
+
/**
|
|
77
|
+
* The eight data-mask patterns (table 23). True means "invert this module".
|
|
78
|
+
*
|
|
79
|
+
* `row`/`col` are the spec's i/j. These apply to encoding-region modules only; function patterns
|
|
80
|
+
* are written before masking and are never touched, which `placeData` enforces by only filling
|
|
81
|
+
* modules still left null.
|
|
82
|
+
*/
|
|
83
|
+
const MASK_FUNCTIONS = [
|
|
84
|
+
(row, col) => (row + col) % 2 === 0,
|
|
85
|
+
(row) => row % 2 === 0,
|
|
86
|
+
(_row, col) => col % 3 === 0,
|
|
87
|
+
(row, col) => (row + col) % 3 === 0,
|
|
88
|
+
(row, col) => (Math.floor(row / 2) + Math.floor(col / 3)) % 2 === 0,
|
|
89
|
+
(row, col) => ((row * col) % 2) + ((row * col) % 3) === 0,
|
|
90
|
+
(row, col) => (((row * col) % 2) + ((row * col) % 3)) % 2 === 0,
|
|
91
|
+
(row, col) => (((row + col) % 2) + ((row * col) % 3)) % 2 === 0,
|
|
92
|
+
];
|
|
93
|
+
// ---------------------------------------------------------------------------------------------
|
|
94
|
+
// GF(256) arithmetic, for Reed-Solomon
|
|
95
|
+
// ---------------------------------------------------------------------------------------------
|
|
96
|
+
/**
|
|
97
|
+
* Exponent and log tables over GF(256) with primitive polynomial 0x11d and generator 2 (annex B).
|
|
98
|
+
*
|
|
99
|
+
* The exponent table runs to 512 entries — a doubled copy — so `gfMul` can add two logs (each up to
|
|
100
|
+
* 254) and index straight in without a modulo.
|
|
101
|
+
*/
|
|
102
|
+
function buildGaloisTables() {
|
|
103
|
+
const exp = new Uint8Array(512);
|
|
104
|
+
const log = new Uint8Array(256);
|
|
105
|
+
let value = 1;
|
|
106
|
+
for (let i = 0; i < 255; i += 1) {
|
|
107
|
+
exp[i] = value;
|
|
108
|
+
log[value] = i;
|
|
109
|
+
value <<= 1;
|
|
110
|
+
if ((value & 0x100) !== 0)
|
|
111
|
+
value ^= 0x11d;
|
|
112
|
+
}
|
|
113
|
+
for (let i = 255; i < 512; i += 1)
|
|
114
|
+
exp[i] = exp[i - 255];
|
|
115
|
+
return { exp, log };
|
|
116
|
+
}
|
|
117
|
+
const { exp: GF_EXP, log: GF_LOG } = buildGaloisTables();
|
|
118
|
+
function gfMultiply(a, b) {
|
|
119
|
+
if (a === 0 || b === 0)
|
|
120
|
+
return 0;
|
|
121
|
+
return GF_EXP[GF_LOG[a] + GF_LOG[b]];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The generator polynomial of the given degree, in descending coefficient order.
|
|
125
|
+
*
|
|
126
|
+
* Built as the product of (x - a^0)(x - a^1)...; subtraction is XOR in GF(2), so the sign vanishes.
|
|
127
|
+
*/
|
|
128
|
+
function generatorPolynomial(degree) {
|
|
129
|
+
let poly = Uint8Array.from([1]);
|
|
130
|
+
for (let d = 0; d < degree; d += 1) {
|
|
131
|
+
const next = new Uint8Array(poly.length + 1);
|
|
132
|
+
for (let i = 0; i < poly.length; i += 1) {
|
|
133
|
+
next[i] ^= poly[i];
|
|
134
|
+
next[i + 1] ^= gfMultiply(poly[i], GF_EXP[d]);
|
|
135
|
+
}
|
|
136
|
+
poly = next;
|
|
137
|
+
}
|
|
138
|
+
return poly;
|
|
139
|
+
}
|
|
140
|
+
/** The `ecLength` error-correction codewords for one block of data codewords. */
|
|
141
|
+
function reedSolomon(data, ecLength) {
|
|
142
|
+
const generator = generatorPolynomial(ecLength);
|
|
143
|
+
// Long division of `data` shifted up by ecLength places; the remainder is the ECC.
|
|
144
|
+
const remainder = new Uint8Array(data.length + ecLength);
|
|
145
|
+
remainder.set(data);
|
|
146
|
+
for (let i = 0; i < data.length; i += 1) {
|
|
147
|
+
const factor = remainder[i];
|
|
148
|
+
if (factor === 0)
|
|
149
|
+
continue;
|
|
150
|
+
for (let j = 0; j < generator.length; j += 1) {
|
|
151
|
+
remainder[i + j] ^= gfMultiply(generator[j], factor);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return remainder.slice(data.length);
|
|
155
|
+
}
|
|
156
|
+
// ---------------------------------------------------------------------------------------------
|
|
157
|
+
// Codewords
|
|
158
|
+
// ---------------------------------------------------------------------------------------------
|
|
159
|
+
function totalDataCodewords(spec) {
|
|
160
|
+
return spec.group1Blocks * spec.group1Data + spec.group2Blocks * spec.group2Data;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* How many bytes fit at this version, in byte mode at level M.
|
|
164
|
+
*
|
|
165
|
+
* The header costs 12 bits — 4 for the mode indicator plus 8 for the count — so the payload gets
|
|
166
|
+
* the data capacity less one and a half codewords, rounded down.
|
|
167
|
+
*/
|
|
168
|
+
function byteCapacity(version) {
|
|
169
|
+
return Math.floor((totalDataCodewords(BLOCKS_M[version - 1]) * 8 - 12) / 8);
|
|
170
|
+
}
|
|
171
|
+
/** The smallest version that holds `byteLength` bytes, or null when even version 9 does not. */
|
|
172
|
+
function smallestVersion(byteLength) {
|
|
173
|
+
for (let version = 1; version <= MAX_VERSION; version += 1) {
|
|
174
|
+
if (byteLength <= byteCapacity(version))
|
|
175
|
+
return version;
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The final codeword sequence: header, payload, padding, ECC, interleaved as the spec requires.
|
|
181
|
+
*
|
|
182
|
+
* Interleaving (8.6) is what makes a burst of damage survivable — consecutive codewords in the
|
|
183
|
+
* symbol come from different blocks, so a smudge spreads its errors across every block's budget
|
|
184
|
+
* instead of exhausting one.
|
|
185
|
+
*/
|
|
186
|
+
function buildCodewords(payload, version) {
|
|
187
|
+
const spec = BLOCKS_M[version - 1];
|
|
188
|
+
const dataCodewordCount = totalDataCodewords(spec);
|
|
189
|
+
const capacityBits = dataCodewordCount * 8;
|
|
190
|
+
const bits = [];
|
|
191
|
+
const pushBits = (value, length) => {
|
|
192
|
+
for (let i = length - 1; i >= 0; i -= 1)
|
|
193
|
+
bits.push((value >>> i) & 1);
|
|
194
|
+
};
|
|
195
|
+
pushBits(MODE_BYTE, 4);
|
|
196
|
+
pushBits(payload.length, 8);
|
|
197
|
+
for (const byte of payload)
|
|
198
|
+
pushBits(byte, 8);
|
|
199
|
+
// Terminator: up to four zero bits, truncated if the capacity ends first (11.1).
|
|
200
|
+
for (let i = 0; i < 4 && bits.length < capacityBits; i += 1)
|
|
201
|
+
bits.push(0);
|
|
202
|
+
while (bits.length % 8 !== 0)
|
|
203
|
+
bits.push(0);
|
|
204
|
+
const data = new Uint8Array(dataCodewordCount);
|
|
205
|
+
for (let i = 0; i < bits.length; i += 1) {
|
|
206
|
+
if (bits[i] === 1)
|
|
207
|
+
data[i >> 3] |= 0x80 >> (i & 7);
|
|
208
|
+
}
|
|
209
|
+
for (let i = bits.length / 8, pad = 0; i < dataCodewordCount; i += 1, pad += 1) {
|
|
210
|
+
data[i] = PAD_CODEWORDS[pad % 2];
|
|
211
|
+
}
|
|
212
|
+
const blocks = [];
|
|
213
|
+
let offset = 0;
|
|
214
|
+
const groups = [
|
|
215
|
+
[spec.group1Blocks, spec.group1Data],
|
|
216
|
+
[spec.group2Blocks, spec.group2Data],
|
|
217
|
+
];
|
|
218
|
+
for (const [count, size] of groups) {
|
|
219
|
+
for (let b = 0; b < count; b += 1) {
|
|
220
|
+
const chunk = data.slice(offset, offset + size);
|
|
221
|
+
offset += size;
|
|
222
|
+
blocks.push({ data: chunk, ec: reedSolomon(chunk, spec.ecPerBlock) });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const out = [];
|
|
226
|
+
const longestBlock = Math.max(spec.group1Data, spec.group2Data);
|
|
227
|
+
for (let i = 0; i < longestBlock; i += 1) {
|
|
228
|
+
for (const block of blocks) {
|
|
229
|
+
if (i < block.data.length)
|
|
230
|
+
out.push(block.data[i]);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
for (let i = 0; i < spec.ecPerBlock; i += 1) {
|
|
234
|
+
for (const block of blocks)
|
|
235
|
+
out.push(block.ec[i]);
|
|
236
|
+
}
|
|
237
|
+
return Uint8Array.from(out);
|
|
238
|
+
}
|
|
239
|
+
function moduleCount(version) {
|
|
240
|
+
return version * 4 + 17;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* One finder pattern with its separator, anchored at the given top-left module.
|
|
244
|
+
*
|
|
245
|
+
* The loop runs from -1 to 7 rather than 0 to 6 so the one-module separator is written in the same
|
|
246
|
+
* pass, as false. Out-of-range coordinates are skipped, which is what keeps the three call sites
|
|
247
|
+
* identical despite each finder having its separator on different sides.
|
|
248
|
+
*/
|
|
249
|
+
function drawFinderPattern(grid, row, col) {
|
|
250
|
+
const size = grid.length;
|
|
251
|
+
for (let r = -1; r <= 7; r += 1) {
|
|
252
|
+
if (row + r < 0 || row + r >= size)
|
|
253
|
+
continue;
|
|
254
|
+
for (let c = -1; c <= 7; c += 1) {
|
|
255
|
+
if (col + c < 0 || col + c >= size)
|
|
256
|
+
continue;
|
|
257
|
+
const onOuterRing = (r >= 0 && r <= 6 && (c === 0 || c === 6))
|
|
258
|
+
|| (c >= 0 && c <= 6 && (r === 0 || r === 6));
|
|
259
|
+
const inCore = r >= 2 && r <= 4 && c >= 2 && c <= 4;
|
|
260
|
+
grid[row + r][col + c] = onOuterRing || inCore;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function drawTimingPatterns(grid) {
|
|
265
|
+
const size = grid.length;
|
|
266
|
+
for (let i = 8; i < size - 8; i += 1) {
|
|
267
|
+
if (grid[i][6] === null)
|
|
268
|
+
grid[i][6] = i % 2 === 0;
|
|
269
|
+
if (grid[6][i] === null)
|
|
270
|
+
grid[6][i] = i % 2 === 0;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function drawAlignmentPatterns(grid, version) {
|
|
274
|
+
const positions = ALIGNMENT_POSITIONS[version - 1];
|
|
275
|
+
for (const row of positions) {
|
|
276
|
+
for (const col of positions) {
|
|
277
|
+
// Already written means a finder owns this corner; the spec omits the pattern there.
|
|
278
|
+
if (grid[row][col] !== null)
|
|
279
|
+
continue;
|
|
280
|
+
for (let r = -2; r <= 2; r += 1) {
|
|
281
|
+
for (let c = -2; c <= 2; c += 1) {
|
|
282
|
+
grid[row + r][col + c] = r === -2 || r === 2 || c === -2 || c === 2 || (r === 0 && c === 0);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* The two copies of the format information, plus the always-dark module beside the bottom-left
|
|
290
|
+
* finder (8.9). Written before the data so `placeData` treats these positions as occupied.
|
|
291
|
+
*/
|
|
292
|
+
function drawFormatInfo(grid, mask) {
|
|
293
|
+
const size = grid.length;
|
|
294
|
+
const bits = FORMAT_INFO_M[mask];
|
|
295
|
+
for (let i = 0; i < 15; i += 1) {
|
|
296
|
+
const dark = ((bits >> i) & 1) === 1;
|
|
297
|
+
// Copy one, running down the left of the top-left finder and skipping the timing row.
|
|
298
|
+
if (i < 6)
|
|
299
|
+
grid[i][8] = dark;
|
|
300
|
+
else if (i < 8)
|
|
301
|
+
grid[i + 1][8] = dark;
|
|
302
|
+
else
|
|
303
|
+
grid[size - 15 + i][8] = dark;
|
|
304
|
+
// Copy two, running left from the top-right corner and continuing under the top-left finder.
|
|
305
|
+
if (i < 8)
|
|
306
|
+
grid[8][size - i - 1] = dark;
|
|
307
|
+
else if (i < 9)
|
|
308
|
+
grid[8][15 - i] = dark;
|
|
309
|
+
else
|
|
310
|
+
grid[8][14 - i] = dark;
|
|
311
|
+
}
|
|
312
|
+
grid[size - 8][8] = true;
|
|
313
|
+
}
|
|
314
|
+
/** The two copies of the version information, for versions 7 and up only (8.10). */
|
|
315
|
+
function drawVersionInfo(grid, version) {
|
|
316
|
+
if (version < 7)
|
|
317
|
+
return;
|
|
318
|
+
const size = grid.length;
|
|
319
|
+
const bits = VERSION_INFO[version];
|
|
320
|
+
for (let i = 0; i < 18; i += 1) {
|
|
321
|
+
const dark = ((bits >> i) & 1) === 1;
|
|
322
|
+
const major = Math.floor(i / 3);
|
|
323
|
+
const minor = i % 3;
|
|
324
|
+
grid[major][size - 11 + minor] = dark;
|
|
325
|
+
grid[size - 11 + minor][major] = dark;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Fill the encoding region with the codeword bits, masking as we go.
|
|
330
|
+
*
|
|
331
|
+
* The walk is the spec's: two-module-wide columns from the right edge leftwards, alternating
|
|
332
|
+
* upward and downward, right module of the pair before the left. Column 6 is the vertical timing
|
|
333
|
+
* pattern and is stepped over entirely rather than skipped module by module.
|
|
334
|
+
*
|
|
335
|
+
* Running out of codewords is not an error — versions 2 to 6 have leftover remainder bits, which
|
|
336
|
+
* the spec fills with zeros. They still get masked, which is why this cannot just stop early.
|
|
337
|
+
*/
|
|
338
|
+
function placeData(grid, codewords, mask) {
|
|
339
|
+
const size = grid.length;
|
|
340
|
+
const maskFn = MASK_FUNCTIONS[mask];
|
|
341
|
+
let bitIndex = 7;
|
|
342
|
+
let byteIndex = 0;
|
|
343
|
+
let row = size - 1;
|
|
344
|
+
let upward = true;
|
|
345
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
346
|
+
if (col === 6)
|
|
347
|
+
col -= 1;
|
|
348
|
+
for (;;) {
|
|
349
|
+
for (let c = 0; c < 2; c += 1) {
|
|
350
|
+
if (grid[row][col - c] !== null)
|
|
351
|
+
continue;
|
|
352
|
+
let dark = false;
|
|
353
|
+
if (byteIndex < codewords.length) {
|
|
354
|
+
dark = ((codewords[byteIndex] >>> bitIndex) & 1) === 1;
|
|
355
|
+
}
|
|
356
|
+
if (maskFn(row, col - c))
|
|
357
|
+
dark = !dark;
|
|
358
|
+
grid[row][col - c] = dark;
|
|
359
|
+
bitIndex -= 1;
|
|
360
|
+
if (bitIndex === -1) {
|
|
361
|
+
byteIndex += 1;
|
|
362
|
+
bitIndex = 7;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
row += upward ? -1 : 1;
|
|
366
|
+
if (row < 0 || row >= size) {
|
|
367
|
+
row -= upward ? -1 : 1;
|
|
368
|
+
upward = !upward;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function buildSymbol(codewords, version, mask) {
|
|
375
|
+
const size = moduleCount(version);
|
|
376
|
+
const grid = Array.from({ length: size }, () => new Array(size).fill(null));
|
|
377
|
+
drawFinderPattern(grid, 0, 0);
|
|
378
|
+
drawFinderPattern(grid, size - 7, 0);
|
|
379
|
+
drawFinderPattern(grid, 0, size - 7);
|
|
380
|
+
drawAlignmentPatterns(grid, version);
|
|
381
|
+
drawTimingPatterns(grid);
|
|
382
|
+
drawFormatInfo(grid, mask);
|
|
383
|
+
drawVersionInfo(grid, version);
|
|
384
|
+
placeData(grid, codewords, mask);
|
|
385
|
+
// Every module is written by now: the function patterns above cover the whole reserved area, and
|
|
386
|
+
// placeData fills every remaining null. The cast is the only place this file assumes that.
|
|
387
|
+
return grid.map((row) => row.map((module) => module === true));
|
|
388
|
+
}
|
|
389
|
+
// ---------------------------------------------------------------------------------------------
|
|
390
|
+
// Mask selection
|
|
391
|
+
// ---------------------------------------------------------------------------------------------
|
|
392
|
+
/**
|
|
393
|
+
* The spec's four penalty rules (8.8.2), summed. Lower is better.
|
|
394
|
+
*
|
|
395
|
+
* Scored over the entire symbol including function patterns, as the spec requires — the finders'
|
|
396
|
+
* own 1:1:3:1:1 ratio is exactly what rule 3 hunts for elsewhere, and excluding them would let a
|
|
397
|
+
* mask hide a false finder against a real one.
|
|
398
|
+
*/
|
|
399
|
+
export function maskPenalty(matrix) {
|
|
400
|
+
const size = matrix.length;
|
|
401
|
+
let points = 0;
|
|
402
|
+
// Rule 1: runs of five or more same-coloured modules in a row or column.
|
|
403
|
+
for (let a = 0; a < size; a += 1) {
|
|
404
|
+
let runRow = 1;
|
|
405
|
+
let runCol = 1;
|
|
406
|
+
for (let b = 1; b < size; b += 1) {
|
|
407
|
+
if (matrix[a][b] === matrix[a][b - 1])
|
|
408
|
+
runRow += 1;
|
|
409
|
+
else {
|
|
410
|
+
if (runRow >= 5)
|
|
411
|
+
points += PENALTY_N1 + (runRow - 5);
|
|
412
|
+
runRow = 1;
|
|
413
|
+
}
|
|
414
|
+
if (matrix[b][a] === matrix[b - 1][a])
|
|
415
|
+
runCol += 1;
|
|
416
|
+
else {
|
|
417
|
+
if (runCol >= 5)
|
|
418
|
+
points += PENALTY_N1 + (runCol - 5);
|
|
419
|
+
runCol = 1;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (runRow >= 5)
|
|
423
|
+
points += PENALTY_N1 + (runRow - 5);
|
|
424
|
+
if (runCol >= 5)
|
|
425
|
+
points += PENALTY_N1 + (runCol - 5);
|
|
426
|
+
}
|
|
427
|
+
// Rule 2: every 2x2 block of one colour.
|
|
428
|
+
for (let row = 0; row < size - 1; row += 1) {
|
|
429
|
+
for (let col = 0; col < size - 1; col += 1) {
|
|
430
|
+
const dark = matrix[row][col];
|
|
431
|
+
if (matrix[row][col + 1] === dark
|
|
432
|
+
&& matrix[row + 1][col] === dark
|
|
433
|
+
&& matrix[row + 1][col + 1] === dark) {
|
|
434
|
+
points += PENALTY_N2;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// Rule 3: the 1:1:3:1:1 finder ratio with four light modules on one side, either orientation.
|
|
439
|
+
// Tracked as an 11-bit sliding window per row and per column; 0x5d0 is 10111010000 and 0x05d is
|
|
440
|
+
// 00001011101.
|
|
441
|
+
for (let a = 0; a < size; a += 1) {
|
|
442
|
+
let windowRow = 0;
|
|
443
|
+
let windowCol = 0;
|
|
444
|
+
for (let b = 0; b < size; b += 1) {
|
|
445
|
+
windowRow = ((windowRow << 1) & 0x7ff) | (matrix[a][b] ? 1 : 0);
|
|
446
|
+
windowCol = ((windowCol << 1) & 0x7ff) | (matrix[b][a] ? 1 : 0);
|
|
447
|
+
if (b < 10)
|
|
448
|
+
continue;
|
|
449
|
+
if (windowRow === 0x5d0 || windowRow === 0x05d)
|
|
450
|
+
points += PENALTY_N3;
|
|
451
|
+
if (windowCol === 0x5d0 || windowCol === 0x05d)
|
|
452
|
+
points += PENALTY_N3;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Rule 4: how far the proportion of dark modules strays from half, in five-percent steps.
|
|
456
|
+
let dark = 0;
|
|
457
|
+
for (const row of matrix) {
|
|
458
|
+
for (const module of row) {
|
|
459
|
+
if (module)
|
|
460
|
+
dark += 1;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const percent = (dark * 100) / (size * size);
|
|
464
|
+
points += Math.floor(Math.abs(percent - 50) / 5) * PENALTY_N4;
|
|
465
|
+
return points;
|
|
466
|
+
}
|
|
467
|
+
// ---------------------------------------------------------------------------------------------
|
|
468
|
+
// Public surface
|
|
469
|
+
// ---------------------------------------------------------------------------------------------
|
|
470
|
+
/**
|
|
471
|
+
* Encode `text` with an explicitly chosen mask.
|
|
472
|
+
*
|
|
473
|
+
* Exported for the fixture tests, which pin the mask so they compare structure — codewords, ECC,
|
|
474
|
+
* interleaving, function patterns, format bits — rather than a mask heuristic. Callers outside the
|
|
475
|
+
* tests want `encodeQr`.
|
|
476
|
+
*/
|
|
477
|
+
export function encodeQrWithMask(text, mask) {
|
|
478
|
+
if (mask < 0 || mask > 7)
|
|
479
|
+
return null;
|
|
480
|
+
const payload = Buffer.from(text, 'utf8');
|
|
481
|
+
const version = smallestVersion(payload.length);
|
|
482
|
+
if (version === null)
|
|
483
|
+
return null;
|
|
484
|
+
return buildSymbol(buildCodewords(payload, version), version, mask);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Encode `text` as a matrix of modules, row-major, true meaning dark. Null when it does not fit.
|
|
488
|
+
*
|
|
489
|
+
* The mask is chosen by the spec's penalty rules. That choice is a legibility heuristic and not a
|
|
490
|
+
* correctness property — all eight masks produce a valid, scannable symbol, and a decoder reads the
|
|
491
|
+
* chosen one out of the format information either way.
|
|
492
|
+
*
|
|
493
|
+
* There is no quiet zone here: it belongs to whatever draws the symbol, which knows what it is
|
|
494
|
+
* drawing onto. `qr-terminal.ts` paints its own.
|
|
495
|
+
*/
|
|
496
|
+
export function encodeQr(text) {
|
|
497
|
+
const payload = Buffer.from(text, 'utf8');
|
|
498
|
+
const version = smallestVersion(payload.length);
|
|
499
|
+
if (version === null)
|
|
500
|
+
return null;
|
|
501
|
+
const codewords = buildCodewords(payload, version);
|
|
502
|
+
let best = null;
|
|
503
|
+
let bestPenalty = Number.POSITIVE_INFINITY;
|
|
504
|
+
for (let mask = 0; mask < 8; mask += 1) {
|
|
505
|
+
const candidate = buildSymbol(codewords, version, mask);
|
|
506
|
+
const penalty = maskPenalty(candidate);
|
|
507
|
+
if (penalty < bestPenalty) {
|
|
508
|
+
bestPenalty = penalty;
|
|
509
|
+
best = candidate;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return best;
|
|
513
|
+
}
|
|
514
|
+
/** The longest text this encoder can hold, in bytes. Exported so a caller can explain a refusal. */
|
|
515
|
+
export const MAX_BYTES = byteCapacity(MAX_VERSION);
|
|
516
|
+
//# sourceMappingURL=qr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr.js","sourceRoot":"","sources":["../../src/render/qr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,sGAAsG;AACtG,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,gEAAgE;AAChE,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,yFAAyF;AACzF,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAiBnC,MAAM,QAAQ,GAAyB;IACrC,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY;IACjG,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY;IACjG,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,YAAY;IACjG,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,CAA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H,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,IAAI,GAAuB,IAAI,CAAC;IACpC,IAAI,WAAW,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAC3C,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;YAC1B,WAAW,GAAG,OAAO,CAAC;YACtB,IAAI,GAAG,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitmagic/cli",
|
|
3
|
-
"version": "0.1.53-dev.
|
|
3
|
+
"version": "0.1.53-dev.4",
|
|
4
4
|
"description": "Build Bitmagic games from your own agent tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Bitmagic Oy",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"fflate": "^0.8.2",
|
|
24
24
|
"playwright-core": "^1.59.1",
|
|
25
25
|
"tar": "^7.4.3",
|
|
26
|
-
"@bitmagic/
|
|
27
|
-
"@bitmagic/
|
|
28
|
-
"@bitmagic/
|
|
26
|
+
"@bitmagic/animation-forger": "0.1.8-dev.4",
|
|
27
|
+
"@bitmagic/asset-core": "0.2.8-dev.4",
|
|
28
|
+
"@bitmagic/world-forger": "0.1.13-dev.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@eslint/js": "^9.38.0",
|