@ttmg/cli 0.4.8-alpha.0 → 0.4.9-alpha.0

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/dist/index.js CHANGED
@@ -18363,7 +18363,7 @@ async function authStatus(options = {}) {
18363
18363
  return result;
18364
18364
  }
18365
18365
 
18366
- var version = "0.4.8-alpha.0";
18366
+ var version = "0.4.9-alpha.0";
18367
18367
  var engines = {
18368
18368
  node: ">=20.19.1 <21 || >=22"
18369
18369
  };
@@ -23772,6 +23772,9 @@ const store = Store.getInstance({
23772
23772
  // 打包产出的屏幕配置(packageConfig.screen_config),没有时为 undefined
23773
23773
  screenConfig: undefined,
23774
23774
  isUnderCompiling: false,
23775
+ // Set once the startup compile has ended, success or failure. The IDE builds its
23776
+ // launch link from screenConfig, so it waits for this first.
23777
+ initialCompileSettled: false,
23775
23778
  isUnderUploading: false,
23776
23779
  isWaitingForUpload: false,
23777
23780
  projectInfo: {
@@ -24419,6 +24422,7 @@ async function compile(context) {
24419
24422
  if (!isSuccess) {
24420
24423
  store.setState({
24421
24424
  isUnderCompiling: false,
24425
+ initialCompileSettled: true,
24422
24426
  });
24423
24427
  wsServer.sendCompilationStatus('end', {
24424
24428
  errorMsg,
@@ -24443,6 +24447,7 @@ async function compile(context) {
24443
24447
  else {
24444
24448
  store.setState({
24445
24449
  isUnderCompiling: false,
24450
+ initialCompileSettled: true,
24446
24451
  packages,
24447
24452
  remoteCdnResources: msg.remoteCdnResources,
24448
24453
  screenConfig,
@@ -25514,11 +25519,40 @@ function buildCheckPkgsOptions(outputDir) {
25514
25519
  };
25515
25520
  }
25516
25521
 
25522
+ // Long enough for a large first pack; after it the route answers as before.
25523
+ const INITIAL_COMPILE_WAIT_MS = 60000;
25524
+ /**
25525
+ * Resolves once the startup compile of `ttmg dev` has ended, or after the timeout,
25526
+ * so the launch link is built from the packed screen_config.
25527
+ */
25528
+ function waitForInitialCompile(timeoutMs = INITIAL_COMPILE_WAIT_MS) {
25529
+ if (store.getState().initialCompileSettled) {
25530
+ return Promise.resolve();
25531
+ }
25532
+ return new Promise(resolve => {
25533
+ let unsubscribe = () => undefined;
25534
+ const timer = setTimeout(() => {
25535
+ unsubscribe();
25536
+ resolve();
25537
+ }, timeoutMs);
25538
+ unsubscribe = store.subscribe(state => {
25539
+ if (!state.initialCompileSettled)
25540
+ return;
25541
+ clearTimeout(timer);
25542
+ unsubscribe();
25543
+ resolve();
25544
+ });
25545
+ });
25546
+ }
25547
+
25517
25548
  const devToolVersion = getDevToolVersion();
25518
25549
  const gameConfigRoute = {
25519
25550
  method: 'get',
25520
25551
  path: '/game/config',
25521
25552
  handler: async (req, res) => {
25553
+ // `ttmg dev` opens the IDE before the startup compile, and the IDE reads this
25554
+ // route once. Answering early would drop the landscape launch query.
25555
+ await waitForInitialCompile();
25522
25556
  const [basic, checkResult] = await Promise.all([
25523
25557
  ttmgPack.getPkgs({ entryDir: process.cwd() }),
25524
25558
  ttmgPack.checkPkgs(buildCheckPkgsOptions(getOutputDir()), {