@lucablockltd/ultimate-packaging 1.1.0 → 1.2.0
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/AGENTS_README.md +299 -30
- package/dist/index.js +239 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +239 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3755,6 +3755,64 @@ function generateBecf12109(attr) {
|
|
|
3755
3755
|
crease.push(line6(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
|
|
3756
3756
|
return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
|
|
3757
3757
|
}
|
|
3758
|
+
function generateOuterContour6(attr) {
|
|
3759
|
+
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3760
|
+
const D = calcD2(C, B);
|
|
3761
|
+
const kulak = glueArea ?? calcKulak2(B);
|
|
3762
|
+
const totalWidth = kulak + 2 * A + 2 * B - 2;
|
|
3763
|
+
const totalHeight = D + C + B / 2 + DIP2;
|
|
3764
|
+
return [
|
|
3765
|
+
{ x: 0, y: 0 },
|
|
3766
|
+
{ x: totalWidth, y: 0 },
|
|
3767
|
+
{ x: totalWidth, y: totalHeight },
|
|
3768
|
+
{ x: 0, y: totalHeight }
|
|
3769
|
+
];
|
|
3770
|
+
}
|
|
3771
|
+
function offsetContour6(points, distance) {
|
|
3772
|
+
const n = points.length;
|
|
3773
|
+
const result = [];
|
|
3774
|
+
for (let i = 0; i < n; i++) {
|
|
3775
|
+
const prev = points[(i - 1 + n) % n];
|
|
3776
|
+
const curr = points[i];
|
|
3777
|
+
const next = points[(i + 1) % n];
|
|
3778
|
+
const e1x = curr.x - prev.x;
|
|
3779
|
+
const e1y = curr.y - prev.y;
|
|
3780
|
+
const e2x = next.x - curr.x;
|
|
3781
|
+
const e2y = next.y - curr.y;
|
|
3782
|
+
const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
|
|
3783
|
+
const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
|
|
3784
|
+
if (len1 === 0 || len2 === 0) {
|
|
3785
|
+
result.push(curr);
|
|
3786
|
+
continue;
|
|
3787
|
+
}
|
|
3788
|
+
const n1x = e1y / len1;
|
|
3789
|
+
const n1y = -e1x / len1;
|
|
3790
|
+
const n2x = e2y / len2;
|
|
3791
|
+
const n2y = -e2x / len2;
|
|
3792
|
+
const ax = n1x + n2x;
|
|
3793
|
+
const ay = n1y + n2y;
|
|
3794
|
+
const aLen = Math.sqrt(ax * ax + ay * ay);
|
|
3795
|
+
if (aLen < 1e-3) {
|
|
3796
|
+
result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
|
|
3797
|
+
continue;
|
|
3798
|
+
}
|
|
3799
|
+
const nx = ax / aLen;
|
|
3800
|
+
const ny = ay / aLen;
|
|
3801
|
+
const dot = n1x * nx + n1y * ny;
|
|
3802
|
+
const d = distance / Math.max(dot, 0.1);
|
|
3803
|
+
result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
|
|
3804
|
+
}
|
|
3805
|
+
return result;
|
|
3806
|
+
}
|
|
3807
|
+
function contourToPath6(points) {
|
|
3808
|
+
if (points.length === 0) return "";
|
|
3809
|
+
let d = `M${points[0].x} ${points[0].y}`;
|
|
3810
|
+
for (let i = 1; i < points.length; i++) {
|
|
3811
|
+
d += ` L${points[i].x} ${points[i].y}`;
|
|
3812
|
+
}
|
|
3813
|
+
d += " Z";
|
|
3814
|
+
return d;
|
|
3815
|
+
}
|
|
3758
3816
|
function generateDimensions6(attr, unit) {
|
|
3759
3817
|
const { length: A, width: B, height: C, glueArea } = attr;
|
|
3760
3818
|
const D = calcD2(C, B);
|
|
@@ -5039,6 +5097,156 @@ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth,
|
|
|
5039
5097
|
};
|
|
5040
5098
|
}
|
|
5041
5099
|
|
|
5100
|
+
// src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
|
|
5101
|
+
function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
|
|
5102
|
+
const rotated = normalizePoints(contourPoints, deg);
|
|
5103
|
+
return {
|
|
5104
|
+
profile: buildProfile(rotated),
|
|
5105
|
+
bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
|
|
5106
|
+
deg
|
|
5107
|
+
};
|
|
5108
|
+
}
|
|
5109
|
+
function pairGrid4(rdA, rdB, bounds) {
|
|
5110
|
+
const pA = rdA.profile, pB = rdB.profile;
|
|
5111
|
+
const gapAB = findMinStepX(pA, pB, 0);
|
|
5112
|
+
if (gapAB <= 0) return emptyResult();
|
|
5113
|
+
const pairW = gapAB + pB.width;
|
|
5114
|
+
const pairH = Math.max(pA.height, pB.height);
|
|
5115
|
+
const pairStepX = gapAB + findMinStepX(pB, pA, 0);
|
|
5116
|
+
const pairStepY = Math.max(
|
|
5117
|
+
findMinStepY(pA, pA, 0),
|
|
5118
|
+
findMinStepY(pA, pB, gapAB),
|
|
5119
|
+
findMinStepY(pB, pA, -gapAB),
|
|
5120
|
+
findMinStepY(pB, pB, 0)
|
|
5121
|
+
);
|
|
5122
|
+
if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
|
|
5123
|
+
const usableW = bounds.right - bounds.left;
|
|
5124
|
+
const usableH = bounds.bottom - bounds.top;
|
|
5125
|
+
const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
|
|
5126
|
+
const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
|
|
5127
|
+
if (pairCols === 0 || pairRows === 0) return emptyResult();
|
|
5128
|
+
const placements = [];
|
|
5129
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
5130
|
+
for (let r = 0; r < pairRows; r++) {
|
|
5131
|
+
for (let c = 0; c < pairCols; c++) {
|
|
5132
|
+
const baseX = bounds.left + c * pairStepX;
|
|
5133
|
+
const baseY = bounds.top + r * pairStepY;
|
|
5134
|
+
const oxA = baseX;
|
|
5135
|
+
const oyA = baseY;
|
|
5136
|
+
placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
|
|
5137
|
+
if (oxA < minX) minX = oxA;
|
|
5138
|
+
if (oyA < minY) minY = oyA;
|
|
5139
|
+
if (oxA + pA.width > maxX) maxX = oxA + pA.width;
|
|
5140
|
+
if (oyA + pA.height > maxY) maxY = oyA + pA.height;
|
|
5141
|
+
const oxB = baseX + gapAB;
|
|
5142
|
+
const oyB = baseY;
|
|
5143
|
+
placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
|
|
5144
|
+
if (oxB < minX) minX = oxB;
|
|
5145
|
+
if (oyB < minY) minY = oyB;
|
|
5146
|
+
if (oxB + pB.width > maxX) maxX = oxB + pB.width;
|
|
5147
|
+
if (oyB + pB.height > maxY) maxY = oyB + pB.height;
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
|
|
5151
|
+
const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
|
|
5152
|
+
const gapRight = bounds.right - pairsRightEdge;
|
|
5153
|
+
const gapBottom = bounds.bottom - pairsBottomEdge;
|
|
5154
|
+
const extraRotations = [rdA, rdB];
|
|
5155
|
+
for (const rdExtra of extraRotations) {
|
|
5156
|
+
const pe = rdExtra.profile;
|
|
5157
|
+
if (pe.width <= gapRight) {
|
|
5158
|
+
for (let r = 0; r < pairRows; r++) {
|
|
5159
|
+
const ox = pairsRightEdge;
|
|
5160
|
+
const oy = bounds.top + r * pairStepY;
|
|
5161
|
+
if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5162
|
+
placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5163
|
+
if (ox + pe.width > maxX) maxX = ox + pe.width;
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
break;
|
|
5167
|
+
}
|
|
5168
|
+
}
|
|
5169
|
+
for (const rdExtra of extraRotations) {
|
|
5170
|
+
const pe = rdExtra.profile;
|
|
5171
|
+
if (pe.height <= gapBottom) {
|
|
5172
|
+
for (let c = 0; c < pairCols; c++) {
|
|
5173
|
+
const oxA = bounds.left + c * pairStepX;
|
|
5174
|
+
const oy = pairsBottomEdge;
|
|
5175
|
+
if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
|
|
5176
|
+
placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
|
|
5177
|
+
if (oy + pe.height > maxY) maxY = oy + pe.height;
|
|
5178
|
+
}
|
|
5179
|
+
}
|
|
5180
|
+
break;
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
return { placements, count: placements.length, minX, minY, maxX, maxY };
|
|
5184
|
+
}
|
|
5185
|
+
function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
|
|
5186
|
+
const rots = [0, 90, 180, 270];
|
|
5187
|
+
const rd = /* @__PURE__ */ new Map();
|
|
5188
|
+
for (const deg of rots) {
|
|
5189
|
+
rd.set(deg, prepareRotation5(contourPoints, dielineW, dielineH, deg));
|
|
5190
|
+
}
|
|
5191
|
+
const results = [];
|
|
5192
|
+
for (const deg of rots) {
|
|
5193
|
+
results.push(singleRotGrid(rd.get(deg), bounds));
|
|
5194
|
+
}
|
|
5195
|
+
const allPairs = [
|
|
5196
|
+
[0, 180],
|
|
5197
|
+
[90, 270],
|
|
5198
|
+
[0, 90],
|
|
5199
|
+
[0, 270],
|
|
5200
|
+
[90, 180],
|
|
5201
|
+
[180, 270]
|
|
5202
|
+
];
|
|
5203
|
+
for (const [a, b] of allPairs) {
|
|
5204
|
+
const rdA = rd.get(a), rdB = rd.get(b);
|
|
5205
|
+
const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
|
|
5206
|
+
if (stepA <= 0) continue;
|
|
5207
|
+
for (let off = 0; off < stepA; off += 1) {
|
|
5208
|
+
results.push(dualRotGrid(rdA, rdB, off, bounds));
|
|
5209
|
+
results.push(dualRotGrid(rdB, rdA, off, bounds));
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
for (const [a, b] of allPairs) {
|
|
5213
|
+
results.push(pairGrid4(rd.get(a), rd.get(b), bounds));
|
|
5214
|
+
results.push(pairGrid4(rd.get(b), rd.get(a), bounds));
|
|
5215
|
+
}
|
|
5216
|
+
const singleResults = [];
|
|
5217
|
+
const multiResults = [];
|
|
5218
|
+
for (const r of results) {
|
|
5219
|
+
if (r.count === 0) continue;
|
|
5220
|
+
const rotations = new Set(r.placements.map((p) => p.rotation));
|
|
5221
|
+
if (rotations.size > 1) {
|
|
5222
|
+
multiResults.push(r);
|
|
5223
|
+
} else {
|
|
5224
|
+
singleResults.push(r);
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
function pickBest(arr) {
|
|
5228
|
+
let b = arr[0] ?? emptyResult();
|
|
5229
|
+
let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
|
|
5230
|
+
for (const r of arr) {
|
|
5231
|
+
const area = (r.maxX - r.minX) * (r.maxY - r.minY);
|
|
5232
|
+
if (r.count > b.count || r.count === b.count && area < bArea) {
|
|
5233
|
+
b = r;
|
|
5234
|
+
bArea = area;
|
|
5235
|
+
}
|
|
5236
|
+
}
|
|
5237
|
+
return b;
|
|
5238
|
+
}
|
|
5239
|
+
const bestSingle = pickBest(singleResults);
|
|
5240
|
+
const bestMulti = pickBest(multiResults);
|
|
5241
|
+
const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
|
|
5242
|
+
centerLayout(best, bounds);
|
|
5243
|
+
return {
|
|
5244
|
+
rotation: best.placements[0]?.rotation ?? 0,
|
|
5245
|
+
placements: best.placements,
|
|
5246
|
+
producedPerSheet: best.count
|
|
5247
|
+
};
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5042
5250
|
// src/utils/autoLayout/calculate/index.ts
|
|
5043
5251
|
function resolveModelFunctions(modelId, attrs) {
|
|
5044
5252
|
switch (modelId) {
|
|
@@ -5074,6 +5282,14 @@ function resolveModelFunctions(modelId, attrs) {
|
|
|
5074
5282
|
offsetContour: offsetContour5
|
|
5075
5283
|
};
|
|
5076
5284
|
}
|
|
5285
|
+
case "BECF-12109": {
|
|
5286
|
+
const a = attrs;
|
|
5287
|
+
return {
|
|
5288
|
+
contour: generateOuterContour6(a),
|
|
5289
|
+
dieline: generateBecf12109(a),
|
|
5290
|
+
offsetContour: offsetContour6
|
|
5291
|
+
};
|
|
5292
|
+
}
|
|
5077
5293
|
case "BECF-1010A":
|
|
5078
5294
|
default: {
|
|
5079
5295
|
const a = attrs;
|
|
@@ -5095,6 +5311,8 @@ function resolveLayoutCalculator(modelId) {
|
|
|
5095
5311
|
return computeLayoutForPaper3;
|
|
5096
5312
|
case "BECF-12101":
|
|
5097
5313
|
return computeLayoutForPaper4;
|
|
5314
|
+
case "BECF-12109":
|
|
5315
|
+
return computeLayoutForPaper5;
|
|
5098
5316
|
default:
|
|
5099
5317
|
return computeLayoutForPaperDefault;
|
|
5100
5318
|
}
|
|
@@ -5108,11 +5326,11 @@ function calculateAutoLayout(rawConfig) {
|
|
|
5108
5326
|
colorbarHeight: rawConfig.colorbarHeight ?? 5,
|
|
5109
5327
|
isShowColorbar: rawConfig.isShowColorbar ?? true
|
|
5110
5328
|
};
|
|
5111
|
-
const { contour, dieline, offsetContour:
|
|
5329
|
+
const { contour, dieline, offsetContour: offsetContour7 } = resolveModelFunctions(
|
|
5112
5330
|
config.model.modelId,
|
|
5113
5331
|
config.model.attributes
|
|
5114
5332
|
);
|
|
5115
|
-
const offsetContourPoints = config.layoutDistance > 0 ?
|
|
5333
|
+
const offsetContourPoints = config.layoutDistance > 0 ? offsetContour7(contour, config.layoutDistance / 2) : contour;
|
|
5116
5334
|
const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
|
|
5117
5335
|
const computeLayout = resolveLayoutCalculator(config.model.modelId);
|
|
5118
5336
|
const paperResults = [];
|
|
@@ -6052,6 +6270,17 @@ function resolveModel(modelId, attrs, layoutDistance) {
|
|
|
6052
6270
|
generateContour: (a) => generateOuterContour5(a)
|
|
6053
6271
|
};
|
|
6054
6272
|
}
|
|
6273
|
+
case "BECF-12109": {
|
|
6274
|
+
const typedAttrs = attrs;
|
|
6275
|
+
const contour = generateOuterContour6(typedAttrs);
|
|
6276
|
+
return {
|
|
6277
|
+
dieline: generateBecf12109(typedAttrs),
|
|
6278
|
+
contourPath: contourToPath6(contour),
|
|
6279
|
+
offsetContourPoints: layoutDistance > 0 ? offsetContour6(contour, layoutDistance / 2) : contour,
|
|
6280
|
+
generate: (a) => generateBecf12109(a),
|
|
6281
|
+
generateContour: (a) => generateOuterContour6(a)
|
|
6282
|
+
};
|
|
6283
|
+
}
|
|
6055
6284
|
case "BECF-1010A":
|
|
6056
6285
|
default: {
|
|
6057
6286
|
const typedAttrs = attrs;
|
|
@@ -6101,6 +6330,14 @@ function renderDieLine2(modelId, attrs) {
|
|
|
6101
6330
|
renderAs: "group"
|
|
6102
6331
|
}
|
|
6103
6332
|
);
|
|
6333
|
+
case "BECF-12109":
|
|
6334
|
+
return /* @__PURE__ */ jsx(
|
|
6335
|
+
DIE_LINE_BECF_12109,
|
|
6336
|
+
{
|
|
6337
|
+
attributes: attrs,
|
|
6338
|
+
renderAs: "group"
|
|
6339
|
+
}
|
|
6340
|
+
);
|
|
6104
6341
|
case "BECF-1010A":
|
|
6105
6342
|
default:
|
|
6106
6343
|
return /* @__PURE__ */ jsx(
|