@mpgd/cli 0.28.1 → 0.30.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.
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
- import { resolve } from 'node:path';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
 
4
5
  import ttsc from '@ttsc/unplugin/vite';
5
6
  import type { PluginOption } from 'vite';
@@ -8,6 +9,7 @@ import {
8
9
  assertRuntimeTargetConfigMatrix,
9
10
  type TargetConfigMatrix,
10
11
  } from './vite.runtime-target-config';
12
+ import { resolveTextSelectionMode } from './src/platform/textSelection';
11
13
 
12
14
  interface RuntimePlatformTargetMetadata {
13
15
  readonly kind: string;
@@ -39,9 +41,20 @@ export interface GameViteSharedConfig<SharedPluginOption> {
39
41
  readonly define: Record<string, string>;
40
42
  }
41
43
 
44
+ /** Fail ordinary Vite builds when mpgd.game.json declares an invalid ui policy. */
45
+ function readGameTextSelectionPolicy(): 'disabled' | 'enabled' {
46
+ const gameRoot = dirname(fileURLToPath(import.meta.url));
47
+ const gameConfig = JSON.parse(
48
+ readFileSync(resolve(gameRoot, 'mpgd.game.json'), 'utf8'),
49
+ ) as { readonly ui?: unknown };
50
+
51
+ return resolveTextSelectionMode(gameConfig.ui);
52
+ }
53
+
42
54
  export function createGameViteSharedConfig<SharedPluginOption = PluginOption>(
43
55
  input: CreateGameViteSharedConfigInput,
44
56
  ): GameViteSharedConfig<SharedPluginOption> {
57
+ readGameTextSelectionPolicy();
45
58
  const isProduction = input.mode === 'production';
46
59
  const appTarget = input.appTarget ?? process.env.APP_TARGET ?? 'browser';
47
60
  const configTarget = input.configTarget ?? process.env.MPGD_CONFIG_TARGET ?? '';