vibedgames 0.9.0 → 0.10.1
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 +3 -2
- package/assets/align-framing.py +242 -0
- package/assets/render-model.py +406 -0
- package/assets/tilemap-editor.html +630 -0
- package/dist/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/{chunk-56OY4TEP.js → chunk-2SBBKY5C.js} +1361 -4493
- package/dist/{chunk-FC233UKH.js → chunk-2ZKS7V72.js} +16 -16
- package/dist/chunk-37LLKM73.js +124 -0
- package/dist/{chunk-BMTHAVMS.js → chunk-3HGBIUM5.js} +22 -19
- package/dist/chunk-3UGGMFJJ.js +22 -0
- package/dist/{chunk-3HUWAJQH.js → chunk-42K3BJJH.js} +93 -76
- package/dist/{chunk-ST5FC2W3.js → chunk-43P4U7CB.js} +20 -11
- package/dist/chunk-4RYTTD4D.js +53 -0
- package/dist/{chunk-WSRIF6K4.js → chunk-4UU622RK.js} +5 -4
- package/dist/chunk-52E6EKZV.js +72 -0
- package/dist/chunk-6IUFHPMV.js +62 -0
- package/dist/chunk-6KXXZXSO.js +475 -0
- package/dist/chunk-72KHWZMN.js +87 -0
- package/dist/{chunk-ZCYWDKYP.js → chunk-A556KALN.js} +14 -13
- package/dist/{chunk-UFR6G6BL.js → chunk-ABTUEIRC.js} +554 -254
- package/dist/chunk-ALPTHSUT.js +132 -0
- package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
- package/dist/chunk-BJAN3RMY.js +48 -0
- package/dist/{chunk-HNRVSBRK.js → chunk-BN3Q7UEC.js} +20 -17
- package/dist/chunk-BZOMEG3X.js +412 -0
- package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
- package/dist/{chunk-KZBZNTM4.js → chunk-CTY2WZQK.js} +9 -13
- package/dist/chunk-DH6WPL3X.js +47 -0
- package/dist/chunk-DPLFCKXP.js +80 -0
- package/dist/{chunk-K2U7L4RU.js → chunk-E3FJUPLT.js} +15 -21
- package/dist/chunk-E7NDOZ27.js +428 -0
- package/dist/{chunk-TBQ5BU3Q.js → chunk-F42QKWBB.js} +18 -18
- package/dist/chunk-F4J6XCHT.js +73 -0
- package/dist/chunk-FB3UDZAV.js +168 -0
- package/dist/chunk-FJXPMA63.js +48 -0
- package/dist/chunk-FNJL6Z5C.js +71 -0
- package/dist/chunk-G63MXDX2.js +45 -0
- package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
- package/dist/{chunk-AXTLPJ2F.js → chunk-H2C4QUTG.js} +8 -7
- package/dist/{chunk-H3IPLBXQ.js → chunk-HRKVAXNN.js} +17 -14
- package/dist/chunk-HSCTPDEU.js +126 -0
- package/dist/{chunk-UXCWSWWX.js → chunk-HSMG6U7J.js} +8 -7
- package/dist/chunk-I5LELJSK.js +22 -0
- package/dist/{chunk-7CXMMC5S.js → chunk-JN4WZCR7.js} +5 -4
- package/dist/{chunk-7QZSDU52.js → chunk-K36EOII3.js} +5 -4
- package/dist/chunk-KLFBAFXD.js +25 -0
- package/dist/{chunk-355VG7EO.js → chunk-LONQWRTR.js} +107 -77
- package/dist/{chunk-Z5TFZQ5U.js → chunk-LORGE2NB.js} +68 -62
- package/dist/{chunk-LY2GQ32S.js → chunk-MEAO33XW.js} +22 -20
- package/dist/{chunk-OD2MNYXD.js → chunk-MR5KIFI7.js} +23 -22
- package/dist/{chunk-2VUUMXAQ.js → chunk-N2UHAQXC.js} +18 -11
- package/dist/chunk-NG2X3SMF.js +91 -0
- package/dist/chunk-OFJIG4K3.js +6482 -0
- package/dist/chunk-P74GTK23.js +91 -0
- package/dist/chunk-PKM3JOKQ.js +62 -0
- package/dist/{chunk-NDHXM4PL.js → chunk-Q3XQPNF6.js} +12 -12
- package/dist/{chunk-RXHTGX7C.js → chunk-Q5NZNXJE.js} +6 -10
- package/dist/chunk-QEKVZ7BX.js +57 -0
- package/dist/chunk-QNWCBPVO.js +215 -0
- package/dist/{chunk-US6QZICZ.js → chunk-RPJR3S5S.js} +32 -18
- package/dist/chunk-RPSUFZAG.js +3307 -0
- package/dist/chunk-RRI23NK2.js +40 -0
- package/dist/{chunk-6EWHKL7Z.js → chunk-SXYQL4GK.js} +7 -6
- package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
- package/dist/{chunk-UZM6OSW5.js → chunk-UPHB5HWO.js} +15 -13
- package/dist/chunk-UTSSDFQL.js +64 -0
- package/dist/chunk-V5ADM3WC.js +741 -0
- package/dist/{chunk-25BAMW5X.js → chunk-VIEKOGKG.js} +18 -2
- package/dist/chunk-VUV5U4J5.js +117 -0
- package/dist/{chunk-LXS3NJYD.js → chunk-VZEJ2ZHE.js} +14 -15
- package/dist/chunk-W2QPNAZ3.js +58 -0
- package/dist/chunk-YLUB6252.js +45 -0
- package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
- package/dist/chunk-YXOGRERG.js +91 -0
- package/dist/index.js +39 -36
- package/package.json +31 -16
- package/templates/none/src/main.ts +4 -0
- package/templates/none/vite.config.ts +0 -2
- package/templates/phaser/src/main.ts +0 -1
- package/templates/phaser/src/scenes/game-scene.ts +10 -8
- package/templates/phaser/vite.config.ts +0 -2
- package/templates/react-r3f/src/app.tsx +3 -1
- package/templates/react-r3f/src/main.tsx +1 -0
- package/templates/react-r3f/vite.config.ts +0 -2
- package/templates/threejs/src/main.ts +10 -1
- package/templates/threejs/vite.config.ts +0 -2
- package/LICENSE +0 -21
- package/dist/chunk-J6PKNPI2.js +0 -26
|
@@ -8,39 +8,41 @@ import {
|
|
|
8
8
|
ensureAgentBrowser,
|
|
9
9
|
projectSessionId,
|
|
10
10
|
resolveGameUrl
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-RPJR3S5S.js";
|
|
12
|
+
import "./chunk-N2UHAQXC.js";
|
|
13
|
+
import "./chunk-TMPBGXT4.js";
|
|
14
|
+
import {
|
|
15
|
+
assertKnownFlags
|
|
16
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
17
|
+
import "./chunk-JN4WZCR7.js";
|
|
14
18
|
import {
|
|
15
19
|
authErrorCode,
|
|
16
20
|
createClient
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-Z4Z24FWO.js";
|
|
20
|
-
import "./chunk-PEUP4MZR.js";
|
|
21
|
+
} from "./chunk-CTY2WZQK.js";
|
|
22
|
+
import "./chunk-E3FJUPLT.js";
|
|
21
23
|
import {
|
|
22
24
|
getBaseUrl,
|
|
23
25
|
getToken
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-5535KDYI.js";
|
|
26
|
-
import "./chunk-ZI6PKVXG.js";
|
|
26
|
+
} from "./chunk-Q5NZNXJE.js";
|
|
27
27
|
import {
|
|
28
28
|
outputArgs,
|
|
29
29
|
writeStructured
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-COSLGSVO.js";
|
|
31
31
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
32
|
+
defineCommand
|
|
33
|
+
} from "./chunk-MBXCVCC4.js";
|
|
34
|
+
import "./chunk-5535KDYI.js";
|
|
34
35
|
import {
|
|
35
36
|
consola
|
|
36
37
|
} from "./chunk-D2RF35HJ.js";
|
|
38
|
+
import "./chunk-YNCYMWER.js";
|
|
39
|
+
import "./chunk-AWJNAGPE.js";
|
|
37
40
|
import {
|
|
38
41
|
isJsonObject,
|
|
39
|
-
isJsonString
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} from "./chunk-MBXCVCC4.js";
|
|
42
|
+
isJsonString,
|
|
43
|
+
parseJson
|
|
44
|
+
} from "./chunk-RPSUFZAG.js";
|
|
45
|
+
import "./chunk-2SBBKY5C.js";
|
|
44
46
|
import "./chunk-GKDUYJ7R.js";
|
|
45
47
|
|
|
46
48
|
// src/lib/playtest/browser.ts
|
|
@@ -95,7 +97,7 @@ var GameBrowser = class {
|
|
|
95
97
|
}
|
|
96
98
|
let parsed;
|
|
97
99
|
try {
|
|
98
|
-
parsed =
|
|
100
|
+
parsed = parseJson(text);
|
|
99
101
|
} catch {
|
|
100
102
|
throw new HarnessError(`\`${args[0]} --json\` did not return JSON: ${text.slice(0, 200)}`);
|
|
101
103
|
}
|
|
@@ -116,12 +118,6 @@ var GameBrowser = class {
|
|
|
116
118
|
evaluate(expression) {
|
|
117
119
|
return this.payload(["eval", expression], "result");
|
|
118
120
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Navigate and wait for the diagnostics contract. Logs are cleared BEFORE
|
|
121
|
-
* navigating so boot errors belong to this run. Waits for the CONTRACT,
|
|
122
|
-
* not for frames: most games boot into a menu where the loop hasn't
|
|
123
|
-
* started, so frames only advance once setState('active-play') has run.
|
|
124
|
-
*/
|
|
125
121
|
boot(url, headed, whenAbsent) {
|
|
126
122
|
this.run(["console", "--clear"]);
|
|
127
123
|
this.run(["errors", "--clear"]);
|
|
@@ -133,12 +129,6 @@ var GameBrowser = class {
|
|
|
133
129
|
throw new HarnessError(whenAbsent);
|
|
134
130
|
}
|
|
135
131
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Two ways a game can honour a seed: a `seed()` hook that restarts the run,
|
|
138
|
-
* or a `?seed=` boot param for games whose scene is single-start. Calling
|
|
139
|
-
* an absent hook would leave the run unseeded while the report still
|
|
140
|
-
* claimed the seed, so detect which one this game implements.
|
|
141
|
-
*/
|
|
142
132
|
applySeed(seed, headed) {
|
|
143
133
|
const probe = this.evaluate(
|
|
144
134
|
"({ hasSeedHook: typeof window.__GAME_TEST_HOOKS__?.seed === 'function', href: location.href })"
|
|
@@ -363,11 +353,11 @@ var shiftedKey = (code, key) => {
|
|
|
363
353
|
};
|
|
364
354
|
var keyFields = (code) => {
|
|
365
355
|
const letter = /^Key(?<letter>[A-Z])$/u.exec(code)?.groups?.letter;
|
|
366
|
-
if (letter) {
|
|
356
|
+
if (letter !== void 0 && letter !== "") {
|
|
367
357
|
return [letter.codePointAt(0) ?? 0, letter.toLowerCase()];
|
|
368
358
|
}
|
|
369
359
|
const digit = /^Digit(?<digit>[0-9])$/u.exec(code)?.groups?.digit;
|
|
370
|
-
if (digit) {
|
|
360
|
+
if (digit !== void 0 && digit !== "") {
|
|
371
361
|
return [48 + Number(digit), digit];
|
|
372
362
|
}
|
|
373
363
|
const keyCode = NAMED_KEYS.get(code);
|
|
@@ -551,7 +541,7 @@ var parseControls = (raw, source) => {
|
|
|
551
541
|
moves[label] = readMoveOption(option, `${source} move.${label}`);
|
|
552
542
|
}
|
|
553
543
|
if (!Object.values(moves).some(
|
|
554
|
-
(option) => option.keys.length > 0 || option.pointer || option.reflex
|
|
544
|
+
(option) => option.keys.length > 0 || option.pointer !== null || option.reflex
|
|
555
545
|
)) {
|
|
556
546
|
fail(`${source}: no \`move\` option holds any input, so the playtester could never move.`);
|
|
557
547
|
}
|
|
@@ -593,7 +583,7 @@ var readControlsArg = (value) => {
|
|
|
593
583
|
}
|
|
594
584
|
let raw;
|
|
595
585
|
try {
|
|
596
|
-
raw =
|
|
586
|
+
raw = parseJson(text);
|
|
597
587
|
} catch (error) {
|
|
598
588
|
fail(
|
|
599
589
|
`--controls ${value} isn't valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -627,15 +617,35 @@ var browserEnv = () => {
|
|
|
627
617
|
return type === "pointerdown" ? "mousedown" : "mouseup";
|
|
628
618
|
};
|
|
629
619
|
let lastPointer = null;
|
|
620
|
+
const isJson = (value) => {
|
|
621
|
+
if (value === null || Number.isFinite(value)) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
if (Array.isArray(value)) {
|
|
625
|
+
return value.every((item) => isJson(item));
|
|
626
|
+
}
|
|
627
|
+
const tag = Object.prototype.toString.call(value);
|
|
628
|
+
return tag === "[object String]" || tag === "[object Boolean]" || tag === "[object Object]" && value instanceof Object && Object.values(value).every((item) => isJson(item));
|
|
629
|
+
};
|
|
630
|
+
const readJson = (text) => {
|
|
631
|
+
const value = JSON.parse(text);
|
|
632
|
+
if (!isJson(value)) {
|
|
633
|
+
throw new TypeError("not JSON");
|
|
634
|
+
}
|
|
635
|
+
return value;
|
|
636
|
+
};
|
|
630
637
|
const isFunction = (value) => Object.prototype.toString.call(value) === "[object Function]";
|
|
631
638
|
return {
|
|
632
|
-
caf: (id) =>
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
+
caf: (id) => {
|
|
640
|
+
window.cancelAnimationFrame(id);
|
|
641
|
+
},
|
|
642
|
+
delay: async (ms) => {
|
|
643
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
644
|
+
window.setTimeout(() => {
|
|
645
|
+
resolve(ms);
|
|
646
|
+
}, ms);
|
|
647
|
+
await promise;
|
|
648
|
+
},
|
|
639
649
|
dispatchKey: (type, init) => {
|
|
640
650
|
const target = document.activeElement ?? document.body ?? window;
|
|
641
651
|
target.dispatchEvent(new KeyboardEvent(type, init));
|
|
@@ -670,7 +680,7 @@ var browserEnv = () => {
|
|
|
670
680
|
target.dispatchEvent(new PointerEvent(type, init));
|
|
671
681
|
target.dispatchEvent(new MouseEvent(mouseType(type), init));
|
|
672
682
|
},
|
|
673
|
-
fetch: (url, init) => window.fetch(url, init),
|
|
683
|
+
fetch: async (url, init) => await window.fetch(url, init),
|
|
674
684
|
live: () => window.__GAME_DIAGNOSTICS__ ?? null,
|
|
675
685
|
now: () => Date.now(),
|
|
676
686
|
publish: (result) => {
|
|
@@ -684,7 +694,7 @@ var browserEnv = () => {
|
|
|
684
694
|
},
|
|
685
695
|
snapshot: () => {
|
|
686
696
|
try {
|
|
687
|
-
return
|
|
697
|
+
return readJson(JSON.stringify(window.__GAME_DIAGNOSTICS__ ?? null));
|
|
688
698
|
} catch {
|
|
689
699
|
return null;
|
|
690
700
|
}
|
|
@@ -693,6 +703,24 @@ var browserEnv = () => {
|
|
|
693
703
|
};
|
|
694
704
|
var inPageAgent = (config, env) => {
|
|
695
705
|
const isObject = (value) => Object(value) === value && !Array.isArray(value);
|
|
706
|
+
const isText = (value) => Object.prototype.toString.call(value) === "[object String]";
|
|
707
|
+
const isJson = (value) => {
|
|
708
|
+
if (value === null || Number.isFinite(value)) {
|
|
709
|
+
return true;
|
|
710
|
+
}
|
|
711
|
+
if (Array.isArray(value)) {
|
|
712
|
+
return value.every((item) => isJson(item));
|
|
713
|
+
}
|
|
714
|
+
const tag = Object.prototype.toString.call(value);
|
|
715
|
+
return tag === "[object String]" || tag === "[object Boolean]" || tag === "[object Object]" && value instanceof Object && Object.values(value).every((item) => isJson(item));
|
|
716
|
+
};
|
|
717
|
+
const readJson = (text) => {
|
|
718
|
+
const value = JSON.parse(text);
|
|
719
|
+
if (!isJson(value)) {
|
|
720
|
+
throw new TypeError("not JSON");
|
|
721
|
+
}
|
|
722
|
+
return value;
|
|
723
|
+
};
|
|
696
724
|
const round2 = (value) => Number(value.toFixed(2));
|
|
697
725
|
const started = env.now();
|
|
698
726
|
const usage = {
|
|
@@ -847,7 +875,7 @@ var inPageAgent = (config, env) => {
|
|
|
847
875
|
const parseDecision = (text, offered) => {
|
|
848
876
|
let body;
|
|
849
877
|
try {
|
|
850
|
-
body =
|
|
878
|
+
body = readJson(text);
|
|
851
879
|
} catch {
|
|
852
880
|
throw new Error(`decision response was not JSON: ${text.slice(0, 200)}`);
|
|
853
881
|
}
|
|
@@ -856,7 +884,7 @@ var inPageAgent = (config, env) => {
|
|
|
856
884
|
throw new Error(`decision response had no answers: ${text.slice(0, 200)}`);
|
|
857
885
|
}
|
|
858
886
|
const move2 = answerFor(answers, "move");
|
|
859
|
-
const choice =
|
|
887
|
+
const choice = isText(move2.choice) ? move2.choice : "";
|
|
860
888
|
if (!Object.hasOwn(offered, choice)) {
|
|
861
889
|
throw new Error(`decision model answered \`move\` outside the offered options: ${choice}`);
|
|
862
890
|
}
|
|
@@ -905,7 +933,7 @@ var inPageAgent = (config, env) => {
|
|
|
905
933
|
}
|
|
906
934
|
const offered = offeredMoves(state.tick.index);
|
|
907
935
|
const body = JSON.stringify({ model: config.model, questions: questions(offered), state });
|
|
908
|
-
|
|
936
|
+
const ask = async (attempt) => {
|
|
909
937
|
let response = null;
|
|
910
938
|
let failure = "";
|
|
911
939
|
try {
|
|
@@ -923,7 +951,7 @@ var inPageAgent = (config, env) => {
|
|
|
923
951
|
} catch (error) {
|
|
924
952
|
failure = error instanceof Error ? error.message : String(error);
|
|
925
953
|
}
|
|
926
|
-
if (response?.ok) {
|
|
954
|
+
if (response?.ok === true) {
|
|
927
955
|
const text = await response.text();
|
|
928
956
|
return parseDecision(text, offered);
|
|
929
957
|
}
|
|
@@ -936,14 +964,15 @@ var inPageAgent = (config, env) => {
|
|
|
936
964
|
throw new Error(`decision failed after ${attempt + 1} attempts: ${reason}`);
|
|
937
965
|
}
|
|
938
966
|
await env.delay(500 * 2 ** attempt);
|
|
939
|
-
|
|
967
|
+
return await ask(attempt + 1);
|
|
968
|
+
};
|
|
969
|
+
return await ask(0);
|
|
940
970
|
};
|
|
941
971
|
const pointerFrom = (input) => {
|
|
942
972
|
if (!input) {
|
|
943
973
|
return null;
|
|
944
974
|
}
|
|
945
|
-
const x =
|
|
946
|
-
const y = Number(input.y);
|
|
975
|
+
const { x, y } = input;
|
|
947
976
|
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
948
977
|
return null;
|
|
949
978
|
}
|
|
@@ -1080,17 +1109,16 @@ var inPageAgent = (config, env) => {
|
|
|
1080
1109
|
};
|
|
1081
1110
|
const run = async () => {
|
|
1082
1111
|
rafId = env.raf(frame);
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
break;
|
|
1112
|
+
const play = async (tick, game) => {
|
|
1113
|
+
if (tick >= config.ticks || stopped) {
|
|
1114
|
+
return;
|
|
1087
1115
|
}
|
|
1088
1116
|
const t0 = env.now();
|
|
1089
1117
|
const decision = await decide(stateFor(game, tick));
|
|
1090
1118
|
const decisionMs = env.now() - t0;
|
|
1091
1119
|
record(decision, decisionMs);
|
|
1092
1120
|
if (stopped) {
|
|
1093
|
-
|
|
1121
|
+
return;
|
|
1094
1122
|
}
|
|
1095
1123
|
if (pending) {
|
|
1096
1124
|
const remaining = config.tickMs - (env.now() - pending.appliedAt);
|
|
@@ -1116,13 +1144,14 @@ var inPageAgent = (config, env) => {
|
|
|
1116
1144
|
reflexStuck: false,
|
|
1117
1145
|
tick
|
|
1118
1146
|
};
|
|
1119
|
-
game = env.snapshot();
|
|
1120
1147
|
if (measured.complete) {
|
|
1121
1148
|
result.completedAtTick = Math.max(0, tick - 1);
|
|
1122
1149
|
pending = null;
|
|
1123
|
-
|
|
1150
|
+
return;
|
|
1124
1151
|
}
|
|
1125
|
-
|
|
1152
|
+
await play(tick + 1, env.snapshot());
|
|
1153
|
+
};
|
|
1154
|
+
await play(0, env.snapshot());
|
|
1126
1155
|
if (pending && !stopped) {
|
|
1127
1156
|
await env.delay(Math.max(config.tickMs, config.finalHoldMs));
|
|
1128
1157
|
const measured = flush();
|
|
@@ -1358,13 +1387,13 @@ var resultFromAgent = (published, epsilon = THRESHOLDS.displacement * THRESHOLDS
|
|
|
1358
1387
|
var runInPage = async (browser, opts, session) => {
|
|
1359
1388
|
browser.inject(agentSource(agentConfig(opts, session)));
|
|
1360
1389
|
const deadline = Date.now() + budgetMs(opts);
|
|
1361
|
-
|
|
1390
|
+
const waitForAgent = async () => {
|
|
1362
1391
|
const status = browser.agentStatus();
|
|
1363
1392
|
if (!status) {
|
|
1364
1393
|
throw new HarnessError("the page lost the agent; it probably navigated mid-run.");
|
|
1365
1394
|
}
|
|
1366
1395
|
if (status.done) {
|
|
1367
|
-
|
|
1396
|
+
return;
|
|
1368
1397
|
}
|
|
1369
1398
|
if (Date.now() > deadline) {
|
|
1370
1399
|
browser.stopAgent();
|
|
@@ -1373,11 +1402,16 @@ var runInPage = async (browser, opts, session) => {
|
|
|
1373
1402
|
);
|
|
1374
1403
|
}
|
|
1375
1404
|
await delay(POLL_MS);
|
|
1376
|
-
|
|
1405
|
+
await waitForAgent();
|
|
1406
|
+
};
|
|
1407
|
+
await waitForAgent();
|
|
1377
1408
|
return resultFromAgent(browser.agentResult(), motionEpsilon(opts.controls));
|
|
1378
1409
|
};
|
|
1379
1410
|
var summarizeProgress = (timeline) => {
|
|
1380
|
-
const scored = timeline.
|
|
1411
|
+
const scored = timeline.flatMap((entry) => {
|
|
1412
|
+
const p = entry.progress;
|
|
1413
|
+
return p === null ? [] : [p];
|
|
1414
|
+
});
|
|
1381
1415
|
const [first] = scored;
|
|
1382
1416
|
const last = scored.at(-1);
|
|
1383
1417
|
if (first === void 0 || last === void 0) {
|
|
@@ -1434,12 +1468,9 @@ var buildReport = (opts, input) => {
|
|
|
1434
1468
|
distanceTravelled: round(run.metrics.distance),
|
|
1435
1469
|
framesAdvanced: (last ? last.frame : before.frame) - before.frame,
|
|
1436
1470
|
goal: opts.controls.goal,
|
|
1437
|
-
// Which GPU rasterized the run. Under software rendering the functional
|
|
1438
|
-
// checks still hold; any frame-rate read from the run does not.
|
|
1439
1471
|
gpu: input.gpu,
|
|
1440
1472
|
longestStuckRun: run.metrics.longestStuckRun,
|
|
1441
1473
|
maxTickDisplacement: round(run.metrics.maxTickDisplacement),
|
|
1442
|
-
// The gate `maxTickDisplacement` was held to, so the number reads in context.
|
|
1443
1474
|
minDisplacement: displacementGate(opts.controls),
|
|
1444
1475
|
model: {
|
|
1445
1476
|
calls: run.usage.calls,
|
|
@@ -1453,8 +1484,6 @@ var buildReport = (opts, input) => {
|
|
|
1453
1484
|
scoreAfter: last ? last.score : before.score,
|
|
1454
1485
|
scoreBefore: before.score,
|
|
1455
1486
|
seed: input.seed,
|
|
1456
|
-
// How the seed actually landed, so a reader can tell a real seeded run
|
|
1457
|
-
// from one where the hook quietly did nothing.
|
|
1458
1487
|
seedApplied: input.seedApplied,
|
|
1459
1488
|
stuckTicks: run.metrics.stuckTicks,
|
|
1460
1489
|
target: input.target,
|
|
@@ -1585,13 +1614,17 @@ var numberArg = (raw, flag, check, hint) => {
|
|
|
1585
1614
|
}
|
|
1586
1615
|
return value;
|
|
1587
1616
|
};
|
|
1588
|
-
var
|
|
1589
|
-
|
|
1617
|
+
var isFilled = (value) => value !== void 0 && value !== "";
|
|
1618
|
+
var assertOneTarget = (args) => {
|
|
1619
|
+
if (!isFilled(args.url) && !isFilled(args.game)) {
|
|
1590
1620
|
throw new HarnessError("Pass --url <url> or --game <slug>.");
|
|
1591
1621
|
}
|
|
1592
|
-
if (args.url && args.game) {
|
|
1622
|
+
if (isFilled(args.url) && isFilled(args.game)) {
|
|
1593
1623
|
throw new HarnessError("Pass either --url or --game, not both.");
|
|
1594
1624
|
}
|
|
1625
|
+
};
|
|
1626
|
+
var settingsFrom = (args) => {
|
|
1627
|
+
assertOneTarget(args);
|
|
1595
1628
|
if (args.goal !== void 0 && args.goal.trim() === "") {
|
|
1596
1629
|
throw new HarnessError("`--goal` must not be empty.");
|
|
1597
1630
|
}
|
|
@@ -1613,7 +1646,7 @@ var settingsFrom = (args) => {
|
|
|
1613
1646
|
model: args.model,
|
|
1614
1647
|
pinMove: args.pinMove ?? null,
|
|
1615
1648
|
seed: numberArg(args.seed, "--seed", Number.isFinite, "a finite number"),
|
|
1616
|
-
target: args.game ? `game:${args.game}` : args.url ?? "",
|
|
1649
|
+
target: isFilled(args.game) ? `game:${args.game ?? ""}` : args.url ?? "",
|
|
1617
1650
|
tickMs: numberArg(
|
|
1618
1651
|
args.tickMs,
|
|
1619
1652
|
"--tick-ms",
|
|
@@ -1630,10 +1663,7 @@ var settingsFrom = (args) => {
|
|
|
1630
1663
|
};
|
|
1631
1664
|
};
|
|
1632
1665
|
var chooseControls = (settings, manifest) => {
|
|
1633
|
-
|
|
1634
|
-
if (!controls) {
|
|
1635
|
-
controls = manifest === null ? PRESETS.get(DEFAULT_PRESET) : parseControls(manifest, "window.__GAME_PLAYTEST__");
|
|
1636
|
-
}
|
|
1666
|
+
const controls = settings.explicitControls ?? (manifest === null ? PRESETS.get(DEFAULT_PRESET) : parseControls(manifest, "window.__GAME_PLAYTEST__"));
|
|
1637
1667
|
if (!controls) {
|
|
1638
1668
|
throw new HarnessError("no control scheme available.");
|
|
1639
1669
|
}
|
|
@@ -1708,7 +1738,7 @@ var playtestRunCommand = defineCommand({
|
|
|
1708
1738
|
consola.error(error instanceof Error ? error.message : String(error));
|
|
1709
1739
|
process.exit(HARNESS_FAILURE);
|
|
1710
1740
|
}
|
|
1711
|
-
if (
|
|
1741
|
+
if ((getToken() ?? "") === "") {
|
|
1712
1742
|
consola.warn("Not logged in. Run `vg login` to authenticate.");
|
|
1713
1743
|
process.exit(1);
|
|
1714
1744
|
}
|
|
@@ -4,39 +4,41 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import {
|
|
8
|
-
run
|
|
9
|
-
} from "./chunk-TBQ5BU3Q.js";
|
|
10
|
-
import "./chunk-5535KDYI.js";
|
|
11
7
|
import {
|
|
12
8
|
buildManifest,
|
|
13
9
|
contentTypeForPath,
|
|
14
10
|
resolveBuildDir
|
|
15
11
|
} from "./chunk-X75Y7LUW.js";
|
|
12
|
+
import {
|
|
13
|
+
run
|
|
14
|
+
} from "./chunk-F42QKWBB.js";
|
|
16
15
|
import {
|
|
17
16
|
SLUG_RE,
|
|
18
17
|
findProjectRoot,
|
|
19
18
|
projectConfigPath
|
|
20
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-TMPBGXT4.js";
|
|
20
|
+
import {
|
|
21
|
+
assertKnownFlags
|
|
22
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
21
23
|
import {
|
|
22
24
|
isJsonOutput,
|
|
23
25
|
outputArgs,
|
|
24
26
|
writeStructured
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-COSLGSVO.js";
|
|
26
28
|
import {
|
|
27
|
-
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
defineCommand
|
|
30
|
+
} from "./chunk-MBXCVCC4.js";
|
|
31
|
+
import "./chunk-5535KDYI.js";
|
|
29
32
|
import {
|
|
30
33
|
consola
|
|
31
34
|
} from "./chunk-D2RF35HJ.js";
|
|
32
35
|
import {
|
|
33
36
|
isJsonNumber,
|
|
34
37
|
isJsonObject,
|
|
35
|
-
isJsonString
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} from "./chunk-MBXCVCC4.js";
|
|
38
|
+
isJsonString,
|
|
39
|
+
parseJson
|
|
40
|
+
} from "./chunk-RPSUFZAG.js";
|
|
41
|
+
import "./chunk-2SBBKY5C.js";
|
|
40
42
|
import "./chunk-GKDUYJ7R.js";
|
|
41
43
|
|
|
42
44
|
// src/commands/distribute.ts
|
|
@@ -182,7 +184,11 @@ var fileNameFinding = ({ files, limits }) => {
|
|
|
182
184
|
}
|
|
183
185
|
];
|
|
184
186
|
};
|
|
185
|
-
var sdkFinding = ({
|
|
187
|
+
var sdkFinding = ({
|
|
188
|
+
files,
|
|
189
|
+
readText,
|
|
190
|
+
sdk
|
|
191
|
+
}) => {
|
|
186
192
|
if (sdk === null) {
|
|
187
193
|
return [];
|
|
188
194
|
}
|
|
@@ -254,7 +260,7 @@ var COLOR_RE = /^#[0-9a-fA-F]{6}$/u;
|
|
|
254
260
|
var DEFAULT_ICON = "icon.png";
|
|
255
261
|
var isOrientation = (value) => ORIENTATIONS.some((orientation) => orientation === value);
|
|
256
262
|
var readJson = (file) => {
|
|
257
|
-
const parsed =
|
|
263
|
+
const parsed = parseJson(readFileSync(file, "utf-8"));
|
|
258
264
|
if (!isJsonObject(parsed)) {
|
|
259
265
|
throw new Error(`${file} must hold a JSON object.`);
|
|
260
266
|
}
|
|
@@ -263,7 +269,7 @@ var readJson = (file) => {
|
|
|
263
269
|
var optionalString = (source, key, pattern, expected) => {
|
|
264
270
|
const value = source[key];
|
|
265
271
|
if (value === void 0) {
|
|
266
|
-
return
|
|
272
|
+
return value;
|
|
267
273
|
}
|
|
268
274
|
if (!isJsonString(value) || !pattern.test(value)) {
|
|
269
275
|
throw new Error(`vibedgames.json: distribute.${key} must be ${expected}.`);
|
|
@@ -338,7 +344,7 @@ var parseNative = (root, block) => {
|
|
|
338
344
|
};
|
|
339
345
|
var readDistributeProject = (dir) => {
|
|
340
346
|
const root = findProjectRoot(dir);
|
|
341
|
-
if (
|
|
347
|
+
if (root === null || root === "") {
|
|
342
348
|
throw new Error(
|
|
343
349
|
`No vibedgames.json at or above ${dir}. Create one: {"slug": "my-game", "name": "My Game"}`
|
|
344
350
|
);
|
|
@@ -504,12 +510,7 @@ var ORIENTATION_MASKS = {
|
|
|
504
510
|
};
|
|
505
511
|
var iosPlistEntries = (config) => {
|
|
506
512
|
const entries = {
|
|
507
|
-
// The shell speaks only HTTPS and WSS, which is the encryption Apple
|
|
508
|
-
// exempts; declared here so every upload does not stop to ask.
|
|
509
513
|
ITSAppUsesNonExemptEncryption: false,
|
|
510
|
-
// A game owns the whole screen. Without this an iPad build that does not
|
|
511
|
-
// offer all four orientations is refused at upload, since it could not
|
|
512
|
-
// take part in Split View.
|
|
513
514
|
UIRequiresFullScreen: true,
|
|
514
515
|
UIStatusBarHidden: true,
|
|
515
516
|
UISupportedInterfaceOrientations: ORIENTATION_MASKS[config.orientation],
|
|
@@ -580,7 +581,7 @@ var projectPackageManager = (root) => {
|
|
|
580
581
|
}
|
|
581
582
|
};
|
|
582
583
|
var readJsonObject = (file) => {
|
|
583
|
-
const parsed =
|
|
584
|
+
const parsed = parseJson(readFileSync2(file, "utf-8"));
|
|
584
585
|
if (!isJsonObject(parsed)) {
|
|
585
586
|
throw new Error(`${file} must hold a JSON object.`);
|
|
586
587
|
}
|
|
@@ -651,7 +652,7 @@ var writeCapacitorConfig = ({ project, native, buildDir }) => {
|
|
|
651
652
|
writeFileSync2(file, `${JSON.stringify(config, null, 2)}
|
|
652
653
|
`);
|
|
653
654
|
};
|
|
654
|
-
var cap = (root, args) => run("npx", ["--no-install", "cap", ...args], root);
|
|
655
|
+
var cap = async (root, args) => await run("npx", ["--no-install", "cap", ...args], root);
|
|
655
656
|
var rewrite = (file, transform) => {
|
|
656
657
|
if (!existsSync2(file)) {
|
|
657
658
|
throw new Error(`${file} is missing: delete the platform folder and run this again.`);
|
|
@@ -905,6 +906,7 @@ var checkToolchain = async (platform, env = process.env) => {
|
|
|
905
906
|
};
|
|
906
907
|
|
|
907
908
|
// src/lib/distribute/preview.ts
|
|
909
|
+
import { once } from "node:events";
|
|
908
910
|
import { createServer } from "node:http";
|
|
909
911
|
|
|
910
912
|
// ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
|
|
@@ -2014,20 +2016,16 @@ for (const button of document.querySelectorAll("button[data-a]")) {
|
|
|
2014
2016
|
}
|
|
2015
2017
|
</script></body></html>`;
|
|
2016
2018
|
};
|
|
2017
|
-
var listen = (server, port, host) =>
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
);
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
server.close(() => resolve());
|
|
2028
|
-
server.closeAllConnections();
|
|
2029
|
-
})
|
|
2030
|
-
);
|
|
2019
|
+
var listen = async (server, port, host) => {
|
|
2020
|
+
server.listen(port, host);
|
|
2021
|
+
await once(server, "listening");
|
|
2022
|
+
};
|
|
2023
|
+
var closeServer = async (server) => {
|
|
2024
|
+
const closed = once(server, "close");
|
|
2025
|
+
server.close();
|
|
2026
|
+
server.closeAllConnections();
|
|
2027
|
+
await closed;
|
|
2028
|
+
};
|
|
2031
2029
|
var send = (res, status, type, body, headers = {}) => {
|
|
2032
2030
|
res.writeHead(status, { "cache-control": "no-store", "content-type": type, ...headers });
|
|
2033
2031
|
res.end(body);
|
|
@@ -2071,7 +2069,9 @@ var startPreview = async ({ zip, portal, port }) => {
|
|
|
2071
2069
|
const gameUrl = `http://127.0.0.1:${port}${GAME_PATH}index.html`;
|
|
2072
2070
|
const page = previewPage(portal, gameUrl);
|
|
2073
2071
|
const game = createServer(serveGame);
|
|
2074
|
-
const host = createServer((_req, res) =>
|
|
2072
|
+
const host = createServer((_req, res) => {
|
|
2073
|
+
send(res, 200, "text/html; charset=utf-8", page);
|
|
2074
|
+
});
|
|
2075
2075
|
try {
|
|
2076
2076
|
await listen(game, port, "127.0.0.1");
|
|
2077
2077
|
await listen(host, port + 1, "localhost");
|
|
@@ -2134,8 +2134,9 @@ var fail = (message) => {
|
|
|
2134
2134
|
consola.error(message);
|
|
2135
2135
|
process.exit(1);
|
|
2136
2136
|
};
|
|
2137
|
-
var narrator = (args) => isJsonOutput(args) || Boolean(args.field) ? () => {
|
|
2138
|
-
|
|
2137
|
+
var narrator = (args) => isJsonOutput(args) || Boolean(args.field) ? () => null : (message) => {
|
|
2138
|
+
consola.info(message);
|
|
2139
|
+
};
|
|
2139
2140
|
var formatBytes2 = (bytes) => bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
2140
2141
|
var requireBuild = (dir) => {
|
|
2141
2142
|
if (!existsSync4(dir)) {
|
|
@@ -2290,8 +2291,12 @@ var servePreview = async (portal, zip, port) => {
|
|
|
2290
2291
|
await preview.close();
|
|
2291
2292
|
process.exit(0);
|
|
2292
2293
|
};
|
|
2293
|
-
process.once("SIGINT",
|
|
2294
|
-
|
|
2294
|
+
process.once("SIGINT", () => {
|
|
2295
|
+
void stop();
|
|
2296
|
+
});
|
|
2297
|
+
process.once("SIGTERM", () => {
|
|
2298
|
+
void stop();
|
|
2299
|
+
});
|
|
2295
2300
|
return { game_url: preview.gameUrl, sdk_stub: portal.integration !== null, url: preview.url };
|
|
2296
2301
|
};
|
|
2297
2302
|
var portalCommand = (portal) => defineCommand({
|
|
@@ -2372,6 +2377,13 @@ var requireNative = (dir, appId) => {
|
|
|
2372
2377
|
return fail(error instanceof Error ? error.message : String(error));
|
|
2373
2378
|
}
|
|
2374
2379
|
};
|
|
2380
|
+
var shellOrFail = async (input) => {
|
|
2381
|
+
try {
|
|
2382
|
+
return await prepareShell(input);
|
|
2383
|
+
} catch (error) {
|
|
2384
|
+
return fail(error instanceof Error ? error.message : String(error));
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2375
2387
|
var nativeCommand = (platform, store) => defineCommand({
|
|
2376
2388
|
args: nativeArgs,
|
|
2377
2389
|
meta: {
|
|
@@ -2384,12 +2396,7 @@ var nativeCommand = (platform, store) => defineCommand({
|
|
|
2384
2396
|
const dir = path5.resolve(args.dir);
|
|
2385
2397
|
const { project, native } = requireNative(dir, args["app-id"]);
|
|
2386
2398
|
const buildDir = requireBuild(project.root);
|
|
2387
|
-
|
|
2388
|
-
try {
|
|
2389
|
-
shell = await prepareShell({ buildDir, native, platform, project, say });
|
|
2390
|
-
} catch (error) {
|
|
2391
|
-
return fail(error instanceof Error ? error.message : String(error));
|
|
2392
|
-
}
|
|
2399
|
+
const shell = await shellOrFail({ buildDir, native, platform, project, say });
|
|
2393
2400
|
const toolchain = await checkToolchain(platform);
|
|
2394
2401
|
const result = {
|
|
2395
2402
|
app_id: native.appId,
|
|
@@ -2401,20 +2408,19 @@ var nativeCommand = (platform, store) => defineCommand({
|
|
|
2401
2408
|
toolchain_missing: toolchain.ready ? [] : toolchain.missing,
|
|
2402
2409
|
version: native.version
|
|
2403
2410
|
};
|
|
2404
|
-
if (writeStructured(result, args)) {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
)
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
consola.
|
|
2415
|
-
}
|
|
2416
|
-
consola.info(`Next:
|
|
2411
|
+
if (!writeStructured(result, args)) {
|
|
2412
|
+
consola.success(`${result.project} \u2014 ${native.appId} ${native.version} (${native.build})`);
|
|
2413
|
+
if (!shell.icon) {
|
|
2414
|
+
consola.warn(
|
|
2415
|
+
"Still the placeholder icon, which no store accepts. Add a square 1024px icon.png to the project (or set distribute.icon) and run this again."
|
|
2416
|
+
);
|
|
2417
|
+
}
|
|
2418
|
+
for (const missing of result.toolchain_missing) {
|
|
2419
|
+
consola.warn(missing);
|
|
2420
|
+
}
|
|
2421
|
+
consola.info(`Next:
|
|
2417
2422
|
${result.next.join("\n ")}`);
|
|
2423
|
+
}
|
|
2418
2424
|
}
|
|
2419
2425
|
});
|
|
2420
2426
|
var targetsArgs = { ...outputArgs };
|