@openfairygui/cli 0.2.0-alpha.7 → 0.2.0-alpha.9
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 +110 -8
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -1263,6 +1263,7 @@ var ImageResource = class extends ExtensibleProperty {
|
|
|
1263
1263
|
path: "",
|
|
1264
1264
|
branch: "",
|
|
1265
1265
|
branchItemIds: [],
|
|
1266
|
+
highResolutionItemIds: [],
|
|
1266
1267
|
width: 0,
|
|
1267
1268
|
height: 0,
|
|
1268
1269
|
exported: false,
|
|
@@ -1309,6 +1310,12 @@ var ImageResource = class extends ExtensibleProperty {
|
|
|
1309
1310
|
setBranchItemIds(ids) {
|
|
1310
1311
|
return this.set("branchItemIds", [...ids]);
|
|
1311
1312
|
}
|
|
1313
|
+
getHighResolutionItemIds() {
|
|
1314
|
+
return [...this.get("highResolutionItemIds")];
|
|
1315
|
+
}
|
|
1316
|
+
setHighResolutionItemIds(ids) {
|
|
1317
|
+
return this.set("highResolutionItemIds", [...ids]);
|
|
1318
|
+
}
|
|
1312
1319
|
getWidth() {
|
|
1313
1320
|
return this.get("width");
|
|
1314
1321
|
}
|
|
@@ -1678,6 +1685,7 @@ var MovieClipResource = class extends ExtensibleProperty {
|
|
|
1678
1685
|
path: "",
|
|
1679
1686
|
branch: "",
|
|
1680
1687
|
branchItemIds: [],
|
|
1688
|
+
highResolutionItemIds: [],
|
|
1681
1689
|
fileName: "",
|
|
1682
1690
|
exported: false,
|
|
1683
1691
|
width: 0,
|
|
@@ -1713,6 +1721,12 @@ var MovieClipResource = class extends ExtensibleProperty {
|
|
|
1713
1721
|
setBranchItemIds(ids) {
|
|
1714
1722
|
return this.set("branchItemIds", [...ids]);
|
|
1715
1723
|
}
|
|
1724
|
+
getHighResolutionItemIds() {
|
|
1725
|
+
return [...this.get("highResolutionItemIds")];
|
|
1726
|
+
}
|
|
1727
|
+
setHighResolutionItemIds(ids) {
|
|
1728
|
+
return this.set("highResolutionItemIds", [...ids]);
|
|
1729
|
+
}
|
|
1716
1730
|
getFileName() {
|
|
1717
1731
|
return this.get("fileName");
|
|
1718
1732
|
}
|
|
@@ -18404,11 +18418,13 @@ var BinaryReader = class {
|
|
|
18404
18418
|
if (branchCnt2 > 0) if (branchIncluded) branchItemIds = buf.readSArray(branchCnt2);
|
|
18405
18419
|
else branchItemIds = [buf.readS() ?? ""];
|
|
18406
18420
|
const highResCnt = buf.getUint8();
|
|
18407
|
-
|
|
18421
|
+
const highResolutionItemIds = [];
|
|
18422
|
+
for (let highResIndex = 0; highResIndex < highResCnt; highResIndex++) highResolutionItemIds.push(buf.readS());
|
|
18408
18423
|
if (createdResource) {
|
|
18409
18424
|
createdResource.setPath(itemPath);
|
|
18410
18425
|
createdResource.setBranch(branchName);
|
|
18411
18426
|
createdResource.setBranchItemIds(branchItemIds);
|
|
18427
|
+
createdResource.setHighResolutionItemIds?.(highResolutionItemIds);
|
|
18412
18428
|
}
|
|
18413
18429
|
}
|
|
18414
18430
|
buf.pos = nextPos;
|
|
@@ -20451,7 +20467,9 @@ var BinaryWriter = class {
|
|
|
20451
20467
|
data.writeSEx(branchName || null);
|
|
20452
20468
|
data.writeUint8(branchItemIds.length);
|
|
20453
20469
|
for (const branchItemId of branchItemIds) data.writeSEx(branchItemId || null);
|
|
20454
|
-
|
|
20470
|
+
const highResolutionItemIds = getItemHighResolutionItemIds(res, publishedItemIdMap, packageItemIds);
|
|
20471
|
+
data.writeUint8(highResolutionItemIds.length);
|
|
20472
|
+
for (const highResolutionItemId of highResolutionItemIds) data.writeS(highResolutionItemId);
|
|
20455
20473
|
}
|
|
20456
20474
|
const nextPos = data.pos;
|
|
20457
20475
|
const savedPos = data.pos;
|
|
@@ -20722,6 +20740,15 @@ function getItemBranchItemIds(item, branchNames, branchItemIdsMap) {
|
|
|
20722
20740
|
if (!inferred) return [];
|
|
20723
20741
|
return inferred.some((value) => !!value) ? [...inferred] : [];
|
|
20724
20742
|
}
|
|
20743
|
+
function getItemHighResolutionItemIds(item, publishedItemIdMap, packageItemIds) {
|
|
20744
|
+
const resolvedIds = (item.getHighResolutionItemIds?.() ?? []).map((id) => {
|
|
20745
|
+
if (!id) return null;
|
|
20746
|
+
const publishedId = publishedItemIdMap.get(id) ?? id;
|
|
20747
|
+
return packageItemIds.has(publishedId) ? publishedId : null;
|
|
20748
|
+
});
|
|
20749
|
+
while (resolvedIds.length > 0 && !resolvedIds[resolvedIds.length - 1]) resolvedIds.pop();
|
|
20750
|
+
return resolvedIds;
|
|
20751
|
+
}
|
|
20725
20752
|
function getAtlasId(atlas) {
|
|
20726
20753
|
return `atlas${atlas.getIndex()}`;
|
|
20727
20754
|
}
|
|
@@ -21862,15 +21889,15 @@ function atlas(_options = {}) {
|
|
|
21862
21889
|
}
|
|
21863
21890
|
for (const res of orderedAllResources) if (isImageResource$1(res)) {
|
|
21864
21891
|
const resId = res.getId();
|
|
21865
|
-
if (!res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
21892
|
+
if (selectedPublishIds.size === 0 && !res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
21866
21893
|
await _collectImage(res, pkg, inputs, encoder, options, doTrim, logger);
|
|
21867
21894
|
} else if (isMovieClipResource$1(res)) {
|
|
21868
21895
|
const resId = res.getId();
|
|
21869
|
-
if (!res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
21896
|
+
if (selectedPublishIds.size === 0 && !res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
21870
21897
|
await _collectMovieClipFrames(doc, res, pkg, inputs, encoder, options, logger);
|
|
21871
21898
|
} else if (isFontResource$1(res)) {
|
|
21872
21899
|
const resId = res.getId();
|
|
21873
|
-
if (!res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
21900
|
+
if (selectedPublishIds.size === 0 && !res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
21874
21901
|
await _collectFontTexture(doc, res, pkg, options);
|
|
21875
21902
|
}
|
|
21876
21903
|
if (inputs.length === 0) continue;
|
|
@@ -23976,6 +24003,9 @@ function isImageResource(resource) {
|
|
|
23976
24003
|
function isMovieClipResource(resource) {
|
|
23977
24004
|
return resource.propertyType === "MovieClipResource";
|
|
23978
24005
|
}
|
|
24006
|
+
function isHighResolutionResource(resource) {
|
|
24007
|
+
return isImageResource(resource) || isMovieClipResource(resource);
|
|
24008
|
+
}
|
|
23979
24009
|
function isMiscResource(resource) {
|
|
23980
24010
|
return resource.propertyType === "MiscResource";
|
|
23981
24011
|
}
|
|
@@ -24096,6 +24126,70 @@ function getBranchName(resource) {
|
|
|
24096
24126
|
function buildBranchResourceKey(resource) {
|
|
24097
24127
|
return `${resource.propertyType}|${resource.getPath() ?? ""}|${resource.getName() ?? ""}`;
|
|
24098
24128
|
}
|
|
24129
|
+
const HIGH_RESOLUTION_LEVELS = [
|
|
24130
|
+
{
|
|
24131
|
+
scale: 2,
|
|
24132
|
+
bit: 1,
|
|
24133
|
+
slot: 0
|
|
24134
|
+
},
|
|
24135
|
+
{
|
|
24136
|
+
scale: 3,
|
|
24137
|
+
bit: 2,
|
|
24138
|
+
slot: 1
|
|
24139
|
+
},
|
|
24140
|
+
{
|
|
24141
|
+
scale: 4,
|
|
24142
|
+
bit: 4,
|
|
24143
|
+
slot: 2
|
|
24144
|
+
}
|
|
24145
|
+
];
|
|
24146
|
+
function buildHighResolutionResourceKey(resource, name = resource.getName()) {
|
|
24147
|
+
return `${resource.propertyType}|${resource.getBranch?.() ?? ""}|${resource.getPath() ?? ""}|${name}`;
|
|
24148
|
+
}
|
|
24149
|
+
function isHighResolutionVariantName(name) {
|
|
24150
|
+
return /@(?:2|3|4)x(?:\.[^./\\]+)?$/iu.test(name);
|
|
24151
|
+
}
|
|
24152
|
+
function appendHighResolutionScaleToName(name, scale) {
|
|
24153
|
+
const extensionIndex = name.lastIndexOf(".");
|
|
24154
|
+
if (extensionIndex > 0) return `${name.slice(0, extensionIndex)}@${scale}x${name.slice(extensionIndex)}`;
|
|
24155
|
+
return `${name}@${scale}x`;
|
|
24156
|
+
}
|
|
24157
|
+
function trimTrailingMissingHighResolutionIds(ids) {
|
|
24158
|
+
while (ids.length > 0 && !ids[ids.length - 1]) ids.pop();
|
|
24159
|
+
return ids;
|
|
24160
|
+
}
|
|
24161
|
+
function collectHighResolutionItemIds(resources, publishedResourceIds, includeHighResolution) {
|
|
24162
|
+
const result = /* @__PURE__ */ new Map();
|
|
24163
|
+
if (includeHighResolution <= 0) return result;
|
|
24164
|
+
const highResolutionResourceByKey = /* @__PURE__ */ new Map();
|
|
24165
|
+
for (const resource of resources) {
|
|
24166
|
+
if (!isHighResolutionResource(resource)) continue;
|
|
24167
|
+
highResolutionResourceByKey.set(buildHighResolutionResourceKey(resource), resource);
|
|
24168
|
+
}
|
|
24169
|
+
for (const resource of resources) {
|
|
24170
|
+
if (!isHighResolutionResource(resource)) continue;
|
|
24171
|
+
if (!publishedResourceIds.has(resource.getId())) continue;
|
|
24172
|
+
if (isHighResolutionVariantName(resource.getName())) continue;
|
|
24173
|
+
const ids = [];
|
|
24174
|
+
for (const level of HIGH_RESOLUTION_LEVELS) {
|
|
24175
|
+
if ((includeHighResolution & level.bit) === 0) {
|
|
24176
|
+
ids[level.slot] = null;
|
|
24177
|
+
continue;
|
|
24178
|
+
}
|
|
24179
|
+
const highResolutionResource = highResolutionResourceByKey.get(buildHighResolutionResourceKey(resource, appendHighResolutionScaleToName(resource.getName(), level.scale)));
|
|
24180
|
+
if (!highResolutionResource) {
|
|
24181
|
+
ids[level.slot] = null;
|
|
24182
|
+
continue;
|
|
24183
|
+
}
|
|
24184
|
+
const highResolutionId = highResolutionResource.getId();
|
|
24185
|
+
publishedResourceIds.add(highResolutionId);
|
|
24186
|
+
ids[level.slot] = highResolutionId;
|
|
24187
|
+
}
|
|
24188
|
+
trimTrailingMissingHighResolutionIds(ids);
|
|
24189
|
+
if (ids.length > 0) result.set(resource.getId(), ids);
|
|
24190
|
+
}
|
|
24191
|
+
return result;
|
|
24192
|
+
}
|
|
24099
24193
|
function collectPackagePublishContext(pkg, options) {
|
|
24100
24194
|
const pkgId = pkg.getId();
|
|
24101
24195
|
const resources = pkg.listResources();
|
|
@@ -24199,6 +24293,7 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
24199
24293
|
}
|
|
24200
24294
|
}
|
|
24201
24295
|
}
|
|
24296
|
+
const highResolutionItemIds = collectHighResolutionItemIds(resources, publishedResourceIds, options.includeHighResolution);
|
|
24202
24297
|
if (!options.includeBranches) {
|
|
24203
24298
|
const mainByKey = /* @__PURE__ */ new Map();
|
|
24204
24299
|
const activeBranchByKey = /* @__PURE__ */ new Map();
|
|
@@ -24247,6 +24342,7 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
24247
24342
|
referencedIds,
|
|
24248
24343
|
publishedResourceIds,
|
|
24249
24344
|
pixelHitTestImageIds,
|
|
24345
|
+
highResolutionItemIds,
|
|
24250
24346
|
effectiveResourceIds,
|
|
24251
24347
|
includeBranches: false
|
|
24252
24348
|
};
|
|
@@ -24255,6 +24351,7 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
24255
24351
|
referencedIds,
|
|
24256
24352
|
publishedResourceIds,
|
|
24257
24353
|
pixelHitTestImageIds,
|
|
24354
|
+
highResolutionItemIds,
|
|
24258
24355
|
effectiveResourceIds: new Map([...publishedResourceIds].map((resourceId) => [resourceId, resourceId])),
|
|
24259
24356
|
includeBranches: true
|
|
24260
24357
|
};
|
|
@@ -24303,8 +24400,11 @@ async function applyPixelHitTests(pkg, imageIds, basePath, encoder) {
|
|
|
24303
24400
|
}
|
|
24304
24401
|
}
|
|
24305
24402
|
async function annotatePackagePublishArtifacts(pkg, basePath, encoder, options) {
|
|
24306
|
-
const { publishedResourceIds, pixelHitTestImageIds, effectiveResourceIds, includeBranches } = collectPackagePublishContext(pkg, options);
|
|
24307
|
-
for (const resource of pkg.listResources())
|
|
24403
|
+
const { publishedResourceIds, pixelHitTestImageIds, highResolutionItemIds, effectiveResourceIds, includeBranches } = collectPackagePublishContext(pkg, options);
|
|
24404
|
+
for (const resource of pkg.listResources()) {
|
|
24405
|
+
setPublishedIdExtra(resource, effectiveResourceIds.get(resource.getId()) ?? null);
|
|
24406
|
+
if (isHighResolutionResource(resource)) resource.setHighResolutionItemIds(highResolutionItemIds.get(resource.getId()) ?? []);
|
|
24407
|
+
}
|
|
24308
24408
|
await applyPixelHitTests(pkg, pixelHitTestImageIds, basePath, encoder);
|
|
24309
24409
|
const extras = pkg.getExtras() ?? {};
|
|
24310
24410
|
pkg.setExtras({
|
|
@@ -24441,6 +24541,7 @@ function publish(options) {
|
|
|
24441
24541
|
}
|
|
24442
24542
|
const includeBranches = (publishSettings.branchProcessing ?? 0) === 0;
|
|
24443
24543
|
const activeBranch = includeBranches ? "" : options.branch ?? "";
|
|
24544
|
+
const includeHighResolution = publishSettings.includeHighResolution ?? 0;
|
|
24444
24545
|
const atlasRuntimeOptions = resolvePublishAtlasRuntimeOptions(ext);
|
|
24445
24546
|
const allDocPackages = root.listPackages();
|
|
24446
24547
|
const pkgMap = /* @__PURE__ */ new Map();
|
|
@@ -24449,7 +24550,8 @@ function publish(options) {
|
|
|
24449
24550
|
_computeDependencies(pkg, pkgMap);
|
|
24450
24551
|
await annotatePackagePublishArtifacts(pkg, options.basePath, options.encoder, {
|
|
24451
24552
|
includeBranches,
|
|
24452
|
-
activeBranch
|
|
24553
|
+
activeBranch,
|
|
24554
|
+
includeHighResolution
|
|
24453
24555
|
});
|
|
24454
24556
|
}
|
|
24455
24557
|
await atlas({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfairygui/cli",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.9",
|
|
4
4
|
"description": "FairyGUI Headless Authoring SDK — command-line interface.",
|
|
5
5
|
"author": "OpenFairyGUI Contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"restore"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@openfairygui/
|
|
37
|
-
"@openfairygui/
|
|
36
|
+
"@openfairygui/core": "0.2.0-alpha.9",
|
|
37
|
+
"@openfairygui/functions": "0.2.0-alpha.8"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@openfairygui/backend": "0.2.0-alpha.
|
|
40
|
+
"@openfairygui/backend": "0.2.0-alpha.9"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
43
|
"sharp": ">=0.33.0"
|