@openfairygui/cli 0.3.0-alpha.2 → 0.3.0-alpha.4

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 +404 -23
  2. package/package.json +4 -4
package/dist/cli.mjs CHANGED
@@ -821,7 +821,7 @@ var ExtensibleProperty = class extends Property {
821
821
  };
822
822
  //#endregion
823
823
  //#region ../core/src/constants.ts
824
- const VERSION = `v0.3.0-alpha.2`;
824
+ const VERSION = `v0.3.0-alpha.4`;
825
825
  /** Binary package file magic number: "FGUI" as uint32. */
826
826
  const FGUI_MAGIC = 1179080009;
827
827
  /** Null string index in the binary string table. */
@@ -19366,8 +19366,8 @@ function createDisplayObject$1(ctx, doc, tagName, attrs, localControllers) {
19366
19366
  const groupLayout = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.group.attrs.layout);
19367
19367
  if (groupLayout) g.setLayout({
19368
19368
  none: 0,
19369
- horizontal: 1,
19370
- vertical: 2
19369
+ hz: 1,
19370
+ vt: 2
19371
19371
  }[groupLayout] ?? 0);
19372
19372
  const groupLineGap = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.group.attrs.lineGap);
19373
19373
  if (groupLineGap !== void 0) g.setLineGap(parseInt2(groupLineGap));
@@ -20447,6 +20447,358 @@ function getXmlNode(value) {
20447
20447
  if (!node || typeof node !== "object" || Array.isArray(node)) return null;
20448
20448
  return node;
20449
20449
  }
20450
+ const COMPONENT_INT32_RULES = [
20451
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.size, 2],
20452
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.restrictSize, 4],
20453
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.margin, 4],
20454
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.scrollBarMargin, 4],
20455
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.clipSoftness, 2],
20456
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageOffsetX, 1],
20457
+ [PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageOffsetY, 1]
20458
+ ];
20459
+ const DISPLAY_OBJECT_INT32_RULES = [
20460
+ [PROJECT_XML_PROTOCOL.list.attrs.xy, 2],
20461
+ [PROJECT_XML_PROTOCOL.list.attrs.size, 2],
20462
+ [PROJECT_XML_PROTOCOL.list.attrs.restrictSize, 4]
20463
+ ];
20464
+ const LIST_INT32_RULES = [
20465
+ [PROJECT_XML_PROTOCOL.list.attrs.margin, 4],
20466
+ [PROJECT_XML_PROTOCOL.list.attrs.scrollBarMargin, 4],
20467
+ [PROJECT_XML_PROTOCOL.list.attrs.clipSoftness, 2]
20468
+ ];
20469
+ function isProjectInt32(value) {
20470
+ const trimmed = value.trim();
20471
+ if (!/^[+-]?\d+$/.test(trimmed)) return false;
20472
+ const parsed = BigInt(trimmed);
20473
+ return parsed >= -2147483648n && parsed <= 2147483647n;
20474
+ }
20475
+ function isProjectFiniteNumber(value) {
20476
+ const trimmed = value.trim();
20477
+ return /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(trimmed) && Number.isFinite(Number(trimmed));
20478
+ }
20479
+ function isProjectBoolean(value) {
20480
+ return [
20481
+ "true",
20482
+ "false",
20483
+ "1",
20484
+ "0"
20485
+ ].includes(value.trim());
20486
+ }
20487
+ function hasInvalidProjectInt32Parts(value, partCount, allowSuffix = false) {
20488
+ const parts = String(value).split(",");
20489
+ if (allowSuffix ? parts.length < partCount : parts.length !== partCount) return true;
20490
+ return parts.slice(0, partCount).some((part) => !isProjectInt32(part));
20491
+ }
20492
+ function validateComponentXmlValues(ctx, comp, sourcePath, componentNode) {
20493
+ const addInvalidValue = (attrs, spec, path, expectation, isValid, nodeId) => {
20494
+ if (!spec) return;
20495
+ const value = readXmlAttr(attrs, spec);
20496
+ if (value === void 0 || isValid(String(value))) return;
20497
+ ctx.addDiagnostic({
20498
+ severity: "error",
20499
+ code: "invalid_project_value",
20500
+ path: `${path}.${spec.canonical}`,
20501
+ message: `Attribute "${spec.canonical}" must be ${expectation}; received ${JSON.stringify(String(value))}.`,
20502
+ resourceId: comp.getId(),
20503
+ ...nodeId ? { nodeId } : {},
20504
+ sourcePath
20505
+ });
20506
+ };
20507
+ const validateBooleanAttrs = (attrs, specs, path, nodeId) => {
20508
+ for (const spec of specs) addInvalidValue(attrs, spec, path, "true, false, 1, or 0", isProjectBoolean, nodeId);
20509
+ };
20510
+ const validateInt32Attrs = (attrs, specs, path, nodeId) => {
20511
+ for (const spec of specs) addInvalidValue(attrs, spec, path, "a signed 32-bit integer", isProjectInt32, nodeId);
20512
+ };
20513
+ const validateNumberTuple = (attrs, spec, partCount, path, nodeId) => {
20514
+ addInvalidValue(attrs, spec, path, `exactly ${partCount} finite number(s)`, (value) => {
20515
+ const parts = value.split(",");
20516
+ return parts.length === partCount && parts.every(isProjectFiniteNumber);
20517
+ }, nodeId);
20518
+ };
20519
+ const validateEnum = (attrs, spec, values, path, nodeId) => {
20520
+ addInvalidValue(attrs, spec, path, `one of ${values.map((value) => JSON.stringify(value)).join(", ")}`, (value) => values.includes(value.trim()), nodeId);
20521
+ };
20522
+ const addDiagnostics = (attrs, rules, path, nodeId) => {
20523
+ for (const [spec, partCount] of rules) {
20524
+ const value = readXmlAttr(attrs, spec);
20525
+ if (value === void 0 || !hasInvalidProjectInt32Parts(value, partCount)) continue;
20526
+ ctx.addDiagnostic({
20527
+ severity: "error",
20528
+ code: "desktop_incompatible_geometry",
20529
+ path: `${path}.${spec.canonical}`,
20530
+ message: `FairyGUI Desktop requires "${spec.canonical}" to contain ${partCount} signed 32-bit integer value(s); received ${JSON.stringify(String(value))}.`,
20531
+ resourceId: comp.getId(),
20532
+ ...nodeId ? { nodeId } : {},
20533
+ sourcePath
20534
+ });
20535
+ }
20536
+ };
20537
+ const componentPath = `components.${comp.getId()}`;
20538
+ const rootPath = `${componentPath}.component`;
20539
+ const rootAttrs = PROJECT_XML_PROTOCOL.componentRoot.attrs;
20540
+ addDiagnostics(componentNode, COMPONENT_INT32_RULES, rootPath);
20541
+ validateBooleanAttrs(componentNode, [
20542
+ rootAttrs.anchor,
20543
+ rootAttrs.opaque,
20544
+ rootAttrs.reversedMask,
20545
+ rootAttrs.bgColorEnabled
20546
+ ], rootPath);
20547
+ validateInt32Attrs(componentNode, [
20548
+ rootAttrs.scrollBarFlags,
20549
+ rootAttrs.designImageAlpha,
20550
+ rootAttrs.designImageLayer,
20551
+ rootAttrs.idnum
20552
+ ], rootPath);
20553
+ validateNumberTuple(componentNode, rootAttrs.pivot, 2, rootPath);
20554
+ validateEnum(componentNode, rootAttrs.overflow, [
20555
+ "visible",
20556
+ "hidden",
20557
+ "scroll"
20558
+ ], rootPath);
20559
+ validateEnum(componentNode, rootAttrs.scroll, [
20560
+ "horizontal",
20561
+ "vertical",
20562
+ "both"
20563
+ ], rootPath);
20564
+ validateEnum(componentNode, rootAttrs.scrollBar, [
20565
+ "default",
20566
+ "visible",
20567
+ "auto",
20568
+ "hidden"
20569
+ ], rootPath);
20570
+ const displayList = getXmlNode(componentNode.displayList);
20571
+ if (!displayList) return;
20572
+ let nodeIndex = 0;
20573
+ for (const [tagName, definitions] of Object.entries(displayList)) for (const definition of ensureArray(definitions)) {
20574
+ const attrs = getXmlNode(definition);
20575
+ if (!attrs) continue;
20576
+ const nodeId = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.displayObject.attrs.id);
20577
+ const nodePath = `${componentPath}.displayList.${nodeIndex++}`;
20578
+ addDiagnostics(attrs, DISPLAY_OBJECT_INT32_RULES, nodePath, nodeId);
20579
+ const normalizedTagName = tagName.toLowerCase();
20580
+ const displayAttrs = (Object.entries(PROJECT_XML_PROTOCOL.componentRoot.containers?.displayList?.items ?? {}).find(([name]) => name.toLowerCase() === normalizedTagName)?.[1])?.attrs;
20581
+ if (displayAttrs) {
20582
+ validateBooleanAttrs(attrs, [
20583
+ displayAttrs.locked,
20584
+ displayAttrs.aspect,
20585
+ displayAttrs.anchor,
20586
+ displayAttrs.visible,
20587
+ displayAttrs.touchable,
20588
+ displayAttrs.grayed
20589
+ ], nodePath, nodeId);
20590
+ for (const spec of [
20591
+ displayAttrs.pivot,
20592
+ displayAttrs.scale,
20593
+ displayAttrs.skew
20594
+ ]) validateNumberTuple(attrs, spec, 2, nodePath, nodeId);
20595
+ addInvalidValue(attrs, displayAttrs.rotation, nodePath, "a finite number", isProjectFiniteNumber, nodeId);
20596
+ addInvalidValue(attrs, displayAttrs.alpha, nodePath, "a finite number between 0 and 1", (value) => isProjectFiniteNumber(value) && Number(value) >= 0 && Number(value) <= 1, nodeId);
20597
+ }
20598
+ if (normalizedTagName === "list" || normalizedTagName === "tree") addDiagnostics(attrs, LIST_INT32_RULES, nodePath, nodeId);
20599
+ if (displayAttrs && [
20600
+ "text",
20601
+ "richtext",
20602
+ "inputtext"
20603
+ ].includes(normalizedTagName)) {
20604
+ validateBooleanAttrs(attrs, [
20605
+ displayAttrs.input,
20606
+ displayAttrs.singleLine,
20607
+ displayAttrs.autoClearText,
20608
+ displayAttrs.vars,
20609
+ displayAttrs.ubb,
20610
+ displayAttrs.underline,
20611
+ displayAttrs.italic,
20612
+ displayAttrs.bold,
20613
+ displayAttrs.strikethrough,
20614
+ displayAttrs.password
20615
+ ], nodePath, nodeId);
20616
+ validateInt32Attrs(attrs, [
20617
+ displayAttrs.leading,
20618
+ displayAttrs.letterSpacing,
20619
+ displayAttrs.maxLength,
20620
+ displayAttrs.keyboardType
20621
+ ], nodePath, nodeId);
20622
+ addInvalidValue(attrs, displayAttrs.fontSize, nodePath, "a positive signed 32-bit integer", (value) => isProjectInt32(value) && BigInt(value.trim()) > 0n, nodeId);
20623
+ for (const spec of [
20624
+ displayAttrs.strokeSize,
20625
+ displayAttrs.faceDilate,
20626
+ displayAttrs.underlaySoftness
20627
+ ]) addInvalidValue(attrs, spec, nodePath, "a finite number", isProjectFiniteNumber, nodeId);
20628
+ validateNumberTuple(attrs, displayAttrs.shadowOffset, 2, nodePath, nodeId);
20629
+ validateEnum(attrs, displayAttrs.align, [
20630
+ "left",
20631
+ "center",
20632
+ "right"
20633
+ ], nodePath, nodeId);
20634
+ validateEnum(attrs, displayAttrs.vAlign, [
20635
+ "top",
20636
+ "middle",
20637
+ "bottom"
20638
+ ], nodePath, nodeId);
20639
+ validateEnum(attrs, displayAttrs.autoSize, [
20640
+ "none",
20641
+ "both",
20642
+ "height",
20643
+ "shrink",
20644
+ "ellipsis"
20645
+ ], nodePath, nodeId);
20646
+ }
20647
+ if (displayAttrs && (normalizedTagName === "list" || normalizedTagName === "tree")) {
20648
+ validateBooleanAttrs(attrs, [
20649
+ displayAttrs.autoResizeItem,
20650
+ displayAttrs.treeView,
20651
+ displayAttrs.autoClearItems,
20652
+ displayAttrs.scrollItemToViewOnClick,
20653
+ displayAttrs.foldInvisibleItems
20654
+ ], nodePath, nodeId);
20655
+ validateInt32Attrs(attrs, [
20656
+ displayAttrs.lineGap,
20657
+ displayAttrs.columnGap,
20658
+ displayAttrs.lineItemCount,
20659
+ displayAttrs.lineItemCount2,
20660
+ displayAttrs.apexIndex,
20661
+ displayAttrs.scrollBarFlags,
20662
+ displayAttrs.indent,
20663
+ displayAttrs.clickToExpand
20664
+ ], nodePath, nodeId);
20665
+ validateEnum(attrs, displayAttrs.layout, [
20666
+ "singleColumn",
20667
+ "singleRow",
20668
+ "flowHorizontal",
20669
+ "flowVertical",
20670
+ "pagination",
20671
+ "single_column",
20672
+ "single_row",
20673
+ "flow_hz",
20674
+ "flow_vt",
20675
+ "column",
20676
+ "row"
20677
+ ], nodePath, nodeId);
20678
+ validateEnum(attrs, displayAttrs.align, [
20679
+ "left",
20680
+ "center",
20681
+ "right"
20682
+ ], nodePath, nodeId);
20683
+ validateEnum(attrs, displayAttrs.vAlign, [
20684
+ "top",
20685
+ "middle",
20686
+ "bottom"
20687
+ ], nodePath, nodeId);
20688
+ validateEnum(attrs, displayAttrs.childrenRenderOrder, [
20689
+ "ascent",
20690
+ "descent",
20691
+ "arch"
20692
+ ], nodePath, nodeId);
20693
+ validateEnum(attrs, displayAttrs.selectionMode, [
20694
+ "single",
20695
+ "multiple",
20696
+ "multipleSingleClick",
20697
+ "none"
20698
+ ], nodePath, nodeId);
20699
+ validateEnum(attrs, displayAttrs.overflow, [
20700
+ "visible",
20701
+ "hidden",
20702
+ "scroll"
20703
+ ], nodePath, nodeId);
20704
+ validateEnum(attrs, displayAttrs.scroll, [
20705
+ "horizontal",
20706
+ "vertical",
20707
+ "both"
20708
+ ], nodePath, nodeId);
20709
+ validateEnum(attrs, displayAttrs.scrollBar, [
20710
+ "default",
20711
+ "visible",
20712
+ "auto",
20713
+ "hidden"
20714
+ ], nodePath, nodeId);
20715
+ }
20716
+ if (displayAttrs && normalizedTagName === "group") {
20717
+ validateBooleanAttrs(attrs, [
20718
+ displayAttrs.advanced,
20719
+ displayAttrs.excludeInvisibles,
20720
+ displayAttrs.autoSizeDisabled
20721
+ ], nodePath, nodeId);
20722
+ validateInt32Attrs(attrs, [
20723
+ displayAttrs.lineGap,
20724
+ displayAttrs.columnGap,
20725
+ displayAttrs.mainGridIndex
20726
+ ], nodePath, nodeId);
20727
+ validateEnum(attrs, displayAttrs.layout, [
20728
+ "none",
20729
+ "hz",
20730
+ "vt"
20731
+ ], nodePath, nodeId);
20732
+ }
20733
+ if (displayAttrs && [
20734
+ "image",
20735
+ "loader",
20736
+ "loader3d"
20737
+ ].includes(normalizedTagName)) {
20738
+ validateBooleanAttrs(attrs, [
20739
+ displayAttrs.fillClockwise,
20740
+ displayAttrs.shrinkOnly,
20741
+ displayAttrs.autoSize,
20742
+ displayAttrs.useResize,
20743
+ displayAttrs.playing,
20744
+ displayAttrs.loop,
20745
+ displayAttrs.clearOnPublish
20746
+ ], nodePath, nodeId);
20747
+ validateInt32Attrs(attrs, [
20748
+ displayAttrs.frame,
20749
+ displayAttrs.fillOrigin,
20750
+ displayAttrs.fillAmount
20751
+ ], nodePath, nodeId);
20752
+ validateEnum(attrs, displayAttrs.align, [
20753
+ "left",
20754
+ "center",
20755
+ "right"
20756
+ ], nodePath, nodeId);
20757
+ validateEnum(attrs, displayAttrs.vAlign, [
20758
+ "top",
20759
+ "middle",
20760
+ "bottom"
20761
+ ], nodePath, nodeId);
20762
+ validateEnum(attrs, displayAttrs.fill, [
20763
+ "none",
20764
+ "scale",
20765
+ "scaleMatchHeight",
20766
+ "scaleMatchWidth",
20767
+ "scaleFree",
20768
+ "scaleNoBorder"
20769
+ ], nodePath, nodeId);
20770
+ validateEnum(attrs, displayAttrs.fillMethod, [
20771
+ "none",
20772
+ "hz",
20773
+ "vt",
20774
+ "radial90",
20775
+ "radial180",
20776
+ "radial360"
20777
+ ], nodePath, nodeId);
20778
+ }
20779
+ if (displayAttrs && (normalizedTagName === "movieclip" || normalizedTagName === "jta")) {
20780
+ validateBooleanAttrs(attrs, [displayAttrs.playing], nodePath, nodeId);
20781
+ validateInt32Attrs(attrs, [displayAttrs.frame], nodePath, nodeId);
20782
+ }
20783
+ for (const gearTag of ["gearXY", "gearSize"]) for (const [gearIndex, gearDefinition] of ensureArray(attrs[gearTag]).entries()) {
20784
+ const gear = getXmlNode(gearDefinition);
20785
+ if (!gear) continue;
20786
+ for (const spec of [PROJECT_XML_PROTOCOL.gear.attrs.values, PROJECT_XML_PROTOCOL.gear.attrs.default]) {
20787
+ const value = readXmlAttr(gear, spec);
20788
+ if (value === void 0 || !String(value).split("|").some((segment) => segment.trim() !== "-" && hasInvalidProjectInt32Parts(segment, 2, true))) continue;
20789
+ ctx.addDiagnostic({
20790
+ severity: "error",
20791
+ code: "desktop_incompatible_geometry",
20792
+ path: `${nodePath}.${gearTag}.${gearIndex}.${spec.canonical}`,
20793
+ message: `FairyGUI Desktop requires each "${gearTag}.${spec.canonical}" segment to start with two signed 32-bit integers; received ${JSON.stringify(String(value))}.`,
20794
+ resourceId: comp.getId(),
20795
+ ...nodeId ? { nodeId } : {},
20796
+ sourcePath
20797
+ });
20798
+ }
20799
+ }
20800
+ }
20801
+ }
20450
20802
  function assignSetting(settings, key, value) {
20451
20803
  switch (key) {
20452
20804
  case "publish":
@@ -20569,7 +20921,9 @@ var ProjectReader = class {
20569
20921
  const compContent = await fs.readFile(compPath);
20570
20922
  if (diagnostics) {
20571
20923
  assertWellFormedXml(compContent);
20572
- if (!getXmlNode(parseXML(compContent).component)) throw new Error("Component XML must contain a component root element.");
20924
+ const componentNode = getXmlNode(parseXML(compContent).component);
20925
+ if (!componentNode) throw new Error("Component XML must contain a component root element.");
20926
+ validateComponentXmlValues(ctx, comp, compPath, componentNode);
20573
20927
  }
20574
20928
  readComponentXml(ctx, comp, compContent);
20575
20929
  } catch (err) {
@@ -21297,6 +21651,17 @@ function formatTrimmedFixed$1(value, precision = 2) {
21297
21651
  if (precision === 0) return value.toFixed(0);
21298
21652
  return value.toFixed(precision).replace(/(?:\.0+|(\.\d*?[1-9])0+)$/, "$1");
21299
21653
  }
21654
+ const INT32_MIN = -2147483648;
21655
+ const INT32_MAX = 2147483647;
21656
+ function formatProjectInt32(value, field = "project XML integer") {
21657
+ if (!Number.isFinite(value)) throw new Error(`${field} must be finite.`);
21658
+ const normalized = Math.trunc(value);
21659
+ if (normalized < INT32_MIN || normalized > INT32_MAX) throw new Error(`${field} must fit a signed 32-bit integer.`);
21660
+ return Object.is(normalized, -0) ? "0" : String(normalized);
21661
+ }
21662
+ function formatProjectInt32List(values, field) {
21663
+ return values.map((value) => formatProjectInt32(value, field)).join(",");
21664
+ }
21300
21665
  function formatDisplayAlpha(value) {
21301
21666
  return formatTrimmedFixed$1(value, 2);
21302
21667
  }
@@ -21354,7 +21719,7 @@ function normalizeGearSizeSegment(segment, fixedScale, omitIdentityScale) {
21354
21719
  if (!segment || segment === "-") return segment;
21355
21720
  const parts = segment.split(",");
21356
21721
  if (parts.length < 2) return segment;
21357
- const normalized = [String(Math.trunc(Number(parts[0] ?? 0))), String(Math.trunc(Number(parts[1] ?? 0)))];
21722
+ const normalized = [formatProjectInt32(Number(parts[0] ?? 0), "gearSize width"), formatProjectInt32(Number(parts[1] ?? 0), "gearSize height")];
21358
21723
  if (parts.length >= 4) {
21359
21724
  if (omitIdentityScale && isIdentityGearSizeScale(segment)) return normalized.join(",");
21360
21725
  const scaleFormatter = fixedScale ? (value) => {
@@ -21365,12 +21730,23 @@ function normalizeGearSizeSegment(segment, fixedScale, omitIdentityScale) {
21365
21730
  }
21366
21731
  return normalized.join(",");
21367
21732
  }
21733
+ function normalizeGearXYSegment(segment) {
21734
+ if (!segment || segment === "-") return segment;
21735
+ const parts = segment.split(",");
21736
+ if (parts.length < 2) return segment;
21737
+ return [
21738
+ formatProjectInt32(Number(parts[0] ?? 0), "gearXY x"),
21739
+ formatProjectInt32(Number(parts[1] ?? 0), "gearXY y"),
21740
+ ...parts.slice(2)
21741
+ ].join(",");
21742
+ }
21368
21743
  function shouldCompactTextGearColor(ownerType, ownerName) {
21369
21744
  return (ownerType === "GTextField" || ownerType === "GRichTextField" || ownerType === "GTextInput") && ownerName === "title";
21370
21745
  }
21371
21746
  function normalizeGearXmlValue(gearType, value, ownerType, ownerName, gear) {
21372
21747
  const raw = String(value ?? "");
21373
21748
  switch (gearType) {
21749
+ case GearType.XY: return raw.split("|").map((segment) => normalizeGearXYSegment(segment)).join("|");
21374
21750
  case GearType.Size: {
21375
21751
  const fixedScale = !gear?.getTween();
21376
21752
  const segments = raw.split("|");
@@ -21390,10 +21766,10 @@ function normalizeGearXmlValue(gearType, value, ownerType, ownerName, gear) {
21390
21766
  }
21391
21767
  function writeCommonDisplayState(target, object, protocol) {
21392
21768
  const specs = protocol.attrs;
21393
- if (specs.xy) writeXmlAttr(target, specs.xy, `${object.getX?.() ?? 0},${object.getY?.() ?? 0}`);
21769
+ if (specs.xy) writeXmlAttr(target, specs.xy, formatProjectInt32List([object.getX?.() ?? 0, object.getY?.() ?? 0], "display object xy"));
21394
21770
  const width = object.getWidth?.() ?? 0;
21395
21771
  const height = object.getHeight?.() ?? 0;
21396
- if (specs.size && (width !== 0 || height !== 0)) writeXmlAttr(target, specs.size, `${width},${height}`);
21772
+ if (specs.size && (width !== 0 || height !== 0)) writeXmlAttr(target, specs.size, formatProjectInt32List([width, height], "display object size"));
21397
21773
  if (specs.locked && object.getLocked?.()) writeXmlAttr(target, specs.locked, "true");
21398
21774
  const restrictSize = [
21399
21775
  object.getMinWidth?.() ?? 0,
@@ -21401,7 +21777,7 @@ function writeCommonDisplayState(target, object, protocol) {
21401
21777
  object.getMinHeight?.() ?? 0,
21402
21778
  object.getMaxHeight?.() ?? 0
21403
21779
  ];
21404
- if (specs.restrictSize && restrictSize.some((value) => value !== 0)) writeXmlAttr(target, specs.restrictSize, restrictSize.join(","));
21780
+ if (specs.restrictSize && restrictSize.some((value) => value !== 0)) writeXmlAttr(target, specs.restrictSize, formatProjectInt32List(restrictSize, "display object restrictSize"));
21405
21781
  if (specs.aspect && object.getAspect?.()) writeXmlAttr(target, specs.aspect, "true");
21406
21782
  const pivotX = object.getPivotX?.() ?? 0;
21407
21783
  const pivotY = object.getPivotY?.() ?? 0;
@@ -21431,8 +21807,13 @@ function writeCommonDisplayState(target, object, protocol) {
21431
21807
  function hasNonZeroInsets(value) {
21432
21808
  return !!value && !!(value.top || value.bottom || value.left || value.right);
21433
21809
  }
21434
- function formatInsets(value) {
21435
- return `${value.top ?? 0},${value.bottom ?? 0},${value.left ?? 0},${value.right ?? 0}`;
21810
+ function formatInsets(value, field = "margin") {
21811
+ return formatProjectInt32List([
21812
+ value.top ?? 0,
21813
+ value.bottom ?? 0,
21814
+ value.left ?? 0,
21815
+ value.right ?? 0
21816
+ ], field);
21436
21817
  }
21437
21818
  function formatFillMethod(fillMethod) {
21438
21819
  return {
@@ -21863,8 +22244,8 @@ function serializeChild(obj) {
21863
22244
  const layout = typedObj.getLayout?.();
21864
22245
  if (layout !== void 0 && layout !== 0) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.group.attrs.layout, {
21865
22246
  0: "none",
21866
- 1: "horizontal",
21867
- 2: "vertical"
22247
+ 1: "hz",
22248
+ 2: "vt"
21868
22249
  }[layout] ?? "none");
21869
22250
  const lineGap = typedObj.getLineGap?.() ?? 0;
21870
22251
  if (lineGap !== 0) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.group.attrs.lineGap, String(lineGap));
@@ -21950,7 +22331,7 @@ function serializeChild(obj) {
21950
22331
  const scrollBarFlags = typedObj.getScrollBarFlags?.() ?? 0;
21951
22332
  if (scrollBarFlags !== 0) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarFlags, String(scrollBarFlags));
21952
22333
  const scrollBarMargin = typedObj.getScrollBarMargin?.();
21953
- if (hasNonZeroInsets(scrollBarMargin)) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarMargin, formatInsets(scrollBarMargin));
22334
+ if (hasNonZeroInsets(scrollBarMargin)) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarMargin, formatInsets(scrollBarMargin, "list scrollBarMargin"));
21954
22335
  const vtScrollBarRes = typedObj.getVtScrollBarRes?.() ?? "";
21955
22336
  const hzScrollBarRes = typedObj.getHzScrollBarRes?.() ?? "";
21956
22337
  if (vtScrollBarRes || hzScrollBarRes) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarRes, `${vtScrollBarRes},${hzScrollBarRes}`);
@@ -21958,9 +22339,9 @@ function serializeChild(obj) {
21958
22339
  const footerRes = typedObj.getFooterRes?.() ?? "";
21959
22340
  if (headerRes || footerRes) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.ptrRes, `${headerRes},${footerRes}`);
21960
22341
  const margin = typedObj.getMargin?.();
21961
- if (hasNonZeroInsets(margin)) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.margin, formatInsets(margin));
22342
+ if (hasNonZeroInsets(margin)) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.margin, formatInsets(margin, "list margin"));
21962
22343
  const clipSoftness = typedObj.getClipSoftness?.();
21963
- if (clipSoftness && ((clipSoftness.x ?? 0) !== 0 || (clipSoftness.y ?? 0) !== 0)) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.clipSoftness, `${clipSoftness.x ?? 0},${clipSoftness.y ?? 0}`);
22344
+ if (clipSoftness && ((clipSoftness.x ?? 0) !== 0 || (clipSoftness.y ?? 0) !== 0)) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.clipSoftness, formatProjectInt32List([clipSoftness.x ?? 0, clipSoftness.y ?? 0], "list clipSoftness"));
21964
22345
  if (typedObj.getScrollItemToViewOnClick?.() === false) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollItemToViewOnClick, "false");
21965
22346
  if (typedObj.getFoldInvisibleItems?.() === true) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.foldInvisibleItems, "true");
21966
22347
  if (typedObj.getAutoClearItems?.() === true) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.autoClearItems, "true");
@@ -22202,7 +22583,7 @@ async function writeComponent(fs, comp, pkgDir, sourceRelativePath) {
22202
22583
  await fs.mkdir(fs.dirname(targetPath));
22203
22584
  const compAttrs = {};
22204
22585
  const [w, h] = [typedComp.getWidth?.() ?? 0, typedComp.getHeight?.() ?? 0];
22205
- if (w || h) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.size, `${w},${h}`);
22586
+ if (w || h) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.size, formatProjectInt32List([w, h], "component size"));
22206
22587
  const [pivotX, pivotY] = [typedComp.getPivotX?.() ?? 0, typedComp.getPivotY?.() ?? 0];
22207
22588
  if (pivotX !== 0 || pivotY !== 0) {
22208
22589
  writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.pivot, `${pivotX},${pivotY}`);
@@ -22215,14 +22596,14 @@ async function writeComponent(fs, comp, pkgDir, sourceRelativePath) {
22215
22596
  2: "scroll"
22216
22597
  }[overflow] ?? "visible");
22217
22598
  const margin = typedComp.getMargin?.();
22218
- if (hasNonZeroInsets(margin)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.margin, formatInsets(margin));
22599
+ if (hasNonZeroInsets(margin)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.margin, formatInsets(margin, "component margin"));
22219
22600
  const restrictSize = [
22220
22601
  typedComp.getMinWidth?.() ?? 0,
22221
22602
  typedComp.getMaxWidth?.() ?? 0,
22222
22603
  typedComp.getMinHeight?.() ?? 0,
22223
22604
  typedComp.getMaxHeight?.() ?? 0
22224
22605
  ];
22225
- if (restrictSize.some((value) => value !== 0)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.restrictSize, restrictSize.join(","));
22606
+ if (restrictSize.some((value) => value !== 0)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.restrictSize, formatProjectInt32List(restrictSize, "component restrictSize"));
22226
22607
  if (typedComp.getBgColorEnabled?.()) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.bgColorEnabled, "true");
22227
22608
  const bgColor = typedComp.getBgColor?.();
22228
22609
  if (bgColor) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.bgColor, bgColor);
@@ -22231,9 +22612,9 @@ async function writeComponent(fs, comp, pkgDir, sourceRelativePath) {
22231
22612
  const designImageLayer = typedComp.getDesignImageLayer?.() ?? 0;
22232
22613
  if (designImageLayer !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageLayer, String(designImageLayer));
22233
22614
  const designImageOffsetX = typedComp.getDesignImageOffsetX?.() ?? 0;
22234
- if (designImageOffsetX !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageOffsetX, String(designImageOffsetX));
22615
+ if (designImageOffsetX !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageOffsetX, formatProjectInt32(designImageOffsetX, "designImageOffsetX"));
22235
22616
  const designImageOffsetY = typedComp.getDesignImageOffsetY?.() ?? 0;
22236
- if (designImageOffsetY !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageOffsetY, String(designImageOffsetY));
22617
+ if (designImageOffsetY !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.designImageOffsetY, formatProjectInt32(designImageOffsetY, "designImageOffsetY"));
22237
22618
  const idNum = typedComp.getIdNum?.() ?? 0;
22238
22619
  if (idNum !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.idnum, String(idNum));
22239
22620
  const initName = typedComp.getInitName?.();
@@ -22241,7 +22622,7 @@ async function writeComponent(fs, comp, pkgDir, sourceRelativePath) {
22241
22622
  const remark = typedComp.getRemark?.();
22242
22623
  if (remark) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.remark, remark);
22243
22624
  const clipSoftness = typedComp.getClipSoftness?.();
22244
- if (clipSoftness && ((clipSoftness.x ?? 0) !== 0 || (clipSoftness.y ?? 0) !== 0)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.clipSoftness, `${clipSoftness.x ?? 0},${clipSoftness.y ?? 0}`);
22625
+ if (clipSoftness && ((clipSoftness.x ?? 0) !== 0 || (clipSoftness.y ?? 0) !== 0)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.clipSoftness, formatProjectInt32List([clipSoftness.x ?? 0, clipSoftness.y ?? 0], "component clipSoftness"));
22245
22626
  if (typedComp.getOpaque?.() === false) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.opaque, "false");
22246
22627
  const mask = typedComp.getMask?.();
22247
22628
  if (mask) {
@@ -22271,7 +22652,7 @@ async function writeComponent(fs, comp, pkgDir, sourceRelativePath) {
22271
22652
  const scrollBarFlags = typedComp.getScrollBarFlags?.() ?? 0;
22272
22653
  if (scrollBarFlags !== 0) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.scrollBarFlags, String(scrollBarFlags));
22273
22654
  const scrollBarMargin = typedComp.getScrollBarMargin?.();
22274
- if (hasNonZeroInsets(scrollBarMargin)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.scrollBarMargin, formatInsets(scrollBarMargin));
22655
+ if (hasNonZeroInsets(scrollBarMargin)) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.scrollBarMargin, formatInsets(scrollBarMargin, "component scrollBarMargin"));
22275
22656
  const vtScrollBarRes = typedComp.getVtScrollBarRes?.() ?? "";
22276
22657
  const hzScrollBarRes = typedComp.getHzScrollBarRes?.() ?? "";
22277
22658
  if (vtScrollBarRes || hzScrollBarRes) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.scrollBarRes, `${vtScrollBarRes},${hzScrollBarRes}`);
@@ -31403,7 +31784,7 @@ function registerValidateCommand(program) {
31403
31784
  //#region src/utils/package-version.ts
31404
31785
  const require$1 = createRequire(import.meta.url);
31405
31786
  function getInjectedPackageVersion() {
31406
- const version = "0.3.0-alpha.2";
31787
+ const version = "0.3.0-alpha.4";
31407
31788
  return typeof version === "string" && true ? version : null;
31408
31789
  }
31409
31790
  function readPackageVersion() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfairygui/cli",
3
- "version": "0.3.0-alpha.2",
3
+ "version": "0.3.0-alpha.4",
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/functions": "0.3.0-alpha.2",
37
- "@openfairygui/core": "0.3.0-alpha.2"
36
+ "@openfairygui/core": "0.3.0-alpha.4",
37
+ "@openfairygui/functions": "0.3.0-alpha.4"
38
38
  },
39
39
  "dependencies": {
40
40
  "commander": "^14.0.2",
41
41
  "jiti": "^2.7.0",
42
- "@openfairygui/backend": "0.3.0-alpha.2"
42
+ "@openfairygui/backend": "0.3.0-alpha.4"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "sharp": ">=0.33.0"