@threenative/runtime-native 0.2.0 → 0.3.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/README.md +63 -0
- package/android/README.md +2 -2
- package/android/app/build.gradle.kts +166 -29
- package/android/app/src/main/AndroidManifest.xml +8 -1
- package/android/app/src/main/java/com/mystral/engine/MystralActivity.java +179 -2
- package/android/app/src/main/java/com/mystral/engine/TnUiOverlay.java +261 -0
- package/android/app/src/main/res/values/branding.xml +12 -0
- package/android/app/src/main/res/values/themes.xml +2 -0
- package/package.json +21 -8
- package/scripts/asset-preflight.mjs +442 -0
- package/scripts/bundle.mjs +167 -44
- package/scripts/device-preflight.mjs +456 -0
- package/scripts/install-prebuilt.mjs +80 -11
- package/scripts/package-android.mjs +400 -20
- package/scripts/package-desktop.mjs +83 -6
- package/scripts/package-ios.mjs +205 -22
- package/scripts/physical-device-evidence.mjs +644 -0
- package/scripts/production-evidence.mjs +1 -1
- package/scripts/profile-production.mjs +54 -23
- package/scripts/qualify-physical-mobile.mjs +1327 -0
- package/scripts/verify-starter-desktop.mjs +6 -3
- package/scripts/xvfb.sh +63 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { createServer } from 'node:http';
|
|
4
|
-
import { execFile, spawn } from 'node:child_process';
|
|
4
|
+
import { execFile, execFileSync, spawn } from 'node:child_process';
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
import { mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
@@ -11,6 +11,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
11
11
|
import { promisify } from 'node:util';
|
|
12
12
|
import { PNG } from 'pngjs';
|
|
13
13
|
import { readAndroidConfig } from './package-android.mjs';
|
|
14
|
+
import { suppressPlayProtectOnAdbInstalls } from './device-preflight.mjs';
|
|
14
15
|
|
|
15
16
|
import {
|
|
16
17
|
PRODUCTION_EVIDENCE_VERSION,
|
|
@@ -243,13 +244,16 @@ async function scaffoldPlatformer(project, tools) {
|
|
|
243
244
|
const packageSource = async (name, directory) => [name, await packLocalPackage(directory, packageArchiveRoot)];
|
|
244
245
|
const localSources = [];
|
|
245
246
|
if (inRepositoryCheckout) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
247
|
+
for (const workspacePackage of localWorkspacePackages()) {
|
|
248
|
+
localSources.push(
|
|
249
|
+
await packageSource(workspacePackage.name, join(repositoryRoot, workspacePackage.directory)),
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
const studioDirectory = join(repositoryRoot, 'packages/studio');
|
|
253
|
+
if (existsSync(join(studioDirectory, 'package.json'))) {
|
|
254
|
+
// Studio is a private cross-checkout extra, not a workspace package in this repository.
|
|
255
|
+
localSources.push(await packageSource('@threenative/studio', studioDirectory));
|
|
256
|
+
}
|
|
253
257
|
}
|
|
254
258
|
const args = [
|
|
255
259
|
tools.scaffoldCli,
|
|
@@ -263,6 +267,17 @@ async function scaffoldPlatformer(project, tools) {
|
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
|
|
270
|
+
function localWorkspacePackages() {
|
|
271
|
+
const output = execFileSync(
|
|
272
|
+
'pnpm',
|
|
273
|
+
['exec', 'tsx', join(repositoryRoot, 'scripts/workspace-packages.ts'), '--json'],
|
|
274
|
+
{ cwd: repositoryRoot, encoding: 'utf8' },
|
|
275
|
+
);
|
|
276
|
+
const packages = JSON.parse(output);
|
|
277
|
+
if (!Array.isArray(packages)) throw new Error('TN_WORKSPACE_PACKAGE_DERIVATION_INVALID: expected an array.');
|
|
278
|
+
return packages.filter((item) => item && typeof item.name === 'string' && typeof item.directory === 'string');
|
|
279
|
+
}
|
|
280
|
+
|
|
266
281
|
async function packLocalPackage(directory, destination) {
|
|
267
282
|
const before = new Set(await readdir(destination));
|
|
268
283
|
const result = await runCommand('pnpm', ['pack', '--pack-destination', destination], directory);
|
|
@@ -273,19 +288,13 @@ async function packLocalPackage(directory, destination) {
|
|
|
273
288
|
}
|
|
274
289
|
|
|
275
290
|
function packageSourceFlag(name) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
? '--runtime-native-package'
|
|
284
|
-
: name === '@threenative/ui'
|
|
285
|
-
? '--ui-package'
|
|
286
|
-
: name === '@threenative/studio'
|
|
287
|
-
? '--studio-package'
|
|
288
|
-
: '--cli-package';
|
|
291
|
+
if (name === 'create-threenative') return '--cli-package';
|
|
292
|
+
if (name === 'threenative-engine-mcp') return '--engine-mcp-package';
|
|
293
|
+
if (name.startsWith('@threenative/')) {
|
|
294
|
+
const suffix = name.slice('@threenative/'.length);
|
|
295
|
+
return `--threenative-${suffix}-package`;
|
|
296
|
+
}
|
|
297
|
+
throw new Error(`TN_PROD_PACKAGE_FLAG_UNSUPPORTED: ${name}`);
|
|
289
298
|
}
|
|
290
299
|
|
|
291
300
|
export async function writeRunScenarios(project, options) {
|
|
@@ -928,7 +937,6 @@ function parsePlaytestReport(stdout) {
|
|
|
928
937
|
try {
|
|
929
938
|
return JSON.parse(line);
|
|
930
939
|
} catch {
|
|
931
|
-
continue;
|
|
932
940
|
}
|
|
933
941
|
}
|
|
934
942
|
}
|
|
@@ -959,7 +967,6 @@ function frameSeriesFromReport(report) {
|
|
|
959
967
|
const batch = JSON.parse(line.slice(offset + prefix.length));
|
|
960
968
|
if (Array.isArray(batch)) series.push(...batch);
|
|
961
969
|
} catch {
|
|
962
|
-
continue;
|
|
963
970
|
}
|
|
964
971
|
}
|
|
965
972
|
return series.length === 0 ? undefined : series;
|
|
@@ -1380,6 +1387,12 @@ async function playtestRunnerPath(project, tools) {
|
|
|
1380
1387
|
}
|
|
1381
1388
|
|
|
1382
1389
|
async function installAndroidArtifact(apk, device) {
|
|
1390
|
+
// The Play Protect verifier dialog is modal and swallows the install, so an unattended
|
|
1391
|
+
// lane behind it proves nothing. Suppress before the install, as every install lane must.
|
|
1392
|
+
const serial = device ?? String(execFileSync('adb', ['get-serialno'], { encoding: 'utf8' })).trim();
|
|
1393
|
+
suppressPlayProtectOnAdbInstalls(serial, {
|
|
1394
|
+
adb: (adbArgs) => String(execFileSync('adb', ['-s', serial, ...adbArgs], { encoding: 'utf8' })),
|
|
1395
|
+
});
|
|
1383
1396
|
const args = [...(device === undefined ? [] : ['-s', device]), 'install', '-r', apk];
|
|
1384
1397
|
const result = await runCommand('adb', args, commandRoot);
|
|
1385
1398
|
if (result.status !== 0) throw new ProductionEvidenceError('TN_PROD_ANDROID_INSTALL_FAILED', 'Installing the scaffolded Android platformer failed.');
|
|
@@ -1512,6 +1525,21 @@ function positiveInteger(value, flag) {
|
|
|
1512
1525
|
}
|
|
1513
1526
|
|
|
1514
1527
|
if (process.argv[1] && new URL(`file://${process.argv[1]}`).pathname === new URL(import.meta.url).pathname) {
|
|
1528
|
+
// Gate records are an engine-repository artefact, not something a published install owns. A
|
|
1529
|
+
// package-relative specifier here would ship inside the tarball and die ERR_MODULE_NOT_FOUND on
|
|
1530
|
+
// an installed copy, so the path is resolved against the checkout and its absence is named.
|
|
1531
|
+
const gateRecords = resolve(scriptDirectory, '../../../scripts/gate-records.mjs');
|
|
1532
|
+
if (!existsSync(gateRecords)) {
|
|
1533
|
+
throw new ProductionEvidenceError(
|
|
1534
|
+
'TN_PROD_GATE_RECORDS_MISSING',
|
|
1535
|
+
`pnpm profile:production records its gate phases through ${gateRecords}, which does not exist. This command runs from a ThreeNative engine checkout, not from an installed @threenative/runtime-native.`,
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
const { createGateRecorder } = await import(pathToFileURL(gateRecords).href);
|
|
1539
|
+
const gateRecorder = await createGateRecorder({
|
|
1540
|
+
phase: 'profile-production',
|
|
1541
|
+
command: ['pnpm profile:production', ...process.argv.slice(2)].join(' '),
|
|
1542
|
+
});
|
|
1515
1543
|
try {
|
|
1516
1544
|
const result = await runProductionProfile(parseProductionArgs());
|
|
1517
1545
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
@@ -1521,5 +1549,8 @@ if (process.argv[1] && new URL(`file://${process.argv[1]}`).pathname === new URL
|
|
|
1521
1549
|
const message = error instanceof Error ? error.message : String(error);
|
|
1522
1550
|
process.stderr.write(`${JSON.stringify({ codes: [code], message, status: 'BLOCKED', exitCode: 2 }, null, 2)}\n`);
|
|
1523
1551
|
process.exitCode = 2;
|
|
1552
|
+
} finally {
|
|
1553
|
+
// main() communicates its own result through process.exitCode; record what actually ran.
|
|
1554
|
+
await gateRecorder.finish(process.exitCode ?? 0);
|
|
1524
1555
|
}
|
|
1525
1556
|
}
|