lbrnts 0.0.13 → 0.0.14

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/index.d.ts CHANGED
@@ -317,8 +317,10 @@ declare class ShapeText extends ShapeBase {
317
317
  declare class ShapeGroup extends ShapeBase {
318
318
  children: LightBurnBaseElement[];
319
319
  constructor();
320
+ getXmlAttributes(): Record<string, string | number | boolean | undefined>;
320
321
  static fromXmlJson(node: XmlJsonElement): ShapeGroup;
321
322
  getChildren(): LightBurnBaseElement[];
323
+ toXml(indent?: number): string;
322
324
  }
323
325
 
324
326
  declare class ShapeBitmap extends ShapeBase {
package/dist/index.js CHANGED
@@ -1080,11 +1080,17 @@ var ShapeGroup = class _ShapeGroup extends ShapeBase {
1080
1080
  super();
1081
1081
  this.token = "Shape.Group";
1082
1082
  }
1083
+ getXmlAttributes() {
1084
+ return {
1085
+ Type: "Group",
1086
+ ...this.getShapeXmlAttributes()
1087
+ };
1088
+ }
1083
1089
  static fromXmlJson(node) {
1084
1090
  const group = new _ShapeGroup();
1085
1091
  const common = ShapeBase.readCommon(node);
1086
1092
  Object.assign(group, common);
1087
- const shapes = node.Shape;
1093
+ const shapes = node.Children?.Shape || node.Shape;
1088
1094
  if (shapes) {
1089
1095
  if (Array.isArray(shapes)) {
1090
1096
  for (const shape of shapes) {
@@ -1104,6 +1110,32 @@ var ShapeGroup = class _ShapeGroup extends ShapeBase {
1104
1110
  const baseChildren = super.getChildren();
1105
1111
  return [...baseChildren, ...this.children];
1106
1112
  }
1113
+ toXml(indent = 0) {
1114
+ const indentStr = " ".repeat(indent);
1115
+ const tag = this.getXmlTag();
1116
+ const attrs = this.getXmlAttributes();
1117
+ const attrPairs = [];
1118
+ for (const [key, value] of Object.entries(attrs)) {
1119
+ if (value !== void 0 && value !== null) {
1120
+ if (typeof value === "boolean") {
1121
+ attrPairs.push(`${key}="${value ? "True" : "False"}"`);
1122
+ } else {
1123
+ attrPairs.push(`${key}="${value}"`);
1124
+ }
1125
+ }
1126
+ }
1127
+ const attrStr = attrPairs.length > 0 ? " " + attrPairs.join(" ") : "";
1128
+ const lines = [`${indentStr}<${tag}${attrStr}>`];
1129
+ const xformXml = super.getChildren()[0].toXml(indent + 1);
1130
+ lines.push(xformXml);
1131
+ lines.push(`${" ".repeat(indent + 1)}<Children>`);
1132
+ for (const child of this.children) {
1133
+ lines.push(child.toXml(indent + 2));
1134
+ }
1135
+ lines.push(`${" ".repeat(indent + 1)}</Children>`);
1136
+ lines.push(`${indentStr}</${tag}>`);
1137
+ return lines.join("\n");
1138
+ }
1107
1139
  };
1108
1140
  LightBurnBaseElement.register("Shape.Group", ShapeGroup);
1109
1141
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lbrnts",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.13",
5
+ "version": "0.0.14",
6
6
  "files": [
7
7
  "dist"
8
8
  ],