@openfairygui/cli 0.2.0-alpha.21 → 0.2.0-alpha.23

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +198 -1
  2. package/package.json +4 -4
package/dist/cli.mjs CHANGED
@@ -1434,6 +1434,7 @@ var ImageResource = class extends ExtensibleProperty {
1434
1434
  width: 0,
1435
1435
  height: 0,
1436
1436
  exported: false,
1437
+ favorite: false,
1437
1438
  textureSetMode: "",
1438
1439
  qualityOption: "",
1439
1440
  smoothing: true,
@@ -1501,6 +1502,12 @@ var ImageResource = class extends ExtensibleProperty {
1501
1502
  setExported(v) {
1502
1503
  return this.set("exported", v);
1503
1504
  }
1505
+ getFavorite() {
1506
+ return this.get("favorite");
1507
+ }
1508
+ setFavorite(v) {
1509
+ return this.set("favorite", v);
1510
+ }
1504
1511
  getTextureSetMode() {
1505
1512
  return this.get("textureSetMode");
1506
1513
  }
@@ -1596,6 +1603,7 @@ var MiscResource = class extends ExtensibleProperty {
1596
1603
  branchItemIds: [],
1597
1604
  file: "",
1598
1605
  exported: false,
1606
+ favorite: false,
1599
1607
  resourceData: null
1600
1608
  });
1601
1609
  }
@@ -1635,6 +1643,12 @@ var MiscResource = class extends ExtensibleProperty {
1635
1643
  setExported(v) {
1636
1644
  return this.set("exported", v);
1637
1645
  }
1646
+ getFavorite() {
1647
+ return this.get("favorite");
1648
+ }
1649
+ setFavorite(v) {
1650
+ return this.set("favorite", v);
1651
+ }
1638
1652
  getResourceData() {
1639
1653
  return this.getRef("resourceData");
1640
1654
  }
@@ -1667,6 +1681,7 @@ var SoundResource = class extends ExtensibleProperty {
1667
1681
  branchItemIds: [],
1668
1682
  file: "",
1669
1683
  exported: false,
1684
+ favorite: false,
1670
1685
  soundData: null
1671
1686
  });
1672
1687
  }
@@ -1706,6 +1721,12 @@ var SoundResource = class extends ExtensibleProperty {
1706
1721
  setExported(v) {
1707
1722
  return this.set("exported", v);
1708
1723
  }
1724
+ getFavorite() {
1725
+ return this.get("favorite");
1726
+ }
1727
+ setFavorite(v) {
1728
+ return this.set("favorite", v);
1729
+ }
1709
1730
  getSoundData() {
1710
1731
  return this.getRef("soundData");
1711
1732
  }
@@ -1739,6 +1760,7 @@ var FontResource = class extends ExtensibleProperty {
1739
1760
  fileName: "",
1740
1761
  textureId: "",
1741
1762
  exported: false,
1763
+ favorite: false,
1742
1764
  renderMode: "",
1743
1765
  samplePointSize: 0,
1744
1766
  ttf: false,
@@ -1794,6 +1816,12 @@ var FontResource = class extends ExtensibleProperty {
1794
1816
  setExported(v) {
1795
1817
  return this.set("exported", v);
1796
1818
  }
1819
+ getFavorite() {
1820
+ return this.get("favorite");
1821
+ }
1822
+ setFavorite(v) {
1823
+ return this.set("favorite", v);
1824
+ }
1797
1825
  getRenderMode() {
1798
1826
  return this.get("renderMode");
1799
1827
  }
@@ -1884,6 +1912,7 @@ var MovieClipResource = class extends ExtensibleProperty {
1884
1912
  highResolutionItemIds: [],
1885
1913
  fileName: "",
1886
1914
  exported: false,
1915
+ favorite: false,
1887
1916
  textureSetMode: "",
1888
1917
  width: 0,
1889
1918
  height: 0,
@@ -1937,6 +1966,12 @@ var MovieClipResource = class extends ExtensibleProperty {
1937
1966
  setExported(v) {
1938
1967
  return this.set("exported", v);
1939
1968
  }
1969
+ getFavorite() {
1970
+ return this.get("favorite");
1971
+ }
1972
+ setFavorite(v) {
1973
+ return this.set("favorite", v);
1974
+ }
1940
1975
  getTextureSetMode() {
1941
1976
  return this.get("textureSetMode");
1942
1977
  }
@@ -2011,6 +2046,7 @@ var SkeletonResourceBase = class extends ExtensibleProperty {
2011
2046
  branchItemIds: [],
2012
2047
  file: "",
2013
2048
  exported: false,
2049
+ favorite: false,
2014
2050
  width: 0,
2015
2051
  height: 0,
2016
2052
  requireIds: [],
@@ -2056,6 +2092,12 @@ var SkeletonResourceBase = class extends ExtensibleProperty {
2056
2092
  setExported(v) {
2057
2093
  return this.set("exported", v);
2058
2094
  }
2095
+ getFavorite() {
2096
+ return this.get("favorite");
2097
+ }
2098
+ setFavorite(v) {
2099
+ return this.set("favorite", v);
2100
+ }
2059
2101
  getWidth() {
2060
2102
  return this.get("width");
2061
2103
  }
@@ -2148,6 +2190,7 @@ var Component = class extends ExtensibleProperty {
2148
2190
  branch: "",
2149
2191
  branchItemIds: [],
2150
2192
  exported: false,
2193
+ favorite: false,
2151
2194
  width: 0,
2152
2195
  height: 0,
2153
2196
  minWidth: 0,
@@ -2247,6 +2290,12 @@ var Component = class extends ExtensibleProperty {
2247
2290
  setExported(v) {
2248
2291
  return this.set("exported", v);
2249
2292
  }
2293
+ getFavorite() {
2294
+ return this.get("favorite");
2295
+ }
2296
+ setFavorite(v) {
2297
+ return this.set("favorite", v);
2298
+ }
2250
2299
  getWidth() {
2251
2300
  return this.get("width");
2252
2301
  }
@@ -9368,6 +9417,137 @@ function ensureArray(v) {
9368
9417
  return Array.isArray(v) ? v : [v];
9369
9418
  }
9370
9419
  //#endregion
9420
+ //#region ../core/src/utils/jta-parser.ts
9421
+ /**
9422
+ * Parser for FairyGUI `.jta` animation files.
9423
+ *
9424
+ * Extracts individual frame textures (PNG/JPG byte arrays) from the binary format.
9425
+ * Used by the atlas packer to include MovieClip frames in texture atlases.
9426
+ *
9427
+ * @internal
9428
+ */
9429
+ const FILE_MARK = "yytou";
9430
+ /**
9431
+ * Parse a `.jta` binary buffer into frame and texture data.
9432
+ */
9433
+ function parseJta(data) {
9434
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
9435
+ let pos = 0;
9436
+ const markLen = view.getUint16(pos);
9437
+ pos += 2;
9438
+ if (pos + markLen > data.length) throw new Error("Invalid .jta file: truncated file mark");
9439
+ const mark = new TextDecoder("utf-8").decode(data.subarray(pos, pos + markLen));
9440
+ pos += markLen;
9441
+ if (mark !== FILE_MARK) throw new Error(`Invalid .jta file: expected "${FILE_MARK}", got "${mark}"`);
9442
+ const version = view.getInt32(pos);
9443
+ pos += 4;
9444
+ if (version < 100 || version > 102) throw new Error(`Unsupported .jta version: ${version}`);
9445
+ let fps = view.getInt8(pos);
9446
+ pos += 1;
9447
+ if (fps === 0) fps = 24;
9448
+ pos += 3;
9449
+ let boundsWidth = 0, boundsHeight = 0;
9450
+ if (version >= 102) {
9451
+ pos += 4;
9452
+ boundsWidth = view.getUint16(pos);
9453
+ pos += 2;
9454
+ boundsHeight = view.getUint16(pos);
9455
+ pos += 2;
9456
+ }
9457
+ const speed = view.getUint8(pos);
9458
+ pos += 1;
9459
+ const repeatDelay = view.getUint8(pos);
9460
+ pos += 1;
9461
+ const swing = view.getInt8(pos) === 1;
9462
+ pos += 1;
9463
+ const frameCount = view.getInt16(pos);
9464
+ pos += 2;
9465
+ if (frameCount < 0) throw new Error("Invalid .jta file: negative frame count");
9466
+ const frames = [];
9467
+ for (let i = 0; i < frameCount; i++) {
9468
+ const delay = view.getInt16(pos);
9469
+ pos += 2;
9470
+ const rectX = view.getInt16(pos);
9471
+ pos += 2;
9472
+ const rectY = view.getInt16(pos);
9473
+ pos += 2;
9474
+ const rectWidth = view.getInt16(pos);
9475
+ pos += 2;
9476
+ const rectHeight = view.getInt16(pos);
9477
+ pos += 2;
9478
+ const textureIndex = view.getInt16(pos);
9479
+ pos += 2;
9480
+ frames.push({
9481
+ delay,
9482
+ rectX,
9483
+ rectY,
9484
+ rectWidth,
9485
+ rectHeight,
9486
+ textureIndex
9487
+ });
9488
+ }
9489
+ const textureCount = view.getInt16(pos);
9490
+ pos += 2;
9491
+ if (textureCount < 0) throw new Error("Invalid .jta file: negative texture count");
9492
+ const textures = [];
9493
+ for (let i = 0; i < textureCount; i++) {
9494
+ const rawLen = view.getInt32(pos);
9495
+ pos += 4;
9496
+ if (rawLen < 0 || pos + rawLen > data.length) throw new Error("Invalid .jta file: truncated texture data");
9497
+ let raw;
9498
+ if (rawLen > 0) {
9499
+ raw = data.subarray(pos, pos + rawLen);
9500
+ pos += rawLen;
9501
+ } else raw = new Uint8Array(0);
9502
+ textures.push({ raw });
9503
+ }
9504
+ if (version === 101) {
9505
+ pos += 4;
9506
+ boundsWidth = view.getUint16(pos);
9507
+ pos += 2;
9508
+ boundsHeight = view.getUint16(pos);
9509
+ pos += 2;
9510
+ } else if (version === 100) {
9511
+ let minX = Number.POSITIVE_INFINITY;
9512
+ let minY = Number.POSITIVE_INFINITY;
9513
+ let maxX = Number.NEGATIVE_INFINITY;
9514
+ let maxY = Number.NEGATIVE_INFINITY;
9515
+ for (const frame of frames) {
9516
+ if (frame.rectWidth <= 0 || frame.rectHeight <= 0) continue;
9517
+ minX = Math.min(minX, frame.rectX);
9518
+ minY = Math.min(minY, frame.rectY);
9519
+ maxX = Math.max(maxX, frame.rectX + frame.rectWidth);
9520
+ maxY = Math.max(maxY, frame.rectY + frame.rectHeight);
9521
+ }
9522
+ if (Number.isFinite(minX)) {
9523
+ boundsWidth = maxX - Math.min(minX, 0);
9524
+ boundsHeight = maxY - Math.min(minY, 0);
9525
+ }
9526
+ }
9527
+ return {
9528
+ version,
9529
+ fps,
9530
+ speed,
9531
+ repeatDelay,
9532
+ swing,
9533
+ boundsWidth,
9534
+ boundsHeight,
9535
+ frames,
9536
+ textures
9537
+ };
9538
+ }
9539
+ function tryReadJtaSize(data) {
9540
+ try {
9541
+ const parsed = parseJta(data);
9542
+ return {
9543
+ width: parsed.boundsWidth,
9544
+ height: parsed.boundsHeight
9545
+ };
9546
+ } catch {
9547
+ return null;
9548
+ }
9549
+ }
9550
+ //#endregion
9371
9551
  //#region ../core/src/document.ts
9372
9552
  /**
9373
9553
  * Wraps a FairyGUI project and its resources for easier modification.
@@ -9564,6 +9744,7 @@ const defineNode = (attrs, children, containers) => ({
9564
9744
  });
9565
9745
  const PACKAGE_DESCRIPTION_ATTRS = {
9566
9746
  id: { canonical: "id" },
9747
+ hasFavorites: { canonical: "hasFavorites" },
9567
9748
  compressPNG: { canonical: "compressPNG" },
9568
9749
  jpegQuality: { canonical: "jpegQuality" }
9569
9750
  };
@@ -9584,7 +9765,8 @@ const PACKAGE_RESOURCE_BASE_ATTRS = {
9584
9765
  id: { canonical: "id" },
9585
9766
  name: { canonical: "name" },
9586
9767
  path: { canonical: "path" },
9587
- exported: { canonical: "exported" }
9768
+ exported: { canonical: "exported" },
9769
+ favorite: { canonical: "favorite" }
9588
9770
  };
9589
9771
  const PACKAGE_IMAGE_RESOURCE_ATTRS = {
9590
9772
  atlas: { canonical: "atlas" },
@@ -12131,6 +12313,10 @@ var ProjectReader = class {
12131
12313
  const data = new Uint8Array(await fs.readFileRaw(filePath));
12132
12314
  const buffer = doc.createBuffer().setURI(sourcePath).setData(data);
12133
12315
  this._asSourceDataResource(resource).setSourceData(buffer);
12316
+ if (resource.propertyType === "MovieClipResource") {
12317
+ const size = tryReadJtaSize(data);
12318
+ if (size) resource.setWidth(size.width).setHeight(size.height);
12319
+ }
12134
12320
  } catch {}
12135
12321
  }
12136
12322
  }
@@ -12162,6 +12348,7 @@ var ProjectReader = class {
12162
12348
  const name = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.name) ?? "";
12163
12349
  const path = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.path) ?? "/";
12164
12350
  const exported = parseBool(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.exported));
12351
+ const favorite = parseBool(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.favorite));
12165
12352
  switch (tagName) {
12166
12353
  case "image": {
12167
12354
  const res = doc.createImageResource(name.replace(/\.\w+$/, ""));
@@ -12169,6 +12356,7 @@ var ProjectReader = class {
12169
12356
  res.setPath(path);
12170
12357
  res.setBranch(branchName);
12171
12358
  res.setExported(exported);
12359
+ res.setFavorite(favorite);
12172
12360
  res.setFileName(name);
12173
12361
  const textureSetMode = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageImageResource.attrs.atlas);
12174
12362
  if (textureSetMode !== void 0) res.setTextureSetMode(textureSetMode);
@@ -12198,6 +12386,7 @@ var ProjectReader = class {
12198
12386
  res.setPath(path);
12199
12387
  res.setBranch(branchName);
12200
12388
  res.setExported(exported);
12389
+ res.setFavorite(favorite);
12201
12390
  const filePath = fs.join(packageDir, path.replace(/^\//, ""), name);
12202
12391
  res.setExtras({
12203
12392
  ...res.getExtras(),
@@ -12214,6 +12403,7 @@ var ProjectReader = class {
12214
12403
  res.setBranch(branchName);
12215
12404
  res.setFile(name);
12216
12405
  res.setExported(exported);
12406
+ res.setFavorite(favorite);
12217
12407
  pkg.addResource(res);
12218
12408
  ctx.registerResource(pkg.getId(), id, res);
12219
12409
  return res;
@@ -12225,6 +12415,7 @@ var ProjectReader = class {
12225
12415
  res.setBranch(branchName);
12226
12416
  res.setFile(name);
12227
12417
  res.setExported(exported);
12418
+ res.setFavorite(favorite);
12228
12419
  pkg.addResource(res);
12229
12420
  ctx.registerResource(pkg.getId(), id, res);
12230
12421
  return res;
@@ -12236,6 +12427,7 @@ var ProjectReader = class {
12236
12427
  res.setBranch(branchName);
12237
12428
  res.setFileName(name);
12238
12429
  res.setExported(exported);
12430
+ res.setFavorite(favorite);
12239
12431
  const texture = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageFontResource.attrs.texture);
12240
12432
  if (texture) res.setTextureId(texture);
12241
12433
  const renderMode = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageFontResource.attrs.renderMode);
@@ -12253,6 +12445,7 @@ var ProjectReader = class {
12253
12445
  res.setBranch(branchName);
12254
12446
  res.setFile(name);
12255
12447
  res.setExported(exported);
12448
+ res.setFavorite(favorite);
12256
12449
  res.setWidth(parseInt2(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageSkeletonResource.attrs.width)));
12257
12450
  res.setHeight(parseInt2(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageSkeletonResource.attrs.height)));
12258
12451
  const requireValue = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageSkeletonResource.attrs.require);
@@ -12275,6 +12468,7 @@ var ProjectReader = class {
12275
12468
  res.setBranch(branchName);
12276
12469
  res.setFile(name);
12277
12470
  res.setExported(exported);
12471
+ res.setFavorite(favorite);
12278
12472
  res.setWidth(parseInt2(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageSkeletonResource.attrs.width)));
12279
12473
  res.setHeight(parseInt2(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageSkeletonResource.attrs.height)));
12280
12474
  const requireValue = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageSkeletonResource.attrs.require);
@@ -12297,6 +12491,7 @@ var ProjectReader = class {
12297
12491
  res.setBranch(branchName);
12298
12492
  res.setFileName(name);
12299
12493
  res.setExported(exported);
12494
+ res.setFavorite(favorite);
12300
12495
  const textureSetMode = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageMovieClipResource.attrs.atlas);
12301
12496
  if (textureSetMode !== void 0) res.setTextureSetMode(textureSetMode);
12302
12497
  pkg.addResource(res);
@@ -13659,6 +13854,7 @@ var ProjectWriter = class {
13659
13854
  const codePath = pkg.getCodePath();
13660
13855
  const packageDescriptionAttrs = {};
13661
13856
  writeXmlAttr(packageDescriptionAttrs, PROJECT_XML_PROTOCOL.packageDescription.attrs.id, pkg.getId());
13857
+ if (pkg.listResources().some((resource) => resource.getFavorite?.())) writeXmlAttr(packageDescriptionAttrs, PROJECT_XML_PROTOCOL.packageDescription.attrs.hasFavorites, "true");
13662
13858
  const compressPNG = pkg.getCompressPNG();
13663
13859
  if (compressPNG !== null) writeXmlAttr(packageDescriptionAttrs, PROJECT_XML_PROTOCOL.packageDescription.attrs.compressPNG, compressPNG ? "true" : "false");
13664
13860
  const jpegQuality = pkg.getJpegQuality();
@@ -13869,6 +14065,7 @@ var ProjectWriter = class {
13869
14065
  writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.name, this._resourceFileName(res));
13870
14066
  writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.path, typedRes.getPath?.() ?? "/");
13871
14067
  if (typedRes.getExported?.()) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.exported, "true");
14068
+ if (typedRes.getFavorite?.()) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResource.attrs.favorite, "true");
13872
14069
  if (res.propertyType === "ImageResource") {
13873
14070
  const imgRes = res;
13874
14071
  const textureSetMode = imgRes.getTextureSetMode?.() ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfairygui/cli",
3
- "version": "0.2.0-alpha.21",
3
+ "version": "0.2.0-alpha.23",
4
4
  "description": "FairyGUI Headless Authoring SDK — command-line interface.",
5
5
  "author": "OpenFairyGUI Contributors",
6
6
  "license": "MIT",
@@ -33,13 +33,13 @@
33
33
  "restore"
34
34
  ],
35
35
  "devDependencies": {
36
- "@openfairygui/core": "0.2.0-alpha.21",
37
- "@openfairygui/functions": "0.2.0-alpha.21"
36
+ "@openfairygui/core": "0.2.0-alpha.23",
37
+ "@openfairygui/functions": "0.2.0-alpha.23"
38
38
  },
39
39
  "dependencies": {
40
40
  "commander": "^14.0.2",
41
41
  "jiti": "^2.7.0",
42
- "@openfairygui/backend": "0.2.0-alpha.21"
42
+ "@openfairygui/backend": "0.2.0-alpha.23"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "sharp": ">=0.33.0"