@openfairygui/cli 0.1.1 → 0.2.0-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/cli.mjs +41 -6
- package/package.json +4 -1
- package/src/cli.ts +41 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BackendRuntime } from "@openfairygui/backend";
|
|
1
2
|
import * as fs$1 from "node:fs/promises";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import * as path$1 from "node:path";
|
|
@@ -13096,6 +13097,8 @@ var ProjectWriter = class {
|
|
|
13096
13097
|
if (trans.getAutoPlay()) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.transition.attrs.autoPlay, "true");
|
|
13097
13098
|
if (trans.getAutoPlayTimes() !== 1) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.transition.attrs.autoPlayTimes, String(trans.getAutoPlayTimes()));
|
|
13098
13099
|
if (trans.getAutoPlayDelay() !== 0) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.transition.attrs.autoPlayDelay, String(trans.getAutoPlayDelay()));
|
|
13100
|
+
if (trans.getOptions() !== 0) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.transition.attrs.options, String(trans.getOptions()));
|
|
13101
|
+
if (trans.getFps() !== 24) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.transition.attrs.fps, String(trans.getFps()));
|
|
13099
13102
|
const ACTION_TYPE_NAMES = {
|
|
13100
13103
|
0: "XY",
|
|
13101
13104
|
1: "Size",
|
|
@@ -20169,7 +20172,7 @@ var BinaryWriter = class {
|
|
|
20169
20172
|
id: dep.getId(),
|
|
20170
20173
|
name: dep.getName()
|
|
20171
20174
|
})).filter((dep) => !!dep.id);
|
|
20172
|
-
const branchNames = includeBranches ? getPackageBranchNames(doc,
|
|
20175
|
+
const branchNames = includeBranches ? getPackageBranchNames(doc, resources) : [];
|
|
20173
20176
|
const branchItemIdsMap = buildBranchItemIdsMap(pkg, branchNames);
|
|
20174
20177
|
const publishedItemIdMap = new Map(resources.map((resource) => [resource.getId(), getPublishedItemId$1(resource)]));
|
|
20175
20178
|
const sprites = [];
|
|
@@ -20642,7 +20645,7 @@ function getPublishedItemId$1(item) {
|
|
|
20642
20645
|
function getItemBranchName(item) {
|
|
20643
20646
|
return item.getBranch?.() ?? "";
|
|
20644
20647
|
}
|
|
20645
|
-
function getPackageBranchNames(doc,
|
|
20648
|
+
function getPackageBranchNames(doc, resources) {
|
|
20646
20649
|
const packageBranchSet = new Set(resources.map((resource) => getItemBranchName(resource)).filter((branchName) => !!branchName));
|
|
20647
20650
|
if (packageBranchSet.size === 0) return [];
|
|
20648
20651
|
return doc.getRoot().listBranches().filter((branchName) => packageBranchSet.has(branchName));
|
|
@@ -21300,7 +21303,7 @@ var BinarySearchCompat = class {
|
|
|
21300
21303
|
return this.getCurrent();
|
|
21301
21304
|
}
|
|
21302
21305
|
getCurrent() {
|
|
21303
|
-
if (this.pot) return Math.trunc(
|
|
21306
|
+
if (this.pot) return Math.trunc(2 ** this.current);
|
|
21304
21307
|
if (this.mof) return this.current * 4;
|
|
21305
21308
|
return this.current;
|
|
21306
21309
|
}
|
|
@@ -21523,8 +21526,8 @@ function swapCompat(items, left, right) {
|
|
|
21523
21526
|
function initSizeScheme() {
|
|
21524
21527
|
const result = [];
|
|
21525
21528
|
for (let w = 5; w <= 13; w += 1) for (let h = 5; h <= 13; h += 1) {
|
|
21526
|
-
const width =
|
|
21527
|
-
const height =
|
|
21529
|
+
const width = 2 ** w;
|
|
21530
|
+
const height = 2 ** h;
|
|
21528
21531
|
const area = width * height;
|
|
21529
21532
|
const aspectRatio = width > height ? width / height : height / width;
|
|
21530
21533
|
result.push({
|
|
@@ -22494,7 +22497,6 @@ function _readUint32BE(data, offset) {
|
|
|
22494
22497
|
}
|
|
22495
22498
|
/** Collect a Bitmap Font's texture image, packed under the font's ID. */
|
|
22496
22499
|
async function _collectFontTexture(doc, fontRes, pkg, options) {
|
|
22497
|
-
fontRes.getExtras();
|
|
22498
22500
|
const textureId = fontRes.getTextureId?.() ?? "";
|
|
22499
22501
|
if (textureId) {
|
|
22500
22502
|
const fontId = fontRes.getId();
|
|
@@ -24501,6 +24503,7 @@ Commands:
|
|
|
24501
24503
|
inspect <project-dir> Show project contents report
|
|
24502
24504
|
publish <project-dir> --output <dir> [options] Publish project to binary outputs and configured generated code
|
|
24503
24505
|
restore <release-dir> --output <dir> [options] Restore a FairyGUI project from published binaries
|
|
24506
|
+
backend-capabilities <project-dir> Open a backend session, print runtime capabilities, then close it
|
|
24504
24507
|
|
|
24505
24508
|
Publish options:
|
|
24506
24509
|
--output, -o <dir> Output directory (required)
|
|
@@ -24557,6 +24560,9 @@ async function main() {
|
|
|
24557
24560
|
case "restore":
|
|
24558
24561
|
await cmdRestore(rest);
|
|
24559
24562
|
break;
|
|
24563
|
+
case "backend-capabilities":
|
|
24564
|
+
await cmdBackendCapabilities(rest);
|
|
24565
|
+
break;
|
|
24560
24566
|
default:
|
|
24561
24567
|
console.error(`Unknown command: ${command}\n`);
|
|
24562
24568
|
console.log(HELP);
|
|
@@ -24848,6 +24854,35 @@ async function cmdPublish(args) {
|
|
|
24848
24854
|
}));
|
|
24849
24855
|
console.log(`\nDone! Output: ${outputDir}`);
|
|
24850
24856
|
}
|
|
24857
|
+
async function cmdBackendCapabilities(args) {
|
|
24858
|
+
if (args.length === 0) {
|
|
24859
|
+
console.error("Usage: ofgui backend-capabilities <project-dir>");
|
|
24860
|
+
process.exit(1);
|
|
24861
|
+
}
|
|
24862
|
+
const runtime = new BackendRuntime();
|
|
24863
|
+
const opened = await runtime.openSession({ projectPath: path.resolve(args[0]) });
|
|
24864
|
+
if (!opened.ok) {
|
|
24865
|
+
console.error(`backend-capabilities: ${opened.error.message}`);
|
|
24866
|
+
process.exit(1);
|
|
24867
|
+
}
|
|
24868
|
+
const capabilities = runtime.getCapabilities();
|
|
24869
|
+
if (!capabilities.ok) {
|
|
24870
|
+
console.error("backend-capabilities: failed to read capabilities");
|
|
24871
|
+
await runtime.closeSession({ sessionId: opened.data.sessionId });
|
|
24872
|
+
process.exit(1);
|
|
24873
|
+
}
|
|
24874
|
+
console.log(`Session: ${opened.data.sessionId}`);
|
|
24875
|
+
console.log(`Project: ${opened.data.canonicalProjectPath}`);
|
|
24876
|
+
console.log(`Revision: ${opened.data.revision}`);
|
|
24877
|
+
console.log(`Runtime owner: ${capabilities.data.runtimeOwner}`);
|
|
24878
|
+
console.log(`Transaction owner: ${capabilities.data.transactionKernelOwner}`);
|
|
24879
|
+
console.log(`App seam owner: ${capabilities.data.appSeamOwner}`);
|
|
24880
|
+
const closed = await runtime.closeSession({ sessionId: opened.data.sessionId });
|
|
24881
|
+
if (!closed.ok) {
|
|
24882
|
+
console.error(`backend-capabilities: ${closed.error.message}`);
|
|
24883
|
+
process.exit(1);
|
|
24884
|
+
}
|
|
24885
|
+
}
|
|
24851
24886
|
main().catch((err) => {
|
|
24852
24887
|
console.error(err);
|
|
24853
24888
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfairygui/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.0",
|
|
4
4
|
"description": "FairyGUI Headless Authoring SDK — command-line interface.",
|
|
5
5
|
"author": "OpenFairyGUI Contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
"@openfairygui/core": "workspace:*",
|
|
40
40
|
"@openfairygui/functions": "workspace:*"
|
|
41
41
|
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@openfairygui/backend": "workspace:*"
|
|
44
|
+
},
|
|
42
45
|
"optionalDependencies": {
|
|
43
46
|
"sharp": ">=0.33.0"
|
|
44
47
|
}
|
package/src/cli.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BackendRuntime } from '@openfairygui/backend';
|
|
1
2
|
import {
|
|
2
3
|
NodeIO,
|
|
3
4
|
ProjectType,
|
|
@@ -29,6 +30,7 @@ Commands:
|
|
|
29
30
|
inspect <project-dir> Show project contents report
|
|
30
31
|
publish <project-dir> --output <dir> [options] Publish project to binary outputs and configured generated code
|
|
31
32
|
restore <release-dir> --output <dir> [options] Restore a FairyGUI project from published binaries
|
|
33
|
+
backend-capabilities <project-dir> Open a backend session, print runtime capabilities, then close it
|
|
32
34
|
|
|
33
35
|
Publish options:
|
|
34
36
|
--output, -o <dir> Output directory (required)
|
|
@@ -102,6 +104,9 @@ async function main(): Promise<void> {
|
|
|
102
104
|
case 'restore':
|
|
103
105
|
await cmdRestore(rest);
|
|
104
106
|
break;
|
|
107
|
+
case 'backend-capabilities':
|
|
108
|
+
await cmdBackendCapabilities(rest);
|
|
109
|
+
break;
|
|
105
110
|
default:
|
|
106
111
|
console.error(`Unknown command: ${command}\n`);
|
|
107
112
|
console.log(HELP);
|
|
@@ -464,6 +469,42 @@ async function cmdPublish(args: string[]): Promise<void> {
|
|
|
464
469
|
console.log(`\nDone! Output: ${outputDir}`);
|
|
465
470
|
}
|
|
466
471
|
|
|
472
|
+
async function cmdBackendCapabilities(args: string[]): Promise<void> {
|
|
473
|
+
if (args.length === 0) {
|
|
474
|
+
console.error('Usage: ofgui backend-capabilities <project-dir>');
|
|
475
|
+
process.exit(1);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const runtime = new BackendRuntime();
|
|
479
|
+
const opened = await runtime.openSession({ projectPath: path.resolve(args[0]) });
|
|
480
|
+
if (!opened.ok) {
|
|
481
|
+
const failure = opened as Extract<typeof opened, { ok: false }>;
|
|
482
|
+
console.error(`backend-capabilities: ${failure.error.message}`);
|
|
483
|
+
process.exit(1);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const capabilities = runtime.getCapabilities();
|
|
487
|
+
if (!capabilities.ok) {
|
|
488
|
+
console.error('backend-capabilities: failed to read capabilities');
|
|
489
|
+
await runtime.closeSession({ sessionId: opened.data.sessionId });
|
|
490
|
+
process.exit(1);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
console.log(`Session: ${opened.data.sessionId}`);
|
|
494
|
+
console.log(`Project: ${opened.data.canonicalProjectPath}`);
|
|
495
|
+
console.log(`Revision: ${opened.data.revision}`);
|
|
496
|
+
console.log(`Runtime owner: ${capabilities.data.runtimeOwner}`);
|
|
497
|
+
console.log(`Transaction owner: ${capabilities.data.transactionKernelOwner}`);
|
|
498
|
+
console.log(`App seam owner: ${capabilities.data.appSeamOwner}`);
|
|
499
|
+
|
|
500
|
+
const closed = await runtime.closeSession({ sessionId: opened.data.sessionId });
|
|
501
|
+
if (!closed.ok) {
|
|
502
|
+
const failure = closed as Extract<typeof closed, { ok: false }>;
|
|
503
|
+
console.error(`backend-capabilities: ${failure.error.message}`);
|
|
504
|
+
process.exit(1);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
467
508
|
main().catch((err) => {
|
|
468
509
|
console.error(err);
|
|
469
510
|
process.exit(1);
|