calculate-packing 0.0.8 → 0.0.10

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/index.js +32 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -365,8 +365,19 @@ var PackSolver = class extends BaseSolver {
365
365
  this.packInput = input;
366
366
  }
367
367
  _setup() {
368
- const { components, packOrderStrategy } = this.packInput;
368
+ const { components, packOrderStrategy, packFirst = [] } = this.packInput;
369
+ const packFirstMap = /* @__PURE__ */ new Map();
370
+ packFirst.forEach((componentId, index) => {
371
+ packFirstMap.set(componentId, index);
372
+ });
369
373
  this.unpackedComponentQueue = [...components].sort((a, b) => {
374
+ const aPackFirstIndex = packFirstMap.get(a.componentId);
375
+ const bPackFirstIndex = packFirstMap.get(b.componentId);
376
+ if (aPackFirstIndex !== void 0 && bPackFirstIndex !== void 0) {
377
+ return aPackFirstIndex - bPackFirstIndex;
378
+ }
379
+ if (aPackFirstIndex !== void 0) return -1;
380
+ if (bPackFirstIndex !== void 0) return 1;
370
381
  if (packOrderStrategy === "largest_to_smallest") {
371
382
  return b.pads.length - a.pads.length;
372
383
  }
@@ -816,21 +827,34 @@ var extractPadInfos = (pcbComponent, db, getNetworkId) => {
816
827
  break;
817
828
  }
818
829
  case "circle": {
830
+ pushPad({
831
+ padId: sp.pcb_smtpad_id,
832
+ pcbPortId: sp.pcb_port_id,
833
+ sx: sp.radius ?? 0,
834
+ sy: sp.radius ?? 0,
835
+ x: sp.x,
836
+ y: sp.y
837
+ });
819
838
  break;
820
839
  }
821
840
  case "pill": {
841
+ pushPad({
842
+ padId: sp.pcb_smtpad_id,
843
+ pcbPortId: sp.pcb_port_id,
844
+ sx: sp.width ?? 0,
845
+ sy: sp.height ?? 0,
846
+ x: sp.x,
847
+ y: sp.y
848
+ });
822
849
  break;
823
850
  }
824
- case "polygon": {
825
- break;
826
- }
827
- case "rotated_rect": {
851
+ default: {
852
+ console.warn(
853
+ `smtpad shape ${sp.shape} pads are not supported in pack layout yet`
854
+ );
828
855
  break;
829
856
  }
830
857
  }
831
- console.warn(
832
- `smtpad shape ${sp.shape} pads are not supported in pack layout yet`
833
- );
834
858
  }
835
859
  return out;
836
860
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "calculate-packing",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.8",
5
+ "version": "0.0.10",
6
6
  "description": "Calculate a packing layout with support for different strategy configurations",
7
7
  "scripts": {
8
8
  "start": "cosmos",