@bitmagic/cli 0.1.37 → 0.1.39
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 +41 -3
- package/dist/auth/subscribe-flow.d.ts +59 -0
- package/dist/auth/subscribe-flow.js +102 -0
- package/dist/auth/subscribe-flow.js.map +1 -0
- package/dist/browser-gl.d.ts +23 -0
- package/dist/browser-gl.js +50 -0
- package/dist/browser-gl.js.map +1 -1
- package/dist/cli.d.ts +41 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/login.js +33 -5
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/subscribe.d.ts +14 -0
- package/dist/commands/subscribe.js +60 -0
- package/dist/commands/subscribe.js.map +1 -0
- package/dist/commands/usage.d.ts +76 -0
- package/dist/commands/usage.js +117 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/verify.d.ts +13 -1
- package/dist/commands/verify.js +139 -15
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/whoami.d.ts +10 -4
- package/dist/commands/whoami.js +22 -7
- package/dist/commands/whoami.js.map +1 -1
- package/dist/forge/upload-proxy.js +1 -1
- package/dist/http/client.d.ts +10 -0
- package/dist/http/client.js +38 -2
- package/dist/http/client.js.map +1 -1
- package/dist/scaffold/claude-settings.js +4 -0
- package/dist/scaffold/claude-settings.js.map +1 -1
- package/dist/scaffold/project-files.d.ts +9 -0
- package/dist/scaffold/project-files.js +70 -9
- package/dist/scaffold/project-files.js.map +1 -1
- package/dist/scaffold/project.js +2 -1
- package/dist/scaffold/project.js.map +1 -1
- package/dist/verify/browser.d.ts +37 -1
- package/dist/verify/browser.js +389 -97
- package/dist/verify/browser.js.map +1 -1
- package/dist/verify/classify.d.ts +75 -2
- package/dist/verify/classify.js +48 -2
- package/dist/verify/classify.js.map +1 -1
- package/dist/verify/iterate.d.ts +47 -0
- package/dist/verify/iterate.js +162 -0
- package/dist/verify/iterate.js.map +1 -0
- package/dist/verify/result.d.ts +16 -3
- package/dist/verify/result.js +13 -3
- package/dist/verify/result.js.map +1 -1
- package/dist/verify/settle.d.ts +60 -0
- package/dist/verify/settle.js +90 -0
- package/dist/verify/settle.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,41 @@ web Creator UI. `bitmagic init` scaffolds a project with the engine vendored in
|
|
|
5
5
|
agent edits `src/work/`, and `bitmagic verify` / `bitmagic publish` take it to bitmagic.ai — no
|
|
6
6
|
web project or per-session pod required.
|
|
7
7
|
|
|
8
|
+
## Who can use it
|
|
9
|
+
|
|
10
|
+
The CLI requires an **active Bitmagic Pro subscription**. There is no other way in — an Auth0 role
|
|
11
|
+
used to work and no longer does.
|
|
12
|
+
|
|
13
|
+
You do not have to go and find a signup page: `bitmagic login` checks as soon as you have
|
|
14
|
+
authenticated and, if you are not subscribed, opens Stripe Checkout in the browser you are already
|
|
15
|
+
in and waits for it to complete.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$ bitmagic login
|
|
19
|
+
Open: https://…/activate?user_code=KLMN-PQRS
|
|
20
|
+
Code: KLMN-PQRS
|
|
21
|
+
Waiting for approval…
|
|
22
|
+
Logged in to dev as you@example.com.
|
|
23
|
+
|
|
24
|
+
The Bitmagic CLI needs a Bitmagic Pro subscription.
|
|
25
|
+
Pro gives you a weekly and a 5-hour spark allowance that refill on their own,
|
|
26
|
+
and pays for generating assets, cover art and worlds.
|
|
27
|
+
|
|
28
|
+
Opening checkout in your browser:
|
|
29
|
+
https://checkout.stripe.com/c/pay/cs_…
|
|
30
|
+
|
|
31
|
+
Waiting for your subscription… (Ctrl-C is safe — run `bitmagic subscribe` to resume)
|
|
32
|
+
|
|
33
|
+
Bitmagic Pro is active. You are ready — try `bitmagic init`.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Ctrl-C at any point is safe; your login is already stored. `bitmagic subscribe` picks up where you
|
|
37
|
+
left off, and `bitmagic whoami` says whether Pro is active and when it renews.
|
|
38
|
+
|
|
39
|
+
The spark allowance refills on a rolling basis — a weekly budget and a 5-hour one — and is what pays
|
|
40
|
+
for `bitmagic generate`, `cover` and `forge`. When an allowance runs out, generation falls back to
|
|
41
|
+
your purchased spark balance. `bitmagic usage` shows where it went.
|
|
42
|
+
|
|
8
43
|
## Install
|
|
9
44
|
|
|
10
45
|
```bash
|
|
@@ -35,13 +70,15 @@ browser reloads itself on every change and the assets panel shows each generatio
|
|
|
35
70
|
| Command | What it does |
|
|
36
71
|
|---|---|
|
|
37
72
|
| `bitmagic login [--env <env>]` | Device-code auth against Auth0; stores credentials per environment. |
|
|
73
|
+
| `bitmagic subscribe [--no-wait]` | Start the Bitmagic Pro subscription the CLI requires; opens checkout and waits for it. |
|
|
74
|
+
| `bitmagic usage [--days N]` | Where this account's sparks went, and what Pro allowance is left. |
|
|
38
75
|
| `bitmagic logout [--env <env>]` | Remove stored credentials for an environment. |
|
|
39
76
|
| `bitmagic whoami [--env <env>]` | Show the identity the CLI is authenticated as. |
|
|
40
77
|
| `bitmagic init [dir] [--template <id>] [--name <name>] [--idea "<pitch>"] [--env <env>] [--force]` | Scaffold a new project: mints a game, downloads the vendored engine, writes `AGENTS.md`, `GAME-DESIGN.md` and templates. Starts from `empty-3d` unless told otherwise. `--idea` seeds the design doc's pitch **and** picks the template whose camera and controls fit it — "a doom-like corridor shooter" scaffolds `first-person`, "jump between floating islands" scaffolds `sidescroller`. `--template` overrides both; a suggestion that fails for any reason falls back to `empty-3d` rather than failing the scaffold. |
|
|
41
78
|
| `bitmagic check` | Typecheck (`tsc --noEmit`) against the vendored engine. Fast; does not prove the game runs. |
|
|
42
79
|
| `bitmagic dev [--port <port>] [--editor-port <port>] [--no-open]` | Build, then serve everything and keep it running: `tsc --watch`, `vite` on 3010, and a **Game / Editor** view on 3011 that reloads itself when the project changes. Opens the view in your browser; `--no-open` (or `BITMAGIC_NO_OPEN=1`) skips that. The one command to leave open. See **The dev view** below. |
|
|
43
80
|
| `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. |
|
|
44
|
-
| `bitmagic verify [--timeout <ms>]` | Build, boot the game in a headless browser, click 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. `--timeout`
|
|
81
|
+
| `bitmagic verify [--timeout <ms>] [--renderer webgpu\|webgl] [--fast] [--watch]` | Build, boot the game in a headless browser, click 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 — 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). Writes the artifacts the publish gate reads (see below). |
|
|
45
82
|
| `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. |
|
|
46
83
|
| `bitmagic publish [--visibility public\|private] [--name <name>] [--description <desc>] [--force]` | Verify-gate, build if needed, and upload straight to GCS. **Private unless `--visibility public` is passed.** |
|
|
47
84
|
| `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`. |
|
|
@@ -79,9 +116,10 @@ my-game/
|
|
|
79
116
|
index.html # bitmagic build's output bundle
|
|
80
117
|
manifest.json # engineVersion, fingerprint, bytes, sha256, builtAt
|
|
81
118
|
verify/
|
|
82
|
-
result.json # bitmagic verify's verdict — ok, failures, warnings, fingerprint, at
|
|
83
|
-
screenshot.png # the publish thumbnail when there is no cover art
|
|
119
|
+
result.json # bitmagic verify's verdict — ok, failures, warnings, fingerprint, at, renderer, settle, snapshot
|
|
120
|
+
screenshot.png # the publish thumbnail when there is no cover art (not written by --fast runs)
|
|
84
121
|
console.log # captured browser console output
|
|
122
|
+
console.retry.log # the software-GL retry's console, when a lost context forced one
|
|
85
123
|
```
|
|
86
124
|
|
|
87
125
|
## Cover art
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { openInBrowser } from '../open-browser.js';
|
|
2
|
+
import type { Environment } from '../config/environments.js';
|
|
3
|
+
import type { Output } from '../output.js';
|
|
4
|
+
/** How long to wait for the webhook to land the subscription before giving up. */
|
|
5
|
+
export declare const SUBSCRIBE_POLL_TIMEOUT_MS: number;
|
|
6
|
+
export declare const SUBSCRIBE_POLL_INTERVAL_MS = 3000;
|
|
7
|
+
export interface WhoamiResponse {
|
|
8
|
+
userId: string;
|
|
9
|
+
roles: string[];
|
|
10
|
+
/** Whether the caller currently holds an entitled subscription. */
|
|
11
|
+
pro: boolean;
|
|
12
|
+
/** Period end of any subscription row, including a lapsed one. */
|
|
13
|
+
proUntil: string | null;
|
|
14
|
+
/** Set when the subscription is live but will not renew. Optional: older api-servers omit it. */
|
|
15
|
+
cancelAtPeriodEnd?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* PURE. One line describing where the caller's subscription stands.
|
|
19
|
+
*
|
|
20
|
+
* Covers the case a status boolean cannot: a subscription that is live TODAY
|
|
21
|
+
* but set not to renew. Finding that out when a command is refused mid-work is
|
|
22
|
+
* the worst possible moment, so every command that greets the creator says it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function describeProStatus(me: WhoamiResponse): string;
|
|
25
|
+
export interface SubscribeDeps {
|
|
26
|
+
fetch: typeof globalThis.fetch;
|
|
27
|
+
sleep: (ms: number) => Promise<void>;
|
|
28
|
+
now: () => number;
|
|
29
|
+
openInBrowser: typeof openInBrowser;
|
|
30
|
+
}
|
|
31
|
+
export declare const defaultSubscribeDeps: SubscribeDeps;
|
|
32
|
+
export declare function fetchWhoami(environment: Environment, token: string, deps: SubscribeDeps): Promise<WhoamiResponse>;
|
|
33
|
+
export interface SubscribeOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Do not launch a browser — print the URL instead. Set under `--json`: an
|
|
36
|
+
* agent tool's machine spawning a window unasked is surprising, and the URL
|
|
37
|
+
* is the actionable thing there. `BITMAGIC_NO_OPEN` is honoured separately,
|
|
38
|
+
* inside openInBrowser.
|
|
39
|
+
*/
|
|
40
|
+
noOpen?: boolean;
|
|
41
|
+
/** Skip the wait entirely and return as soon as checkout is open. */
|
|
42
|
+
noWait?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface SubscribeResult {
|
|
45
|
+
/** True when the subscription was confirmed active before we returned. */
|
|
46
|
+
pro: boolean;
|
|
47
|
+
/** The checkout URL, when one was created (absent if already subscribed). */
|
|
48
|
+
checkoutUrl?: string;
|
|
49
|
+
/** Why we stopped waiting, when we did not confirm. */
|
|
50
|
+
reason?: 'timeout' | 'not-waited';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Explain that Pro is required, open checkout, and wait for it to land.
|
|
54
|
+
*
|
|
55
|
+
* Returns rather than throwing when the creator does not finish: abandoning
|
|
56
|
+
* checkout is a decision, not an error, and the credentials from a successful
|
|
57
|
+
* login are still worth keeping.
|
|
58
|
+
*/
|
|
59
|
+
export declare function runSubscribeFlow(environment: Environment, token: string, output: Output, options?: SubscribeOptions, deps?: SubscribeDeps): Promise<SubscribeResult>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting a logged-in creator from "no subscription" to "ready to work".
|
|
3
|
+
*
|
|
4
|
+
* The Bitmagic CLI requires an active Bitmagic Pro subscription, so for a new
|
|
5
|
+
* creator the very first command would otherwise be a 403. Rather than print an
|
|
6
|
+
* error and a URL to retype, the CLI creates the Stripe Checkout session itself
|
|
7
|
+
* and opens it: `bitmagic login` flows straight from the device-code approval
|
|
8
|
+
* into paying, in the same browser, and then confirms.
|
|
9
|
+
*
|
|
10
|
+
* Two api-server routes make this possible, and both live OUTSIDE the CLI's
|
|
11
|
+
* entitlement gate for exactly this reason (see cli-onboarding-routes.ts):
|
|
12
|
+
* `GET /whoami` answers whether the caller is entitled, and
|
|
13
|
+
* `POST /pro/checkout` mints a checkout URL for the caller's own account.
|
|
14
|
+
*
|
|
15
|
+
* Shared by `login` and by `subscribe`, so a creator who abandoned checkout
|
|
16
|
+
* gets an identical second run rather than a different-looking recovery path.
|
|
17
|
+
*/
|
|
18
|
+
import { apiGet, apiPost } from '../http/client.js';
|
|
19
|
+
import { openInBrowser } from '../open-browser.js';
|
|
20
|
+
/** How long to wait for the webhook to land the subscription before giving up. */
|
|
21
|
+
export const SUBSCRIBE_POLL_TIMEOUT_MS = 15 * 60_000;
|
|
22
|
+
export const SUBSCRIBE_POLL_INTERVAL_MS = 3_000;
|
|
23
|
+
/**
|
|
24
|
+
* PURE. One line describing where the caller's subscription stands.
|
|
25
|
+
*
|
|
26
|
+
* Covers the case a status boolean cannot: a subscription that is live TODAY
|
|
27
|
+
* but set not to renew. Finding that out when a command is refused mid-work is
|
|
28
|
+
* the worst possible moment, so every command that greets the creator says it.
|
|
29
|
+
*/
|
|
30
|
+
export function describeProStatus(me) {
|
|
31
|
+
const day = (iso) => iso.slice(0, 10);
|
|
32
|
+
if (me.pro) {
|
|
33
|
+
if (!me.proUntil)
|
|
34
|
+
return 'Bitmagic Pro is active.';
|
|
35
|
+
return me.cancelAtPeriodEnd === true
|
|
36
|
+
? `Bitmagic Pro is active until ${day(me.proUntil)} and will NOT renew — \`bitmagic subscribe\` to keep it.`
|
|
37
|
+
: `Bitmagic Pro is active. Renews ${day(me.proUntil)}.`;
|
|
38
|
+
}
|
|
39
|
+
return me.proUntil
|
|
40
|
+
? `Bitmagic Pro ended on ${day(me.proUntil)}.`
|
|
41
|
+
: 'No Bitmagic Pro subscription.';
|
|
42
|
+
}
|
|
43
|
+
export const defaultSubscribeDeps = {
|
|
44
|
+
fetch: globalThis.fetch,
|
|
45
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
46
|
+
now: () => Date.now(),
|
|
47
|
+
openInBrowser,
|
|
48
|
+
};
|
|
49
|
+
export function fetchWhoami(environment, token, deps) {
|
|
50
|
+
return apiGet(environment, '/api/cli/v1/whoami', token, { fetch: deps.fetch });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Explain that Pro is required, open checkout, and wait for it to land.
|
|
54
|
+
*
|
|
55
|
+
* Returns rather than throwing when the creator does not finish: abandoning
|
|
56
|
+
* checkout is a decision, not an error, and the credentials from a successful
|
|
57
|
+
* login are still worth keeping.
|
|
58
|
+
*/
|
|
59
|
+
export async function runSubscribeFlow(environment, token, output, options = {}, deps = defaultSubscribeDeps) {
|
|
60
|
+
const checkout = await apiPost(environment, '/api/cli/v1/pro/checkout', token, {}, {
|
|
61
|
+
fetch: deps.fetch,
|
|
62
|
+
});
|
|
63
|
+
output.info('');
|
|
64
|
+
output.info('The Bitmagic CLI needs a Bitmagic Pro subscription.');
|
|
65
|
+
output.info('Pro gives you a weekly and a 5-hour spark allowance that refill on their own,');
|
|
66
|
+
output.info('and pays for generating assets, cover art and worlds.');
|
|
67
|
+
output.info('');
|
|
68
|
+
// Always print the URL, opened or not: a printed URL works on a machine with
|
|
69
|
+
// no browser, in a container, and in a log an agent reads back later.
|
|
70
|
+
const opened = options.noOpen === true
|
|
71
|
+
? false
|
|
72
|
+
: deps.openInBrowser(checkout.url, { log: (m) => output.info(m) });
|
|
73
|
+
output.info(opened ? `Opening checkout in your browser:\n ${checkout.url}` : `Subscribe at:\n ${checkout.url}`);
|
|
74
|
+
if (options.noWait === true) {
|
|
75
|
+
return { pro: false, checkoutUrl: checkout.url, reason: 'not-waited' };
|
|
76
|
+
}
|
|
77
|
+
output.info('');
|
|
78
|
+
output.info('Waiting for your subscription… (Ctrl-C is safe — run `bitmagic subscribe` to resume)');
|
|
79
|
+
const deadline = deps.now() + SUBSCRIBE_POLL_TIMEOUT_MS;
|
|
80
|
+
while (deps.now() < deadline) {
|
|
81
|
+
await deps.sleep(SUBSCRIBE_POLL_INTERVAL_MS);
|
|
82
|
+
// A transient failure mid-poll must not end the flow — the creator may
|
|
83
|
+
// still be typing their card in. Only a definitive "yes" stops the loop.
|
|
84
|
+
let me = null;
|
|
85
|
+
try {
|
|
86
|
+
me = await fetchWhoami(environment, token, deps);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (me.pro) {
|
|
92
|
+
output.info('');
|
|
93
|
+
output.info('Bitmagic Pro is active. You are ready — try `bitmagic init`.');
|
|
94
|
+
return { pro: true, checkoutUrl: checkout.url };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
output.info('');
|
|
98
|
+
output.info('Still waiting on Stripe. Run `bitmagic usage` once it completes, or');
|
|
99
|
+
output.info('`bitmagic subscribe` to start again.');
|
|
100
|
+
return { pro: false, checkoutUrl: checkout.url, reason: 'timeout' };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=subscribe-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-flow.js","sourceRoot":"","sources":["../../src/auth/subscribe-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAahD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,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KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC7C,uEAAuE;QACvE,yEAAyE;QACzE,IAAI,EAAE,GAA0B,IAAI,CAAC;QACrC,IAAI,CAAC;YACH,EAAE,GAAG,MAAM,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;YAC5E,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChB,MAAM,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IACnF,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACpD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACtE,CAAC"}
|
package/dist/browser-gl.d.ts
CHANGED
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
*/
|
|
37
37
|
/** `process.platform`, named so callers can pass one in without pulling in the `NodeJS` global. */
|
|
38
38
|
export type Platform = typeof process.platform;
|
|
39
|
+
/** The renderer the game is asked to boot with (`?renderer=` — RendererPreference.ts in the
|
|
40
|
+
* engine). Distinct from what actually drives the canvas: a WebGPURenderer whose adapter never
|
|
41
|
+
* came up runs its WebGL2 fallback backend, which is exactly what verify now detects. */
|
|
42
|
+
export type RendererChoice = 'webgpu' | 'webgl';
|
|
39
43
|
/**
|
|
40
44
|
* Chrome flags for the GL backend, given the environment and platform.
|
|
41
45
|
*
|
|
@@ -48,3 +52,22 @@ export type Platform = typeof process.platform;
|
|
|
48
52
|
* for Vulkan would take that away.
|
|
49
53
|
*/
|
|
50
54
|
export declare function browserGlArgs(env: Record<string, string | undefined>, platform?: Platform): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Chrome flags for booting the game on a specific renderer, given the environment and platform.
|
|
57
|
+
*
|
|
58
|
+
* For WebGL this is exactly `browserGlArgs`. For WebGPU it additionally permits the API in
|
|
59
|
+
* headless Chrome, where `navigator.gpu` otherwise exists but never yields an adapter — the game
|
|
60
|
+
* then silently runs three's WebGL2 fallback backend, which is precisely the undetected state
|
|
61
|
+
* verify exists to catch.
|
|
62
|
+
*/
|
|
63
|
+
export declare function browserRendererArgs(env: Record<string, string | undefined>, renderer: RendererChoice, platform?: Platform): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Whether a failed run is worth one automatic re-run on software GL.
|
|
66
|
+
*
|
|
67
|
+
* A lost WebGL context is a property of the machine's GPU/driver/compositor stack, not of the
|
|
68
|
+
* game (see the file header) — the software path sidesteps that stack entirely. Pointless when
|
|
69
|
+
* software GL was already in effect, which is what the env checks establish.
|
|
70
|
+
*/
|
|
71
|
+
export declare function shouldRetrySoftwareGl(observations: {
|
|
72
|
+
webglContextLost: boolean;
|
|
73
|
+
}, env: Record<string, string | undefined>): boolean;
|
package/dist/browser-gl.js
CHANGED
|
@@ -65,4 +65,54 @@ export function browserGlArgs(env, platform = process.platform) {
|
|
|
65
65
|
'--enable-unsafe-swiftshader',
|
|
66
66
|
];
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Chrome flags for booting the game on a specific renderer, given the environment and platform.
|
|
70
|
+
*
|
|
71
|
+
* For WebGL this is exactly `browserGlArgs`. For WebGPU it additionally permits the API in
|
|
72
|
+
* headless Chrome, where `navigator.gpu` otherwise exists but never yields an adapter — the game
|
|
73
|
+
* then silently runs three's WebGL2 fallback backend, which is precisely the undetected state
|
|
74
|
+
* verify exists to catch.
|
|
75
|
+
*/
|
|
76
|
+
export function browserRendererArgs(env, renderer, platform = process.platform) {
|
|
77
|
+
const base = browserGlArgs(env, platform);
|
|
78
|
+
if (renderer !== 'webgpu')
|
|
79
|
+
return base;
|
|
80
|
+
return mergeEnableFeatures([...base, '--enable-unsafe-webgpu'], ['WebGPU']);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Append feature-flag values as ONE `--enable-features` argument, merged with any already present.
|
|
84
|
+
*
|
|
85
|
+
* Not cosmetic: Chrome keeps only the LAST `--enable-features` flag it sees, so naively appending
|
|
86
|
+
* `--enable-features=WebGPU` after the Linux GL args would silently drop `Vulkan` — the flag that
|
|
87
|
+
* keeps rendering off SwiftShader — and the run would slow to a crawl with nothing announcing why.
|
|
88
|
+
*/
|
|
89
|
+
function mergeEnableFeatures(args, features) {
|
|
90
|
+
const PREFIX = '--enable-features=';
|
|
91
|
+
const merged = [];
|
|
92
|
+
for (const arg of args) {
|
|
93
|
+
if (!arg.startsWith(PREFIX))
|
|
94
|
+
continue;
|
|
95
|
+
for (const value of arg.slice(PREFIX.length).split(',')) {
|
|
96
|
+
if (value !== '' && !merged.includes(value))
|
|
97
|
+
merged.push(value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
for (const value of features) {
|
|
101
|
+
if (!merged.includes(value))
|
|
102
|
+
merged.push(value);
|
|
103
|
+
}
|
|
104
|
+
return [...args.filter((arg) => !arg.startsWith(PREFIX)), `${PREFIX}${merged.join(',')}`];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether a failed run is worth one automatic re-run on software GL.
|
|
108
|
+
*
|
|
109
|
+
* A lost WebGL context is a property of the machine's GPU/driver/compositor stack, not of the
|
|
110
|
+
* game (see the file header) — the software path sidesteps that stack entirely. Pointless when
|
|
111
|
+
* software GL was already in effect, which is what the env checks establish.
|
|
112
|
+
*/
|
|
113
|
+
export function shouldRetrySoftwareGl(observations, env) {
|
|
114
|
+
return (observations.webglContextLost
|
|
115
|
+
&& env.CI !== 'true'
|
|
116
|
+
&& env.BITMAGIC_BROWSER_SOFTWARE_GL !== 'true');
|
|
117
|
+
}
|
|
68
118
|
//# sourceMappingURL=browser-gl.js.map
|
package/dist/browser-gl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-gl.js","sourceRoot":"","sources":["../src/browser-gl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;
|
|
1
|
+
{"version":3,"file":"browser-gl.js","sourceRoot":"","sources":["../src/browser-gl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAUH,oGAAoG;AACpG,MAAM,gBAAgB,GAAG,CAAC,6BAA6B,EAAE,gBAAgB,EAAE,yBAAyB,CAAC,CAAC;AAEtG;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAuC,EACvC,WAAqB,OAAO,CAAC,QAAQ;IAErC,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM,IAAI,GAAG,CAAC,4BAA4B,KAAK,MAAM;QAAE,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC;IACnG,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;IACjE,OAAO;QACL,oBAAoB;QACpB,0BAA0B;QAC1B,6FAA6F;QAC7F,uEAAuE;QACvE,wBAAwB;QACxB,cAAc;QACd,2FAA2F;QAC3F,mBAAmB;QACnB,2BAA2B;QAC3B,6BAA6B;KAC9B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAuC,EACvC,QAAwB,EACxB,WAAqB,OAAO,CAAC,QAAQ;IAErC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1C,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,mBAAmB,CAAC,CAAC,GAAG,I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38,34 @@ declare const rawCommands: {
|
|
|
38
38
|
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
39
39
|
};
|
|
40
40
|
}>;
|
|
41
|
+
subscribe: CommandDef<{
|
|
42
|
+
readonly env: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly description: "Environment to subscribe in (dev, prod, local).";
|
|
45
|
+
};
|
|
46
|
+
readonly 'no-wait': {
|
|
47
|
+
readonly type: "boolean";
|
|
48
|
+
readonly description: "Open checkout and exit instead of waiting for it to complete.";
|
|
49
|
+
};
|
|
50
|
+
readonly json: {
|
|
51
|
+
readonly type: "boolean";
|
|
52
|
+
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
usage: CommandDef<{
|
|
56
|
+
readonly days: {
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
readonly description: "How many days to report on (default 30, max 90).";
|
|
59
|
+
};
|
|
60
|
+
readonly env: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
readonly description: "Environment to query (dev, prod, local).";
|
|
63
|
+
};
|
|
64
|
+
readonly json: {
|
|
65
|
+
readonly type: "boolean";
|
|
66
|
+
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
41
69
|
init: CommandDef<{
|
|
42
70
|
readonly dir: {
|
|
43
71
|
readonly type: "positional";
|
|
@@ -116,7 +144,19 @@ declare const rawCommands: {
|
|
|
116
144
|
verify: CommandDef<{
|
|
117
145
|
readonly timeout: {
|
|
118
146
|
readonly type: "string";
|
|
119
|
-
readonly description:
|
|
147
|
+
readonly description: string;
|
|
148
|
+
};
|
|
149
|
+
readonly renderer: {
|
|
150
|
+
readonly type: "string";
|
|
151
|
+
readonly description: "Renderer to boot the game with: webgpu (default, what players run) or webgl.";
|
|
152
|
+
};
|
|
153
|
+
readonly fast: {
|
|
154
|
+
readonly type: "boolean";
|
|
155
|
+
readonly description: string;
|
|
156
|
+
};
|
|
157
|
+
readonly watch: {
|
|
158
|
+
readonly type: "boolean";
|
|
159
|
+
readonly description: string;
|
|
120
160
|
};
|
|
121
161
|
readonly json: {
|
|
122
162
|
readonly type: "boolean";
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,8 @@ import { jsonErrorResult } from './output.js';
|
|
|
4
4
|
import { loginCommand } from './commands/login.js';
|
|
5
5
|
import { logoutCommand } from './commands/logout.js';
|
|
6
6
|
import { whoamiCommand } from './commands/whoami.js';
|
|
7
|
+
import { usageCommand } from './commands/usage.js';
|
|
8
|
+
import { subscribeCommand } from './commands/subscribe.js';
|
|
7
9
|
import { initCommand } from './commands/init.js';
|
|
8
10
|
import { upgradeCommand } from './commands/upgrade.js';
|
|
9
11
|
import { checkCommand } from './commands/check.js';
|
|
@@ -99,6 +101,8 @@ const rawCommands = {
|
|
|
99
101
|
login: loginCommand,
|
|
100
102
|
logout: logoutCommand,
|
|
101
103
|
whoami: whoamiCommand,
|
|
104
|
+
subscribe: subscribeCommand,
|
|
105
|
+
usage: usageCommand,
|
|
102
106
|
init: initCommand,
|
|
103
107
|
upgrade: upgradeCommand,
|
|
104
108
|
check: checkCommand,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,E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IF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAC1C,MAAM,CAAC,OAAO,CAAC,WAAW,CAA+C,CAAC,GAAG,CAC5E,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CACtD,CAC0C,CAAC;AAE9C,iGAAiG;AACjG,8FAA8F;AAC9F,uFAAuF;AACvF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC;IAChC,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,gDAAgD;KAC9D;IACD,WAAW;CACZ,CAAC,CAAC"}
|
package/dist/commands/login.js
CHANGED
|
@@ -2,7 +2,7 @@ import { defineCommand } from 'citty';
|
|
|
2
2
|
import { resolveEnvironment, resolveAuth0ClientId } from '../config/environments.js';
|
|
3
3
|
import { writeCredentials, writeDefaultEnvironment, readDefaultEnvironment } from '../config/credentials.js';
|
|
4
4
|
import { requestDeviceCode, pollForToken } from '../auth/device-flow.js';
|
|
5
|
-
import {
|
|
5
|
+
import { fetchWhoami, runSubscribeFlow, defaultSubscribeDeps, describeProStatus } from '../auth/subscribe-flow.js';
|
|
6
6
|
import { createOutput } from '../output.js';
|
|
7
7
|
const deps = {
|
|
8
8
|
fetch: globalThis.fetch,
|
|
@@ -35,11 +35,39 @@ export const loginCommand = defineCommand({
|
|
|
35
35
|
writeCredentials(environment.name, credentials);
|
|
36
36
|
writeDefaultEnvironment(environment.name);
|
|
37
37
|
// Prove the login rather than assuming it: a token Auth0 accepted is not the same as an
|
|
38
|
-
// account api-server
|
|
39
|
-
|
|
38
|
+
// account api-server admits to the CLI, which requires an active Bitmagic Pro subscription.
|
|
39
|
+
// whoami sits OUTSIDE that gate precisely so this answer exists for someone who has not
|
|
40
|
+
// subscribed yet — otherwise the first thing a new creator would meet is a 403.
|
|
41
|
+
const me = await fetchWhoami(environment, credentials.accessToken, defaultSubscribeDeps);
|
|
40
42
|
output.info(`Logged in to ${environment.name} as ${me.userId}.`);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
if (me.pro) {
|
|
44
|
+
// Says "renews on X" — or warns when it will not, which is the only
|
|
45
|
+
// chance to mention that before a command is refused mid-work.
|
|
46
|
+
output.info(describeProStatus(me));
|
|
47
|
+
output.result({
|
|
48
|
+
ok: true, environment: environment.name, userId: me.userId, roles: me.roles,
|
|
49
|
+
pro: true, proUntil: me.proUntil, cancelAtPeriodEnd: me.cancelAtPeriodEnd ?? false,
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// A returning creator whose subscription lapsed should be told so, not
|
|
54
|
+
// greeted as though they had never subscribed.
|
|
55
|
+
if (me.proUntil)
|
|
56
|
+
output.info(describeProStatus(me));
|
|
57
|
+
// Not subscribed: carry straight on into checkout rather than ending on an
|
|
58
|
+
// error the creator has to decode. They are already in a browser — they
|
|
59
|
+
// just approved a device code in one.
|
|
60
|
+
const subscribed = await runSubscribeFlow(environment, credentials.accessToken, output, {
|
|
61
|
+
noOpen: args.json === true,
|
|
62
|
+
});
|
|
63
|
+
output.result({
|
|
64
|
+
ok: true,
|
|
65
|
+
environment: environment.name,
|
|
66
|
+
userId: me.userId,
|
|
67
|
+
roles: me.roles,
|
|
68
|
+
pro: subscribed.pro,
|
|
69
|
+
...(subscribed.checkoutUrl ? { checkoutUrl: subscribed.checkoutUrl } : {}),
|
|
70
|
+
});
|
|
43
71
|
},
|
|
44
72
|
});
|
|
45
73
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,gBAAgB,E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AI,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK;gBAC3E,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,IAAI,KAAK;aACnF,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,uEAAuE;QACvE,+CAA+C;QAC/C,IAAI,EAAE,CAAC,QAAQ;YAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;QAEpD,2EAA2E;QAC3E,wEAAwE;QACxE,sCAAsC;QACtC,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE;YACtF,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI;SAC3B,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC;YACZ,EAAE,EAAE,IAAI;YACR,WAAW,EAAE,WAAW,CAAC,IAAI;YAC7B,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3E,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const subscribeCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly env: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly description: "Environment to subscribe in (dev, prod, local).";
|
|
5
|
+
};
|
|
6
|
+
readonly 'no-wait': {
|
|
7
|
+
readonly type: "boolean";
|
|
8
|
+
readonly description: "Open checkout and exit instead of waiting for it to complete.";
|
|
9
|
+
};
|
|
10
|
+
readonly json: {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import { resolveEnvironment, resolveAuth0ClientId } from '../config/environments.js';
|
|
3
|
+
import { readDefaultEnvironment } from '../config/credentials.js';
|
|
4
|
+
import { getAccessToken } from '../auth/session.js';
|
|
5
|
+
import { fetchWhoami, runSubscribeFlow, defaultSubscribeDeps } from '../auth/subscribe-flow.js';
|
|
6
|
+
import { createOutput } from '../output.js';
|
|
7
|
+
/**
|
|
8
|
+
* `bitmagic subscribe` — start (or finish) a Bitmagic Pro subscription.
|
|
9
|
+
*
|
|
10
|
+
* `login` already runs this flow for a creator who has not subscribed, so this
|
|
11
|
+
* command exists for the second attempt: someone who closed the checkout tab,
|
|
12
|
+
* whose card was declined, or whose subscription has since lapsed. Same code
|
|
13
|
+
* path, so the recovery looks exactly like the first run rather than being a
|
|
14
|
+
* differently-worded special case.
|
|
15
|
+
*/
|
|
16
|
+
const deviceFlowDeps = { fetch: globalThis.fetch, sleep: (ms) => new Promise((r) => setTimeout(r, ms)) };
|
|
17
|
+
export const subscribeCommand = defineCommand({
|
|
18
|
+
meta: { name: 'subscribe', description: 'Start a Bitmagic Pro subscription, which the CLI requires.' },
|
|
19
|
+
args: {
|
|
20
|
+
env: { type: 'string', description: 'Environment to subscribe in (dev, prod, local).' },
|
|
21
|
+
'no-wait': { type: 'boolean', description: 'Open checkout and exit instead of waiting for it to complete.' },
|
|
22
|
+
json: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
description: 'Print the result as JSON on stdout; all progress goes to stderr.',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
async run({ args }) {
|
|
28
|
+
const output = createOutput(args.json === true);
|
|
29
|
+
const environment = resolveEnvironment({
|
|
30
|
+
explicit: args.env,
|
|
31
|
+
storedDefault: readDefaultEnvironment(),
|
|
32
|
+
});
|
|
33
|
+
const clientId = resolveAuth0ClientId(environment);
|
|
34
|
+
const token = await getAccessToken(environment, clientId, deviceFlowDeps);
|
|
35
|
+
const me = await fetchWhoami(environment, token, defaultSubscribeDeps);
|
|
36
|
+
if (me.pro) {
|
|
37
|
+
// Nothing to sell. Say when it renews rather than "already subscribed",
|
|
38
|
+
// which is the question behind the question.
|
|
39
|
+
const until = me.proUntil ? ` Renews ${me.proUntil.slice(0, 10)}.` : '';
|
|
40
|
+
output.info(`Bitmagic Pro is already active for ${me.userId}.${until}`);
|
|
41
|
+
output.result({ ok: true, pro: true, userId: me.userId, proUntil: me.proUntil ?? null });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (me.proUntil) {
|
|
45
|
+
output.info(`Your previous Bitmagic Pro subscription ended on ${me.proUntil.slice(0, 10)}.`);
|
|
46
|
+
}
|
|
47
|
+
const result = await runSubscribeFlow(environment, token, output, {
|
|
48
|
+
noOpen: args.json === true,
|
|
49
|
+
noWait: args['no-wait'] === true,
|
|
50
|
+
});
|
|
51
|
+
output.result({
|
|
52
|
+
ok: true,
|
|
53
|
+
pro: result.pro,
|
|
54
|
+
userId: me.userId,
|
|
55
|
+
...(result.checkoutUrl ? { checkoutUrl: result.checkoutUrl } : {}),
|
|
56
|
+
...(result.reason ? { reason: result.reason } : {}),
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=subscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,c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