calculate-packing 0.0.9 → 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 +12 -1
  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
  }
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.9",
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",