lbrnts 0.0.13 → 0.0.15

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
@@ -566,6 +566,9 @@ var CutSettingPropertyElement = class extends LightBurnBaseElement {
566
566
  this.propValue = propValue;
567
567
  }
568
568
  formatValue(value) {
569
+ if (this.propName === "crossHatch" && typeof value === "boolean") {
570
+ return value ? "1" : "0";
571
+ }
569
572
  if (typeof value === "number") {
570
573
  if (value !== 0 && Math.abs(value) < 1e-3) {
571
574
  return value.toFixed(9).replace(/\.?0+$/, "");
@@ -1080,11 +1083,17 @@ var ShapeGroup = class _ShapeGroup extends ShapeBase {
1080
1083
  super();
1081
1084
  this.token = "Shape.Group";
1082
1085
  }
1086
+ getXmlAttributes() {
1087
+ return {
1088
+ Type: "Group",
1089
+ ...this.getShapeXmlAttributes()
1090
+ };
1091
+ }
1083
1092
  static fromXmlJson(node) {
1084
1093
  const group = new _ShapeGroup();
1085
1094
  const common = ShapeBase.readCommon(node);
1086
1095
  Object.assign(group, common);
1087
- const shapes = node.Shape;
1096
+ const shapes = node.Children?.Shape || node.Shape;
1088
1097
  if (shapes) {
1089
1098
  if (Array.isArray(shapes)) {
1090
1099
  for (const shape of shapes) {
@@ -1104,6 +1113,32 @@ var ShapeGroup = class _ShapeGroup extends ShapeBase {
1104
1113
  const baseChildren = super.getChildren();
1105
1114
  return [...baseChildren, ...this.children];
1106
1115
  }
1116
+ toXml(indent = 0) {
1117
+ const indentStr = " ".repeat(indent);
1118
+ const tag = this.getXmlTag();
1119
+ const attrs = this.getXmlAttributes();
1120
+ const attrPairs = [];
1121
+ for (const [key, value] of Object.entries(attrs)) {
1122
+ if (value !== void 0 && value !== null) {
1123
+ if (typeof value === "boolean") {
1124
+ attrPairs.push(`${key}="${value ? "True" : "False"}"`);
1125
+ } else {
1126
+ attrPairs.push(`${key}="${value}"`);
1127
+ }
1128
+ }
1129
+ }
1130
+ const attrStr = attrPairs.length > 0 ? " " + attrPairs.join(" ") : "";
1131
+ const lines = [`${indentStr}<${tag}${attrStr}>`];
1132
+ const xformXml = super.getChildren()[0].toXml(indent + 1);
1133
+ lines.push(xformXml);
1134
+ lines.push(`${" ".repeat(indent + 1)}<Children>`);
1135
+ for (const child of this.children) {
1136
+ lines.push(child.toXml(indent + 2));
1137
+ }
1138
+ lines.push(`${" ".repeat(indent + 1)}</Children>`);
1139
+ lines.push(`${indentStr}</${tag}>`);
1140
+ return lines.join("\n");
1141
+ }
1107
1142
  };
1108
1143
  LightBurnBaseElement.register("Shape.Group", ShapeGroup);
1109
1144
 
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.15",
6
6
  "files": [
7
7
  "dist"
8
8
  ],