@threenative/runtime-native 0.3.5 → 0.3.6

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/runtime-native",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "ThreeNative-owned native host for desktop and Android",
5
5
  "keywords": [
6
6
  "threenative",
@@ -78,15 +78,15 @@
78
78
  "publint": "0.3.22",
79
79
  "three": "0.185.1",
80
80
  "vitest": "4.1.10",
81
- "@threenative/playtest": "0.3.5"
81
+ "@threenative/playtest": "0.3.6"
82
82
  },
83
83
  "dependencies": {
84
84
  "pngjs": "7.0.0",
85
85
  "esbuild": "0.27.0",
86
86
  "typescript": "npm:@typescript/typescript6@6.0.2",
87
- "@threenative/assets": "0.3.6",
88
- "@threenative/core": "0.3.5",
89
- "@threenative/three-native": "0.3.5"
87
+ "@threenative/three-native": "0.3.6",
88
+ "@threenative/assets": "0.3.7",
89
+ "@threenative/core": "0.3.6"
90
90
  },
91
91
  "scripts": {
92
92
  "deps:download": "node scripts/download-deps.mjs",
@@ -328,6 +328,8 @@ void game.start().catch((error) => console.error(
328
328
  },
329
329
  };
330
330
  mkdirSync(dirname(absoluteOutput), { recursive: true });
331
+ // Read by the project's own `createWebBrandPlugin`: this bundle is not a browser's.
332
+ process.env.THREENATIVE_NATIVE_BUNDLE = target;
331
333
  await build({
332
334
  root: absoluteProject,
333
335
  define: { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) },
@@ -33,6 +33,20 @@ import { tmpdir } from 'node:os';
33
33
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
34
34
  import { buildWindowsInstaller } from './windows-installer.mjs';
35
35
 
36
+ /**
37
+ * The file to launch for a desktop artifact. `threenative build --target desktop` writes a
38
+ * container directory (`dist-native/<name>/` holding the player, `game.js` and a launcher named
39
+ * `<name>`); an older build wrote the executable itself. Launching the directory exits 126.
40
+ */
41
+ export function desktopLaunchTarget(artifact, executableName) {
42
+ return statSync(artifact).isDirectory() ? join(artifact, executableName) : artifact;
43
+ }
44
+
45
+ /** Whether the launcher's folder holds the owned engine player, which has no `--frames` or `--screenshot`. */
46
+ export function isEnginePlayerLaunch(launch) {
47
+ return readdirSync(dirname(launch)).some((file) => file.startsWith('tn-native-engine-player'));
48
+ }
49
+
36
50
  export const CONTAINER_MANIFEST = 'threenative-container.json';
37
51
  export const CONTAINER_SCHEMA_VERSION = 1;
38
52
  export const DESKTOP_TARGETS = ['linux-x64', 'linux-arm64', 'darwin-x64', 'darwin-arm64', 'win32-x64'];
@@ -6,6 +6,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, writeFi
6
6
  import { release as osRelease } from 'node:os';
7
7
  import { basename, join, resolve } from 'node:path';
8
8
  import { pathToFileURL } from 'node:url';
9
+ import { desktopLaunchTarget } from './desktop-distribution.mjs';
9
10
 
10
11
  export const CONSUMER_GAMEPLAY_SCENARIO = 'playtests/production-readiness.playtest.json';
11
12
  export const CONSUMER_REQUIRED_TARGETS = ['desktop', 'android'];
@@ -379,11 +380,11 @@ function discoverConsumerArtifact(projectRoot, target) {
379
380
  if (target === 'desktop') {
380
381
  const manifest = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'));
381
382
  const name = basename(String(manifest.name ?? 'starter').replace(/^@[^/]+\//u, ''));
382
- return join(
383
- projectRoot,
384
- 'dist-native',
385
- `${name}${process.platform === 'win32' ? '.exe' : ''}`,
386
- );
383
+ const executable = `${name}${process.platform === 'win32' ? '.exe' : ''}`;
384
+ const artifact = join(projectRoot, 'dist-native', executable);
385
+ // A missing artifact stays the caller's `ARTIFACT_MISSING`; a container directory (PRD-637) is
386
+ // run through its launcher.
387
+ return existsSync(artifact) ? desktopLaunchTarget(artifact, executable) : artifact;
387
388
  }
388
389
  const apks = consumerArtifactFiles(join(projectRoot, 'dist-native'), (file) => file.endsWith('.apk'));
389
390
  if (apks.length === 0) {
@@ -2,12 +2,18 @@
2
2
 
3
3
  import { spawnSync } from 'node:child_process';
4
4
  import { createHash } from 'node:crypto';
5
- import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
5
+ import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
6
6
  import { basename, dirname, join, resolve } from 'node:path';
7
7
  import { fileURLToPath, pathToFileURL } from 'node:url';
8
8
  import { PNG } from 'pngjs';
9
9
 
10
- import { parseLinkedLibraries, resolveContainer } from './desktop-distribution.mjs';
10
+ import {
11
+ desktopLaunchTarget,
12
+ isEnginePlayerLaunch,
13
+ parseLinkedLibraries,
14
+ resolveContainer,
15
+ } from './desktop-distribution.mjs';
16
+ import { verifyStarterConsumerGameplay } from './verify-starter-consumer.mjs';
11
17
  import { inspectContainerBrand } from './inspect-container-brand.mjs';
12
18
  import { inspectMacosIcon } from './inspect-macos-icon.mjs';
13
19
 
@@ -292,6 +298,8 @@ function judgeStarterRun({ artifact, brand, frames, log, logPath, reportPath, sc
292
298
  return report;
293
299
  }
294
300
 
301
+ export { desktopLaunchTarget };
302
+
295
303
  export function verifyStarterDesktop({ frames = 300, project = process.cwd() } = {}) {
296
304
  const projectRoot = resolve(project);
297
305
  const manifest = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'));
@@ -306,8 +314,22 @@ export function verifyStarterDesktop({ frames = 300, project = process.cwd() } =
306
314
  const logPath = join(artifactDirectory, 'starter-desktop.log');
307
315
  const reportPath = join(artifactDirectory, 'starter-desktop-report.json');
308
316
  mkdirSync(artifactDirectory, { recursive: true });
309
- const log = launchStarterExecutable(artifact, { frames, logPath, project: projectRoot, screenshot });
310
- return judgeStarterRun({ artifact, frames, log, logPath, reportPath, screenshot });
317
+ const launch = desktopLaunchTarget(artifact, executableName);
318
+ // The engine player takes neither `--frames` nor `--screenshot` and prints none of the legacy
319
+ // host's markers, so the playtest runner drives it (PRD-637). The report keeps the same path.
320
+ if (isEnginePlayerLaunch(launch)) {
321
+ const { row } = verifyStarterConsumerGameplay({ project: projectRoot, target: 'desktop' });
322
+ const report = {
323
+ artifact: launch,
324
+ assertions: row.assertions,
325
+ gate: 'consumer-playtest',
326
+ pass: row.pass === true,
327
+ };
328
+ writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
329
+ return report;
330
+ }
331
+ const log = launchStarterExecutable(launch, { frames, logPath, project: projectRoot, screenshot });
332
+ return judgeStarterRun({ artifact: launch, frames, log, logPath, reportPath, screenshot });
311
333
  }
312
334
 
313
335
  /**
@@ -447,6 +469,10 @@ if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.ar
447
469
  process.exit(0);
448
470
  }
449
471
  const report = options.root ? verifyStarterContainer(options) : verifyStarterDesktop(options);
472
+ if (report.gate === 'consumer-playtest') {
473
+ console.log(`starter desktop gate passed: engine player, ${report.assertions} playtest assertions`);
474
+ process.exit(0);
475
+ }
450
476
  const brand = report.brand === undefined || report.brand === null
451
477
  ? 'brand NOT inspected (pass --config <resolved config json>)'
452
478
  : `brand ${report.brand.name?.name ?? 'unnamed'} verified`;