@ricsam/formula-engine 0.0.12 → 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/cjs/core/autofill-utils.cjs +95 -3
- package/dist/cjs/core/autofill-utils.cjs.map +3 -3
- package/dist/cjs/core/engine.cjs +76 -5
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/copy-manager.cjs +291 -10
- package/dist/cjs/core/managers/copy-manager.cjs.map +3 -3
- package/dist/cjs/core/types.cjs.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/core/autofill-utils.mjs +95 -3
- package/dist/mjs/core/autofill-utils.mjs.map +3 -3
- package/dist/mjs/core/engine.mjs +76 -5
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/copy-manager.mjs +292 -11
- package/dist/mjs/core/managers/copy-manager.mjs.map +3 -3
- package/dist/mjs/core/types.mjs.map +1 -1
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/autofill-utils.d.ts +12 -2
- package/dist/types/core/engine.d.ts +72 -5
- package/dist/types/core/managers/copy-manager.d.ts +39 -2
- package/dist/types/core/types.d.ts +13 -1
- package/package.json +1 -1
|
@@ -53,16 +53,18 @@ class CopyManager {
|
|
|
53
53
|
const topLeft = this.findTopLeft(source);
|
|
54
54
|
const rowOffset = target.rowIndex - topLeft.rowIndex;
|
|
55
55
|
const colOffset = target.colIndex - topLeft.colIndex;
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
if (options.target !== "style") {
|
|
57
|
+
for (const sourceCell of source) {
|
|
58
|
+
const targetCell = {
|
|
59
|
+
workbookName: target.workbookName,
|
|
60
|
+
sheetName: target.sheetName,
|
|
61
|
+
colIndex: sourceCell.colIndex + colOffset,
|
|
62
|
+
rowIndex: sourceCell.rowIndex + rowOffset
|
|
63
|
+
};
|
|
64
|
+
this.copyCellContent(sourceCell, targetCell, topLeft, options);
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
|
-
if (options.
|
|
67
|
+
if (options.target === "all" || options.target === "style") {
|
|
66
68
|
this.copyFormatting(source, topLeft, target, rowOffset, colOffset);
|
|
67
69
|
}
|
|
68
70
|
if (options.cut) {
|
|
@@ -259,6 +261,285 @@ class CopyManager {
|
|
|
259
261
|
}
|
|
260
262
|
}
|
|
261
263
|
}
|
|
264
|
+
fillAreas(seedRange, targetRanges, options) {
|
|
265
|
+
for (const targetRange of targetRanges) {
|
|
266
|
+
this.fillRangeWithSeed(seedRange, targetRange, {
|
|
267
|
+
copyContent: options.target !== "style",
|
|
268
|
+
copyStyles: options.target === "all" || options.target === "style",
|
|
269
|
+
contentType: options.type,
|
|
270
|
+
adjustFormulas: true
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (options.cut) {
|
|
274
|
+
const seedCells = this.expandRangeToCells(seedRange);
|
|
275
|
+
this.clearSourceCells(seedCells);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
fillRangeWithSeed(seedRange, targetRange, options) {
|
|
279
|
+
const seedCells = this.expandRangeToCells(seedRange);
|
|
280
|
+
const seedWidth = this.getRangeWidth(seedRange);
|
|
281
|
+
const seedHeight = this.getRangeHeight(seedRange);
|
|
282
|
+
const targetWidth = this.getRangeWidth(targetRange);
|
|
283
|
+
const targetHeight = this.getRangeHeight(targetRange);
|
|
284
|
+
const filledColumns = new Map;
|
|
285
|
+
for (let col = 0;col < seedWidth; col++) {
|
|
286
|
+
for (let row = 0;row < targetHeight; row++) {
|
|
287
|
+
const seedRow = row % seedHeight;
|
|
288
|
+
const seedCell = seedCells.find((c) => c.colIndex === seedRange.range.start.col + col && c.rowIndex === seedRange.range.start.row + seedRow);
|
|
289
|
+
if (seedCell) {
|
|
290
|
+
const targetCell = {
|
|
291
|
+
workbookName: targetRange.workbookName,
|
|
292
|
+
sheetName: targetRange.sheetName,
|
|
293
|
+
colIndex: targetRange.range.start.col + col,
|
|
294
|
+
rowIndex: targetRange.range.start.row + row
|
|
295
|
+
};
|
|
296
|
+
const rowDelta = targetCell.rowIndex - seedCell.rowIndex;
|
|
297
|
+
const colDelta = targetCell.colIndex - seedCell.colIndex;
|
|
298
|
+
if (options.copyContent) {
|
|
299
|
+
this.copyCellContentWithOffset(seedCell, targetCell, rowDelta, colDelta, {
|
|
300
|
+
type: options.contentType,
|
|
301
|
+
cut: false,
|
|
302
|
+
target: "content"
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (options.copyStyles) {
|
|
306
|
+
this.copyCellFormatting(seedCell, targetCell);
|
|
307
|
+
}
|
|
308
|
+
const key = `${targetCell.colIndex}-${targetCell.rowIndex}`;
|
|
309
|
+
const sheet = this.workbookManager.getSheet({
|
|
310
|
+
workbookName: targetCell.workbookName,
|
|
311
|
+
sheetName: targetCell.sheetName
|
|
312
|
+
});
|
|
313
|
+
const cellKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;
|
|
314
|
+
const content = sheet?.content.get(cellKey) || "";
|
|
315
|
+
filledColumns.set(key, { cell: targetCell, content });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (targetWidth > seedWidth) {
|
|
320
|
+
for (let col = seedWidth;col < targetWidth; col++) {
|
|
321
|
+
const sourceCol = col % seedWidth;
|
|
322
|
+
for (let row = 0;row < targetHeight; row++) {
|
|
323
|
+
const sourceCell = {
|
|
324
|
+
workbookName: targetRange.workbookName,
|
|
325
|
+
sheetName: targetRange.sheetName,
|
|
326
|
+
colIndex: targetRange.range.start.col + sourceCol,
|
|
327
|
+
rowIndex: targetRange.range.start.row + row
|
|
328
|
+
};
|
|
329
|
+
const targetCell = {
|
|
330
|
+
workbookName: targetRange.workbookName,
|
|
331
|
+
sheetName: targetRange.sheetName,
|
|
332
|
+
colIndex: targetRange.range.start.col + col,
|
|
333
|
+
rowIndex: targetRange.range.start.row + row
|
|
334
|
+
};
|
|
335
|
+
const colDelta = targetCell.colIndex - sourceCell.colIndex;
|
|
336
|
+
if (options.copyContent) {
|
|
337
|
+
this.copyCellContentWithOffset(sourceCell, targetCell, 0, colDelta, {
|
|
338
|
+
type: options.contentType,
|
|
339
|
+
cut: false,
|
|
340
|
+
target: "content"
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (options.copyStyles) {
|
|
344
|
+
this.copyCellFormatting(sourceCell, targetCell);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
getRangeWidth(range) {
|
|
351
|
+
if (range.range.end.col.type === "infinity") {
|
|
352
|
+
return 100;
|
|
353
|
+
}
|
|
354
|
+
return range.range.end.col.value - range.range.start.col + 1;
|
|
355
|
+
}
|
|
356
|
+
getRangeHeight(range) {
|
|
357
|
+
if (range.range.end.row.type === "infinity") {
|
|
358
|
+
return 100;
|
|
359
|
+
}
|
|
360
|
+
return range.range.end.row.value - range.range.start.row + 1;
|
|
361
|
+
}
|
|
362
|
+
expandRangeToCells(rangeAddress) {
|
|
363
|
+
const { workbookName, sheetName, range } = rangeAddress;
|
|
364
|
+
const cells = [];
|
|
365
|
+
const startCol = range.start.col;
|
|
366
|
+
const startRow = range.start.row;
|
|
367
|
+
let endCol;
|
|
368
|
+
if (range.end.col.type === "infinity") {
|
|
369
|
+
endCol = startCol + 99;
|
|
370
|
+
} else {
|
|
371
|
+
endCol = range.end.col.value;
|
|
372
|
+
}
|
|
373
|
+
let endRow;
|
|
374
|
+
if (range.end.row.type === "infinity") {
|
|
375
|
+
endRow = startRow + 99;
|
|
376
|
+
} else {
|
|
377
|
+
endRow = range.end.row.value;
|
|
378
|
+
}
|
|
379
|
+
for (let row = startRow;row <= endRow; row++) {
|
|
380
|
+
for (let col = startCol;col <= endCol; col++) {
|
|
381
|
+
cells.push({
|
|
382
|
+
workbookName,
|
|
383
|
+
sheetName,
|
|
384
|
+
colIndex: col,
|
|
385
|
+
rowIndex: row
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return cells;
|
|
390
|
+
}
|
|
391
|
+
copyCellContentWithOffset(sourceCell, targetCell, rowDelta, colDelta, options) {
|
|
392
|
+
const sheet = this.workbookManager.getSheet({
|
|
393
|
+
workbookName: sourceCell.workbookName,
|
|
394
|
+
sheetName: sourceCell.sheetName
|
|
395
|
+
});
|
|
396
|
+
if (!sheet) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${sourceCell.rowIndex + 1}`;
|
|
400
|
+
const cellContent = sheet.content.get(key);
|
|
401
|
+
if (!cellContent) {
|
|
402
|
+
const targetSheet2 = this.workbookManager.getSheet({
|
|
403
|
+
workbookName: targetCell.workbookName,
|
|
404
|
+
sheetName: targetCell.sheetName
|
|
405
|
+
});
|
|
406
|
+
if (targetSheet2) {
|
|
407
|
+
const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;
|
|
408
|
+
targetSheet2.content.delete(targetKey);
|
|
409
|
+
}
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
let targetContent;
|
|
413
|
+
if (options.type === "value") {
|
|
414
|
+
const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);
|
|
415
|
+
if (!evalResult || evalResult.type !== "value") {
|
|
416
|
+
targetContent = cellContent;
|
|
417
|
+
} else {
|
|
418
|
+
const result = evalResult.result;
|
|
419
|
+
if (result.type === "number") {
|
|
420
|
+
targetContent = result.value;
|
|
421
|
+
} else if (result.type === "string") {
|
|
422
|
+
targetContent = result.value;
|
|
423
|
+
} else if (result.type === "boolean") {
|
|
424
|
+
targetContent = result.value;
|
|
425
|
+
} else {
|
|
426
|
+
targetContent = cellContent;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
if (typeof cellContent === "string" && cellContent.startsWith("=")) {
|
|
431
|
+
targetContent = this.adjustFormulaWithOffset(cellContent, rowDelta, colDelta);
|
|
432
|
+
} else {
|
|
433
|
+
targetContent = cellContent;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const targetSheet = this.workbookManager.getSheet({
|
|
437
|
+
workbookName: targetCell.workbookName,
|
|
438
|
+
sheetName: targetCell.sheetName
|
|
439
|
+
});
|
|
440
|
+
if (targetSheet) {
|
|
441
|
+
const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;
|
|
442
|
+
targetSheet.content.set(targetKey, targetContent);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
adjustFormulaWithOffset(formula, rowDelta, colDelta) {
|
|
446
|
+
try {
|
|
447
|
+
const ast = import_parser.parseFormula(formula.slice(1));
|
|
448
|
+
const adjustedAst = import_ast_traverser.transformAST(ast, (node) => {
|
|
449
|
+
if (node.type === "reference") {
|
|
450
|
+
const refNode = node;
|
|
451
|
+
return {
|
|
452
|
+
...refNode,
|
|
453
|
+
address: {
|
|
454
|
+
colIndex: refNode.isAbsolute.col ? refNode.address.colIndex : refNode.address.colIndex + colDelta,
|
|
455
|
+
rowIndex: refNode.isAbsolute.row ? refNode.address.rowIndex : refNode.address.rowIndex + rowDelta
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
} else if (node.type === "range") {
|
|
459
|
+
const rangeNode = node;
|
|
460
|
+
return {
|
|
461
|
+
...rangeNode,
|
|
462
|
+
range: {
|
|
463
|
+
start: {
|
|
464
|
+
col: rangeNode.isAbsolute.start.col ? rangeNode.range.start.col : rangeNode.range.start.col + colDelta,
|
|
465
|
+
row: rangeNode.isAbsolute.start.row ? rangeNode.range.start.row : rangeNode.range.start.row + rowDelta
|
|
466
|
+
},
|
|
467
|
+
end: {
|
|
468
|
+
col: rangeNode.range.end.col.type === "number" ? rangeNode.isAbsolute.end.col ? rangeNode.range.end.col : {
|
|
469
|
+
type: "number",
|
|
470
|
+
value: rangeNode.range.end.col.value + colDelta
|
|
471
|
+
} : rangeNode.range.end.col,
|
|
472
|
+
row: rangeNode.range.end.row.type === "number" ? rangeNode.isAbsolute.end.row ? rangeNode.range.end.row : {
|
|
473
|
+
type: "number",
|
|
474
|
+
value: rangeNode.range.end.row.value + rowDelta
|
|
475
|
+
} : rangeNode.range.end.row
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
return node;
|
|
481
|
+
});
|
|
482
|
+
return `=${import_formatter.astToString(adjustedAst)}`;
|
|
483
|
+
} catch (error) {
|
|
484
|
+
console.warn("Failed to adjust formula with offset:", error);
|
|
485
|
+
return formula;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
copyCellFormatting(sourceCell, targetCell) {
|
|
489
|
+
const allConditionalStyles = this.styleManager.getAllConditionalStyles();
|
|
490
|
+
const allCellStyles = this.styleManager.getAllCellStyles();
|
|
491
|
+
const sourceCellRange = {
|
|
492
|
+
start: { col: sourceCell.colIndex, row: sourceCell.rowIndex },
|
|
493
|
+
end: {
|
|
494
|
+
col: { type: "number", value: sourceCell.colIndex },
|
|
495
|
+
row: { type: "number", value: sourceCell.rowIndex }
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
for (const style of allConditionalStyles) {
|
|
499
|
+
if (style.area.workbookName === sourceCell.workbookName && style.area.sheetName === sourceCell.sheetName) {
|
|
500
|
+
const intersection = import_range_utils.intersectRanges(style.area.range, sourceCellRange);
|
|
501
|
+
if (intersection) {
|
|
502
|
+
const newStyle = {
|
|
503
|
+
area: {
|
|
504
|
+
workbookName: targetCell.workbookName,
|
|
505
|
+
sheetName: targetCell.sheetName,
|
|
506
|
+
range: {
|
|
507
|
+
start: { col: targetCell.colIndex, row: targetCell.rowIndex },
|
|
508
|
+
end: {
|
|
509
|
+
col: { type: "number", value: targetCell.colIndex },
|
|
510
|
+
row: { type: "number", value: targetCell.rowIndex }
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
condition: style.condition
|
|
515
|
+
};
|
|
516
|
+
this.styleManager.addConditionalStyle(newStyle);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
for (const style of allCellStyles) {
|
|
521
|
+
if (style.area.workbookName === sourceCell.workbookName && style.area.sheetName === sourceCell.sheetName) {
|
|
522
|
+
const intersection = import_range_utils.intersectRanges(style.area.range, sourceCellRange);
|
|
523
|
+
if (intersection) {
|
|
524
|
+
const newStyle = {
|
|
525
|
+
area: {
|
|
526
|
+
workbookName: targetCell.workbookName,
|
|
527
|
+
sheetName: targetCell.sheetName,
|
|
528
|
+
range: {
|
|
529
|
+
start: { col: targetCell.colIndex, row: targetCell.rowIndex },
|
|
530
|
+
end: {
|
|
531
|
+
col: { type: "number", value: targetCell.colIndex },
|
|
532
|
+
row: { type: "number", value: targetCell.rowIndex }
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
style: style.style
|
|
537
|
+
};
|
|
538
|
+
this.styleManager.addCellStyle(newStyle);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
262
543
|
}
|
|
263
544
|
|
|
264
|
-
//# debugId=
|
|
545
|
+
//# debugId=DAB7BAA575141E6064756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/copy-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * CopyManager - Manages cell copy/paste operations\n */\n\nimport type {\n CellAddress,\n CopyCellsOptions,\n ConditionalStyle,\n DirectCellStyle,\n LocalCellAddress,\n SerializedCellValue,\n SpreadsheetRange,\n} from \"../types.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport type { EvaluationManager } from \"./evaluation-manager.cjs\";\nimport type { StyleManager } from \"./style-manager.cjs\";\nimport { parseFormula } from \"../../parser/parser.cjs\";\nimport { astToString } from \"../../parser/formatter.cjs\";\nimport { transformAST } from \"../ast-traverser.cjs\";\nimport type { ReferenceNode, RangeNode } from \"../../parser/ast.cjs\";\nimport { isCellInRange } from \"../utils.cjs\";\nimport { intersectRanges } from \"../utils/range-utils.cjs\";\n\nexport class CopyManager {\n constructor(\n private workbookManager: WorkbookManager,\n private evaluationManager: EvaluationManager,\n private styleManager: StyleManager\n ) {}\n\n /**\n * Copy cells from source to target\n */\n copyCells(\n source: CellAddress[],\n target: CellAddress,\n options: CopyCellsOptions\n ): void {\n if (source.length === 0) {\n return;\n }\n\n // Find top-left cell of source (minimum row/col indices)\n const topLeft = this.findTopLeft(source);\n\n // Calculate offset from source top-left to target\n const rowOffset = target.rowIndex - topLeft.rowIndex;\n const colOffset = target.colIndex - topLeft.colIndex;\n\n // Copy cell contents\n for (const sourceCell of source) {\n const targetCell: CellAddress = {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n colIndex: sourceCell.colIndex + colOffset,\n rowIndex: sourceCell.rowIndex + rowOffset,\n };\n\n this.copyCellContent(sourceCell, targetCell, topLeft, options);\n }\n\n // Copy formatting if requested\n if (options.formatting) {\n this.copyFormatting(source, topLeft, target, rowOffset, colOffset);\n }\n\n // Clear source cells if cut\n if (options.cut) {\n this.clearSourceCells(source);\n }\n }\n\n /**\n * Find the top-left cell (minimum row/col indices)\n */\n private findTopLeft(cells: CellAddress[]): CellAddress {\n let minRow = Infinity;\n let minCol = Infinity;\n let topLeftCell = cells[0]!;\n\n for (const cell of cells) {\n if (\n cell.rowIndex < minRow ||\n (cell.rowIndex === minRow && cell.colIndex < minCol)\n ) {\n minRow = cell.rowIndex;\n minCol = cell.colIndex;\n topLeftCell = cell;\n }\n }\n\n return topLeftCell;\n }\n\n /**\n * Copy content from one cell to another\n */\n private copyCellContent(\n sourceCell: CellAddress,\n targetCell: CellAddress,\n sourceTopLeft: CellAddress,\n options: CopyCellsOptions\n ): void {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (!sheet) {\n return;\n }\n\n const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${\n sourceCell.rowIndex + 1\n }`;\n const cellContent = sheet.content.get(key);\n\n if (!cellContent) {\n // Source cell is empty\n return;\n }\n\n let targetContent: SerializedCellValue;\n\n if (options.type === \"value\") {\n // Copy evaluated value\n const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);\n \n if (!evalResult || evalResult.type !== \"value\") {\n // If evaluation failed or is not a value, copy as-is\n targetContent = cellContent;\n } else {\n // Convert to literal value\n const result = evalResult.result;\n if (result.type === \"number\") {\n targetContent = result.value;\n } else if (result.type === \"string\") {\n targetContent = result.value;\n } else if (result.type === \"boolean\") {\n targetContent = result.value;\n } else {\n // Error or other type, copy as-is\n targetContent = cellContent;\n }\n }\n } else {\n // Copy formula\n if (typeof cellContent === \"string\" && cellContent.startsWith(\"=\")) {\n // Adjust formula references\n targetContent = this.adjustFormulaReferences(\n cellContent,\n {\n colIndex: sourceCell.colIndex,\n rowIndex: sourceCell.rowIndex,\n },\n {\n colIndex: targetCell.colIndex,\n rowIndex: targetCell.rowIndex,\n }\n );\n } else {\n // Not a formula, copy as-is\n targetContent = cellContent;\n }\n }\n\n // Set target cell content (using the engine's method through workbook manager)\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.set(targetKey, targetContent);\n }\n }\n\n /**\n * Adjust formula references when copying\n * Based on autofill-utils.ts adjustFormulaReferences\n */\n private adjustFormulaReferences(\n formula: string,\n sourceAddress: LocalCellAddress,\n targetAddress: LocalCellAddress\n ): string {\n try {\n const ast = parseFormula(formula.slice(1)); // Remove the \"=\" sign\n\n const rowDelta = targetAddress.rowIndex - sourceAddress.rowIndex;\n const colDelta = targetAddress.colIndex - sourceAddress.colIndex;\n\n const adjustedAst = transformAST(ast, (node) => {\n if (node.type === \"reference\") {\n const refNode = node as ReferenceNode;\n return {\n ...refNode,\n address: {\n colIndex: refNode.isAbsolute.col\n ? refNode.address.colIndex\n : refNode.address.colIndex + colDelta,\n rowIndex: refNode.isAbsolute.row\n ? refNode.address.rowIndex\n : refNode.address.rowIndex + rowDelta,\n },\n };\n } else if (node.type === \"range\") {\n const rangeNode = node as RangeNode;\n return {\n ...rangeNode,\n range: {\n start: {\n col: rangeNode.isAbsolute.start.col\n ? rangeNode.range.start.col\n : rangeNode.range.start.col + colDelta,\n row: rangeNode.isAbsolute.start.row\n ? rangeNode.range.start.row\n : rangeNode.range.start.row + rowDelta,\n },\n end: {\n col:\n rangeNode.range.end.col.type === \"number\"\n ? rangeNode.isAbsolute.end.col\n ? rangeNode.range.end.col\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.col.value + colDelta,\n }\n : rangeNode.range.end.col,\n row:\n rangeNode.range.end.row.type === \"number\"\n ? rangeNode.isAbsolute.end.row\n ? rangeNode.range.end.row\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.row.value + rowDelta,\n }\n : rangeNode.range.end.row,\n },\n },\n };\n }\n return node;\n });\n\n return `=${astToString(adjustedAst)}`;\n } catch (error) {\n // If parsing fails, return the original formula\n console.warn(\"Failed to adjust formula references:\", error);\n return formula;\n }\n }\n\n /**\n * Copy formatting (cellStyles and conditionalStyles) from source to target\n */\n private copyFormatting(\n sourceCells: CellAddress[],\n sourceTopLeft: CellAddress,\n target: CellAddress,\n rowOffset: number,\n colOffset: number\n ): void {\n // Get all styles for the source workbook\n const allConditionalStyles = this.styleManager.getAllConditionalStyles();\n const allCellStyles = this.styleManager.getAllCellStyles();\n\n // Find styles that intersect with source cells\n const sourceRange = this.getBoundingBox(sourceCells);\n\n // Copy conditional styles\n for (const style of allConditionalStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: ConditionalStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n condition: style.condition,\n };\n this.styleManager.addConditionalStyle(newStyle);\n }\n }\n }\n\n // Copy cell styles\n for (const style of allCellStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: DirectCellStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n style: style.style,\n };\n this.styleManager.addCellStyle(newStyle);\n }\n }\n }\n }\n\n /**\n * Get bounding box for a set of cells\n */\n private getBoundingBox(cells: CellAddress[]): SpreadsheetRange {\n let minRow = Infinity;\n let maxRow = -Infinity;\n let minCol = Infinity;\n let maxCol = -Infinity;\n\n for (const cell of cells) {\n minRow = Math.min(minRow, cell.rowIndex);\n maxRow = Math.max(maxRow, cell.rowIndex);\n minCol = Math.min(minCol, cell.colIndex);\n maxCol = Math.max(maxCol, cell.colIndex);\n }\n\n return {\n start: { col: minCol, row: minRow },\n end: {\n col: { type: \"number\", value: maxCol },\n row: { type: \"number\", value: maxRow },\n },\n };\n }\n\n\n /**\n * Adjust a range by row and column offsets\n */\n private adjustRange(\n range: SpreadsheetRange,\n rowOffset: number,\n colOffset: number\n ): SpreadsheetRange {\n return {\n start: {\n col: range.start.col + colOffset,\n row: range.start.row + rowOffset,\n },\n end: {\n col:\n range.end.col.type === \"number\"\n ? { type: \"number\", value: range.end.col.value + colOffset }\n : range.end.col,\n row:\n range.end.row.type === \"number\"\n ? { type: \"number\", value: range.end.row.value + rowOffset }\n : range.end.row,\n },\n };\n }\n\n /**\n * Clear source cells (for cut operation)\n */\n private clearSourceCells(cells: CellAddress[]): void {\n for (const cell of cells) {\n const sheet = this.workbookManager.getSheet({\n workbookName: cell.workbookName,\n sheetName: cell.sheetName,\n });\n\n if (sheet) {\n const key = `${String.fromCharCode(65 + cell.colIndex)}${\n cell.rowIndex + 1\n }`;\n sheet.content.delete(key);\n }\n }\n }\n}\n\n"
|
|
5
|
+
"/**\n * CopyManager - Manages cell copy/paste operations\n */\n\nimport type {\n CellAddress,\n CopyCellsOptions,\n ConditionalStyle,\n DirectCellStyle,\n LocalCellAddress,\n RangeAddress,\n SerializedCellValue,\n SpreadsheetRange,\n} from \"../types.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport type { EvaluationManager } from \"./evaluation-manager.cjs\";\nimport type { StyleManager } from \"./style-manager.cjs\";\nimport { parseFormula } from \"../../parser/parser.cjs\";\nimport { astToString } from \"../../parser/formatter.cjs\";\nimport { transformAST } from \"../ast-traverser.cjs\";\nimport type { ReferenceNode, RangeNode } from \"../../parser/ast.cjs\";\nimport { isCellInRange } from \"../utils.cjs\";\nimport { intersectRanges } from \"../utils/range-utils.cjs\";\n\nexport class CopyManager {\n constructor(\n private workbookManager: WorkbookManager,\n private evaluationManager: EvaluationManager,\n private styleManager: StyleManager\n ) {}\n\n /**\n * Paste cells from source to target\n */\n copyCells(\n source: CellAddress[],\n target: CellAddress,\n options: CopyCellsOptions\n ): void {\n if (source.length === 0) {\n return;\n }\n\n // Find top-left cell of source (minimum row/col indices)\n const topLeft = this.findTopLeft(source);\n\n // Calculate offset from source top-left to target\n const rowOffset = target.rowIndex - topLeft.rowIndex;\n const colOffset = target.colIndex - topLeft.colIndex;\n\n // Copy cell contents (skip if only copying style)\n if (options.target !== 'style') {\n for (const sourceCell of source) {\n const targetCell: CellAddress = {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n colIndex: sourceCell.colIndex + colOffset,\n rowIndex: sourceCell.rowIndex + rowOffset,\n };\n\n this.copyCellContent(sourceCell, targetCell, topLeft, options);\n }\n }\n\n // Copy formatting if requested\n if (options.target === 'all' || options.target === 'style') {\n this.copyFormatting(source, topLeft, target, rowOffset, colOffset);\n }\n\n // Clear source cells if cut\n if (options.cut) {\n this.clearSourceCells(source);\n }\n }\n\n /**\n * Find the top-left cell (minimum row/col indices)\n */\n private findTopLeft(cells: CellAddress[]): CellAddress {\n let minRow = Infinity;\n let minCol = Infinity;\n let topLeftCell = cells[0]!;\n\n for (const cell of cells) {\n if (\n cell.rowIndex < minRow ||\n (cell.rowIndex === minRow && cell.colIndex < minCol)\n ) {\n minRow = cell.rowIndex;\n minCol = cell.colIndex;\n topLeftCell = cell;\n }\n }\n\n return topLeftCell;\n }\n\n /**\n * Copy content from one cell to another\n */\n private copyCellContent(\n sourceCell: CellAddress,\n targetCell: CellAddress,\n sourceTopLeft: CellAddress,\n options: CopyCellsOptions\n ): void {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (!sheet) {\n return;\n }\n\n const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${\n sourceCell.rowIndex + 1\n }`;\n const cellContent = sheet.content.get(key);\n\n if (!cellContent) {\n // Source cell is empty\n return;\n }\n\n let targetContent: SerializedCellValue;\n\n if (options.type === \"value\") {\n // Copy evaluated value\n const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);\n \n if (!evalResult || evalResult.type !== \"value\") {\n // If evaluation failed or is not a value, copy as-is\n targetContent = cellContent;\n } else {\n // Convert to literal value\n const result = evalResult.result;\n if (result.type === \"number\") {\n targetContent = result.value;\n } else if (result.type === \"string\") {\n targetContent = result.value;\n } else if (result.type === \"boolean\") {\n targetContent = result.value;\n } else {\n // Error or other type, copy as-is\n targetContent = cellContent;\n }\n }\n } else {\n // Copy formula\n if (typeof cellContent === \"string\" && cellContent.startsWith(\"=\")) {\n // Adjust formula references\n targetContent = this.adjustFormulaReferences(\n cellContent,\n {\n colIndex: sourceCell.colIndex,\n rowIndex: sourceCell.rowIndex,\n },\n {\n colIndex: targetCell.colIndex,\n rowIndex: targetCell.rowIndex,\n }\n );\n } else {\n // Not a formula, copy as-is\n targetContent = cellContent;\n }\n }\n\n // Set target cell content (using the engine's method through workbook manager)\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.set(targetKey, targetContent);\n }\n }\n\n /**\n * Adjust formula references when copying\n * Based on autofill-utils.ts adjustFormulaReferences\n */\n private adjustFormulaReferences(\n formula: string,\n sourceAddress: LocalCellAddress,\n targetAddress: LocalCellAddress\n ): string {\n try {\n const ast = parseFormula(formula.slice(1)); // Remove the \"=\" sign\n\n const rowDelta = targetAddress.rowIndex - sourceAddress.rowIndex;\n const colDelta = targetAddress.colIndex - sourceAddress.colIndex;\n\n const adjustedAst = transformAST(ast, (node) => {\n if (node.type === \"reference\") {\n const refNode = node as ReferenceNode;\n return {\n ...refNode,\n address: {\n colIndex: refNode.isAbsolute.col\n ? refNode.address.colIndex\n : refNode.address.colIndex + colDelta,\n rowIndex: refNode.isAbsolute.row\n ? refNode.address.rowIndex\n : refNode.address.rowIndex + rowDelta,\n },\n };\n } else if (node.type === \"range\") {\n const rangeNode = node as RangeNode;\n return {\n ...rangeNode,\n range: {\n start: {\n col: rangeNode.isAbsolute.start.col\n ? rangeNode.range.start.col\n : rangeNode.range.start.col + colDelta,\n row: rangeNode.isAbsolute.start.row\n ? rangeNode.range.start.row\n : rangeNode.range.start.row + rowDelta,\n },\n end: {\n col:\n rangeNode.range.end.col.type === \"number\"\n ? rangeNode.isAbsolute.end.col\n ? rangeNode.range.end.col\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.col.value + colDelta,\n }\n : rangeNode.range.end.col,\n row:\n rangeNode.range.end.row.type === \"number\"\n ? rangeNode.isAbsolute.end.row\n ? rangeNode.range.end.row\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.row.value + rowDelta,\n }\n : rangeNode.range.end.row,\n },\n },\n };\n }\n return node;\n });\n\n return `=${astToString(adjustedAst)}`;\n } catch (error) {\n // If parsing fails, return the original formula\n console.warn(\"Failed to adjust formula references:\", error);\n return formula;\n }\n }\n\n /**\n * Copy formatting (cellStyles and conditionalStyles) from source to target\n */\n private copyFormatting(\n sourceCells: CellAddress[],\n sourceTopLeft: CellAddress,\n target: CellAddress,\n rowOffset: number,\n colOffset: number\n ): void {\n // Get all styles for the source workbook\n const allConditionalStyles = this.styleManager.getAllConditionalStyles();\n const allCellStyles = this.styleManager.getAllCellStyles();\n\n // Find styles that intersect with source cells\n const sourceRange = this.getBoundingBox(sourceCells);\n\n // Copy conditional styles\n for (const style of allConditionalStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: ConditionalStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n condition: style.condition,\n };\n this.styleManager.addConditionalStyle(newStyle);\n }\n }\n }\n\n // Copy cell styles\n for (const style of allCellStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: DirectCellStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n style: style.style,\n };\n this.styleManager.addCellStyle(newStyle);\n }\n }\n }\n }\n\n /**\n * Get bounding box for a set of cells\n */\n private getBoundingBox(cells: CellAddress[]): SpreadsheetRange {\n let minRow = Infinity;\n let maxRow = -Infinity;\n let minCol = Infinity;\n let maxCol = -Infinity;\n\n for (const cell of cells) {\n minRow = Math.min(minRow, cell.rowIndex);\n maxRow = Math.max(maxRow, cell.rowIndex);\n minCol = Math.min(minCol, cell.colIndex);\n maxCol = Math.max(maxCol, cell.colIndex);\n }\n\n return {\n start: { col: minCol, row: minRow },\n end: {\n col: { type: \"number\", value: maxCol },\n row: { type: \"number\", value: maxRow },\n },\n };\n }\n\n\n /**\n * Adjust a range by row and column offsets\n */\n private adjustRange(\n range: SpreadsheetRange,\n rowOffset: number,\n colOffset: number\n ): SpreadsheetRange {\n return {\n start: {\n col: range.start.col + colOffset,\n row: range.start.row + rowOffset,\n },\n end: {\n col:\n range.end.col.type === \"number\"\n ? { type: \"number\", value: range.end.col.value + colOffset }\n : range.end.col,\n row:\n range.end.row.type === \"number\"\n ? { type: \"number\", value: range.end.row.value + rowOffset }\n : range.end.row,\n },\n };\n }\n\n /**\n * Clear source cells (for cut operation)\n */\n private clearSourceCells(cells: CellAddress[]): void {\n for (const cell of cells) {\n const sheet = this.workbookManager.getSheet({\n workbookName: cell.workbookName,\n sheetName: cell.sheetName,\n });\n\n if (sheet) {\n const key = `${String.fromCharCode(65 + cell.colIndex)}${\n cell.rowIndex + 1\n }`;\n sheet.content.delete(key);\n }\n }\n }\n\n /**\n * Fill one or more areas with a seed range's content/style\n * Uses column-first strategy: fills down, then replicates right\n * Formulas are adjusted based on each target cell's offset from the seed\n */\n fillAreas(\n seedRange: RangeAddress,\n targetRanges: RangeAddress[],\n options: CopyCellsOptions\n ): void {\n for (const targetRange of targetRanges) {\n this.fillRangeWithSeed(seedRange, targetRange, {\n copyContent: options.target !== 'style',\n copyStyles: options.target === 'all' || options.target === 'style',\n contentType: options.type,\n adjustFormulas: true,\n });\n }\n\n // Clear seed range if cut operation\n if (options.cut) {\n const seedCells = this.expandRangeToCells(seedRange);\n this.clearSourceCells(seedCells);\n }\n }\n\n /**\n * Fill a target range with a seed range using column-first strategy\n * Step 1: Fill down - extend seed pattern vertically to match target height\n * Step 2: Replicate right - copy filled columns horizontally\n */\n private fillRangeWithSeed(\n seedRange: RangeAddress,\n targetRange: RangeAddress,\n options: {\n copyContent: boolean;\n copyStyles: boolean;\n contentType: \"value\" | \"formula\";\n adjustFormulas: boolean;\n }\n ): void {\n const seedCells = this.expandRangeToCells(seedRange);\n const seedWidth = this.getRangeWidth(seedRange);\n const seedHeight = this.getRangeHeight(seedRange);\n const targetWidth = this.getRangeWidth(targetRange);\n const targetHeight = this.getRangeHeight(targetRange);\n\n // Step 1: Fill down - replicate seed pattern vertically\n const filledColumns: Map<string, { cell: CellAddress; content: SerializedCellValue }> = new Map();\n \n for (let col = 0; col < seedWidth; col++) {\n for (let row = 0; row < targetHeight; row++) {\n const seedRow = row % seedHeight;\n const seedCell = seedCells.find(\n (c) => \n c.colIndex === seedRange.range.start.col + col &&\n c.rowIndex === seedRange.range.start.row + seedRow\n );\n\n if (seedCell) {\n const targetCell: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: targetRange.range.start.col + col,\n rowIndex: targetRange.range.start.row + row,\n };\n\n const rowDelta = targetCell.rowIndex - seedCell.rowIndex;\n const colDelta = targetCell.colIndex - seedCell.colIndex;\n\n if (options.copyContent) {\n this.copyCellContentWithOffset(seedCell, targetCell, rowDelta, colDelta, {\n type: options.contentType,\n cut: false,\n target: 'content',\n });\n }\n\n if (options.copyStyles) {\n this.copyCellFormatting(seedCell, targetCell);\n }\n\n // Store filled column for horizontal replication\n const key = `${targetCell.colIndex}-${targetCell.rowIndex}`;\n const sheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n const cellKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;\n const content = sheet?.content.get(cellKey) || \"\";\n filledColumns.set(key, { cell: targetCell, content });\n }\n }\n }\n\n // Step 2: Replicate right - copy filled columns horizontally\n if (targetWidth > seedWidth) {\n for (let col = seedWidth; col < targetWidth; col++) {\n const sourceCol = col % seedWidth;\n \n for (let row = 0; row < targetHeight; row++) {\n const sourceCell: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: targetRange.range.start.col + sourceCol,\n rowIndex: targetRange.range.start.row + row,\n };\n\n const targetCell: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: targetRange.range.start.col + col,\n rowIndex: targetRange.range.start.row + row,\n };\n\n const colDelta = targetCell.colIndex - sourceCell.colIndex;\n\n if (options.copyContent) {\n this.copyCellContentWithOffset(sourceCell, targetCell, 0, colDelta, {\n type: options.contentType,\n cut: false,\n target: 'content',\n });\n }\n\n if (options.copyStyles) {\n this.copyCellFormatting(sourceCell, targetCell);\n }\n }\n }\n }\n }\n\n /**\n * Get the width of a range (number of columns)\n */\n private getRangeWidth(range: RangeAddress): number {\n if (range.range.end.col.type === \"infinity\") {\n return 100; // Default for infinite\n }\n return range.range.end.col.value - range.range.start.col + 1;\n }\n\n /**\n * Get the height of a range (number of rows)\n */\n private getRangeHeight(range: RangeAddress): number {\n if (range.range.end.row.type === \"infinity\") {\n return 100; // Default for infinite\n }\n return range.range.end.row.value - range.range.start.row + 1;\n }\n\n /**\n * Expand a RangeAddress into an array of CellAddress\n * Handles finite ranges, row-bounded, and column-bounded ranges\n */\n private expandRangeToCells(rangeAddress: RangeAddress): CellAddress[] {\n const { workbookName, sheetName, range } = rangeAddress;\n const cells: CellAddress[] = [];\n\n const startCol = range.start.col;\n const startRow = range.start.row;\n\n // Determine end column\n let endCol: number;\n if (range.end.col.type === \"infinity\") {\n // Limit infinite column ranges to a reasonable size (e.g., 100 columns)\n endCol = startCol + 99;\n } else {\n endCol = range.end.col.value;\n }\n\n // Determine end row\n let endRow: number;\n if (range.end.row.type === \"infinity\") {\n // Limit infinite row ranges to a reasonable size (e.g., 100 rows)\n endRow = startRow + 99;\n } else {\n endRow = range.end.row.value;\n }\n\n // Generate all cells in the range\n for (let row = startRow; row <= endRow; row++) {\n for (let col = startCol; col <= endCol; col++) {\n cells.push({\n workbookName,\n sheetName,\n colIndex: col,\n rowIndex: row,\n });\n }\n }\n\n return cells;\n }\n\n /**\n * Copy cell content with explicit row/column offset for fill operations\n */\n private copyCellContentWithOffset(\n sourceCell: CellAddress,\n targetCell: CellAddress,\n rowDelta: number,\n colDelta: number,\n options: CopyCellsOptions\n ): void {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (!sheet) {\n return;\n }\n\n const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${\n sourceCell.rowIndex + 1\n }`;\n const cellContent = sheet.content.get(key);\n\n if (!cellContent) {\n // Source cell is empty - clear target\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.delete(targetKey);\n }\n return;\n }\n\n let targetContent: SerializedCellValue;\n\n if (options.type === \"value\") {\n // Copy evaluated value\n const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);\n \n if (!evalResult || evalResult.type !== \"value\") {\n // If evaluation failed or is not a value, copy as-is\n targetContent = cellContent;\n } else {\n // Convert to literal value\n const result = evalResult.result;\n if (result.type === \"number\") {\n targetContent = result.value;\n } else if (result.type === \"string\") {\n targetContent = result.value;\n } else if (result.type === \"boolean\") {\n targetContent = result.value;\n } else {\n // Error or other type, copy as-is\n targetContent = cellContent;\n }\n }\n } else {\n // Copy formula with offset adjustment\n if (typeof cellContent === \"string\" && cellContent.startsWith(\"=\")) {\n // Adjust formula references based on offset\n targetContent = this.adjustFormulaWithOffset(\n cellContent,\n rowDelta,\n colDelta\n );\n } else {\n // Not a formula, copy as-is\n targetContent = cellContent;\n }\n }\n\n // Set target cell content\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.set(targetKey, targetContent);\n }\n }\n\n /**\n * Adjust formula references by a specific row/column offset\n */\n private adjustFormulaWithOffset(\n formula: string,\n rowDelta: number,\n colDelta: number\n ): string {\n try {\n const ast = parseFormula(formula.slice(1)); // Remove the \"=\" sign\n\n const adjustedAst = transformAST(ast, (node) => {\n if (node.type === \"reference\") {\n const refNode = node as ReferenceNode;\n return {\n ...refNode,\n address: {\n colIndex: refNode.isAbsolute.col\n ? refNode.address.colIndex\n : refNode.address.colIndex + colDelta,\n rowIndex: refNode.isAbsolute.row\n ? refNode.address.rowIndex\n : refNode.address.rowIndex + rowDelta,\n },\n };\n } else if (node.type === \"range\") {\n const rangeNode = node as RangeNode;\n return {\n ...rangeNode,\n range: {\n start: {\n col: rangeNode.isAbsolute.start.col\n ? rangeNode.range.start.col\n : rangeNode.range.start.col + colDelta,\n row: rangeNode.isAbsolute.start.row\n ? rangeNode.range.start.row\n : rangeNode.range.start.row + rowDelta,\n },\n end: {\n col:\n rangeNode.range.end.col.type === \"number\"\n ? rangeNode.isAbsolute.end.col\n ? rangeNode.range.end.col\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.col.value + colDelta,\n }\n : rangeNode.range.end.col,\n row:\n rangeNode.range.end.row.type === \"number\"\n ? rangeNode.isAbsolute.end.row\n ? rangeNode.range.end.row\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.row.value + rowDelta,\n }\n : rangeNode.range.end.row,\n },\n },\n };\n }\n return node;\n });\n\n return `=${astToString(adjustedAst)}`;\n } catch (error) {\n // If parsing fails, return the original formula\n console.warn(\"Failed to adjust formula with offset:\", error);\n return formula;\n }\n }\n\n /**\n * Copy formatting from one cell to another\n */\n private copyCellFormatting(\n sourceCell: CellAddress,\n targetCell: CellAddress\n ): void {\n // Get all styles that intersect with the source cell\n const allConditionalStyles = this.styleManager.getAllConditionalStyles();\n const allCellStyles = this.styleManager.getAllCellStyles();\n\n const sourceCellRange: SpreadsheetRange = {\n start: { col: sourceCell.colIndex, row: sourceCell.rowIndex },\n end: {\n col: { type: \"number\", value: sourceCell.colIndex },\n row: { type: \"number\", value: sourceCell.rowIndex },\n },\n };\n\n // Copy conditional styles that apply to source cell\n for (const style of allConditionalStyles) {\n if (\n style.area.workbookName === sourceCell.workbookName &&\n style.area.sheetName === sourceCell.sheetName\n ) {\n const intersection = intersectRanges(style.area.range, sourceCellRange);\n if (intersection) {\n // Apply style to target cell\n const newStyle: ConditionalStyle = {\n area: {\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n range: {\n start: { col: targetCell.colIndex, row: targetCell.rowIndex },\n end: {\n col: { type: \"number\", value: targetCell.colIndex },\n row: { type: \"number\", value: targetCell.rowIndex },\n },\n },\n },\n condition: style.condition,\n };\n this.styleManager.addConditionalStyle(newStyle);\n }\n }\n }\n\n // Copy cell styles that apply to source cell\n for (const style of allCellStyles) {\n if (\n style.area.workbookName === sourceCell.workbookName &&\n style.area.sheetName === sourceCell.sheetName\n ) {\n const intersection = intersectRanges(style.area.range, sourceCellRange);\n if (intersection) {\n // Apply style to target cell\n const newStyle: DirectCellStyle = {\n area: {\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n range: {\n start: { col: targetCell.colIndex, row: targetCell.rowIndex },\n end: {\n col: { type: \"number\", value: targetCell.colIndex },\n row: { type: \"number\", value: targetCell.rowIndex },\n },\n },\n },\n style: style.style,\n };\n this.styleManager.addCellStyle(newStyle);\n }\n }\n }\n }\n}\n\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgB6B,IAA7B;AAC4B,IAA5B;AAC6B,IAA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U,OAAO,WAAW,SAAS;AAAA,gBACpD;AAAA,cACF;AAAA,YACF;AAAA,YACA,WAAW,MAAM;AAAA,UACnB;AAAA,UACA,KAAK,aAAa,oBAAoB,QAAQ;AAAA,QAChD;AAAA,MACF;AAAA,IACF;AAAA,IAGA,WAAW,SAAS,eAAe;AAAA,MACjC,IACE,MAAM,KAAK,iBAAiB,WAAW,gBACvC,MAAM,KAAK,cAAc,WAAW,WACpC;AAAA,QACA,MAAM,eAAe,mCAAgB,MAAM,KAAK,OAAO,eAAe;AAAA,QACtE,IAAI,cAAc;AAAA,UAEhB,MAAM,WAA4B;AAAA,YAChC,MAAM;AAAA,cACJ,cAAc,WAAW;AAAA,cACzB,WAAW,WAAW;AAAA,cACtB,OAAO;AAAA,gBACL,OAAO,EAAE,KAAK,WAAW,UAAU,KAAK,WAAW,SAAS;AAAA,gBAC5D,KAAK;AAAA,kBACH,KAAK,EAAE,MAAM,UAAU,OAAO,WAAW,SAAS;AAAA,kBAClD,KAAK,EAAE,MAAM,UAAU,OAAO,WAAW,SAAS;AAAA,gBACpD;AAAA,cACF;AAAA,YACF;AAAA,YACA,OAAO,MAAM;AAAA,UACf;AAAA,UACA,KAAK,aAAa,aAAa,QAAQ;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA;AAEJ;",
|
|
8
|
+
"debugId": "DAB7BAA575141E6064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Core type definitions for FormulaEngine\n * This file contains all fundamental types used throughout the engine\n */\n\nimport type { EvaluationContext } from \"../evaluator/evaluation-context.cjs\";\nimport type { FormulaEvaluator } from \"../evaluator/formula-evaluator.cjs\";\nimport type { FunctionNode } from \"../parser/ast.cjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.cjs\";\nimport type { LookupOrder } from \"./managers/range-eval-order-builder.cjs\";\n\n// Cell addressing types\nexport interface CellAddress {\n sheetName: string;\n workbookName: string;\n colIndex: number;\n rowIndex: number;\n}\n\nexport interface RangeAddress {\n sheetName: string;\n workbookName: string;\n range: SpreadsheetRange;\n}\n\nexport interface LocalCellAddress {\n colIndex: number;\n rowIndex: number;\n}\n\nexport type ArethmeticEvaluator = (\n left: CellValue,\n right: CellValue,\n context: EvaluationContext\n) => CellValue | ErrorEvaluationResult;\n\nexport type PositiveInfinity = {\n type: \"infinity\";\n sign: \"positive\";\n};\n\nexport type CellInfinity = {\n type: \"infinity\";\n sign: \"positive\" | \"negative\";\n};\n\nexport type CellNumber = {\n type: \"number\";\n value: number;\n};\n\nexport type SpreadsheetRangeEnd = CellNumber | PositiveInfinity;\n\nexport type SpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: SpreadsheetRangeEnd;\n row: SpreadsheetRangeEnd;\n };\n};\n\nexport type RelativeRange = {\n start: {\n col: number;\n row: number;\n };\n width: SpreadsheetRangeEnd;\n height: SpreadsheetRangeEnd;\n};\n\nexport type FiniteSpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: number;\n row: number;\n };\n};\n\nexport type CellString = {\n type: \"string\";\n value: string;\n};\n\nexport type CellBoolean = {\n type: \"boolean\";\n value: boolean;\n};\n\n// Cell value types\nexport type CellValue = CellNumber | CellString | CellBoolean | CellInfinity;\n/**\n * undefined and \"\" are considered empty values\n * undefineds are converted to \"\" in the engine\n *\n * any empty values are deleted from the sheet content\n */\nexport type SerializedCellValue = string | number | boolean | undefined;\n\n// Named expressions\nexport interface NamedExpression {\n name: string;\n expression: string;\n}\n\nexport interface TableDefinition {\n name: string;\n start: {\n rowIndex: number;\n colIndex: number;\n };\n headers: Map<string, { name: string; index: number }>;\n endRow: SpreadsheetRangeEnd;\n sheetName: string;\n workbookName: string;\n}\n\n// Formula errors\nexport enum FormulaError {\n DIV0 = \"#DIV/0!\",\n NA = \"#N/A\",\n NAME = \"#NAME?\",\n NUM = \"#NUM!\",\n REF = \"#REF!\",\n VALUE = \"#VALUE!\",\n CYCLE = \"#CYCLE!\",\n ERROR = \"#ERROR!\",\n SPILL = \"#SPILL!\",\n}\n\n// Sheet structure\nexport interface Sheet {\n name: string;\n index: number; // 0-based index of the sheet\n content: Map<string, SerializedCellValue>;\n}\n\nexport interface Workbook {\n name: string;\n sheets: Map<string, Sheet>;\n}\n\nexport type ValueEvaluationResult = {\n type: \"value\";\n result: CellValue;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type AwaitingEvaluationResult = {\n type: \"awaiting-evaluation\";\n waitingFor: DependencyNode;\n errAddress: DependencyNode;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type DoesNotSpillResult = {\n type: \"does-not-spill\";\n};\n\nexport type ErrorEvaluationResult =\n | {\n type: \"error\";\n err: FormulaError;\n errAddress: DependencyNode;\n message: string;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n }\n | AwaitingEvaluationResult;\n\nexport type SingleEvaluationResult =\n | ValueEvaluationResult\n | ErrorEvaluationResult;\n\nexport type SpilledValuesEvaluator = (\n spillOffset: { x: number; y: number },\n context: EvaluationContext\n) => SingleEvaluationResult;\n\nexport type SpilledValuesEvaluationResult = {\n type: \"spilled-values\";\n\n /**\n * When a raw range is evaluated, we will add it to the sourceRange so it can be used e.g. for context dependent functions\n */\n sourceRange?: RangeAddress;\n\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n * sourceCell will only be defined on a spilledValue when a single value is looked up,\n */\n sourceCell?: CellAddress;\n\n spillArea: (origin: CellAddress) => SpreadsheetRange;\n /**\n * for debugging we add a source string to denote where the spilled values were created\n */\n source: string;\n evaluate: SpilledValuesEvaluator;\n /**\n * evaluateAllCells evaluates all non-empty cells in the spilled range.\n * Because a spilled range can be open-ended, we need to have logic for which cells we should evaluate.\n * e.g. when evaluating a range such as D:D only the cells in the current sheet residing in\n * column D should be evaluated and cells producing spilled values that spill onto D:D.\n *\n * In order to evaluate spilled cells in D:D the range evaluateAllCells need to get all cells in the\n * the intersection of the spilled range and D:D, for that reason evaluateAllCells gets an intersection parameter,\n * where the intersection is relative to the origin.\n *\n * #### Producers:\n * In e.g. SEQUENCE and evaluateRange we have logic for which cells in a spilled range we should evaluate,\n *\n * #### Nesting:\n * e.g. evaluation of scalar operators where we want to nest e.g. `5 * right.evaluate()`\n * can be implemented by calling\n * ```ts\n * const vals = child.evaluateAllCells.call(this, options);\n * return vals.map(val => ({ ...val, result: 5 * val.result }));\n * ```\n *\n * #### Consumers:\n * Only functions that need access to all spilled values in a range end up calling evaluateAllCells, e.g.\n * SUM, MIN, MAX, MATCH. Other types of functions like INDEX doesn't need to evaluate all cells in a range,\n * but does a lookup into a spilled range using the evaluate method.\n *\n */\n evaluateAllCells: (\n this: FormulaEvaluator,\n options: {\n /**\n * an intersection relative to the origin\n */\n intersection?: SpreadsheetRange;\n evaluate: SpilledValuesEvaluator;\n context: EvaluationContext;\n /**\n * origin is the cell address that the spilled range is spilled from\n * e.g. in A3=B2:B4 the origin is A3\n */\n origin: CellAddress;\n\n lookupOrder: LookupOrder;\n }\n ) => EvaluateAllCellsResult;\n};\n\nexport type EvaluateAllCellsResult =\n | ErrorEvaluationResult\n | {\n type: \"values\";\n values: CellInRangeResult[];\n };\n\nexport type CellInRangeResult = {\n result: SingleEvaluationResult;\n relativePos: { x: number; y: number };\n};\n\nexport type FunctionEvaluationResult =\n | SingleEvaluationResult\n | SpilledValuesEvaluationResult;\n\nexport type SpilledValue = {\n /**\n * spillOnto is the range that the spilled value is spilled onto\n */\n spillOnto: SpreadsheetRange;\n /**\n * origin is the cell address that the spilled value is spilled from\n */\n origin: CellAddress;\n};\n\n/**\n * Function definition\n */\nexport interface FunctionDefinition {\n name: string;\n evaluate: (\n this: FormulaEvaluator,\n node: FunctionNode,\n context: EvaluationContext\n ) => FunctionEvaluationResult;\n aliases?: string[];\n}\n\n/**\n * Evaluation result\n */\nexport type EvaluationResult = {\n dependencies: Set<string>;\n} & FunctionEvaluationResult;\n\nexport type SCC = {\n id: number;\n nodes: Set<DependencyNode>; // All nodes considering soft + hard edges\n evaluationOrder: DependencyNode[]; // Flat topologically ordered list\n resolved: boolean;\n hardEdgeSCCs: Set<DependencyNode>[]; // SCCs formed by only hard edges (regular dependencies)\n};\n\nexport type SCCDAG = {\n sccList: SCC[];\n sccGraph: Map<number, Set<number>>; // Adjacency list of SCC dependencies\n};\n\nexport type EvaluationOrder = {\n evaluationOrder: Set<DependencyNode>;\n hasCycle: boolean;\n cycleNodes?: Set<DependencyNode>;\n hash: string;\n sccDAG?: SCCDAG;\n};\n\n// Conditional Styling types\nexport interface LCHColor {\n l: number; // Lightness: 0-100\n c: number; // Chroma: 0-150+\n h: number; // Hue: 0-360\n}\n\nexport interface FormulaStyleCondition {\n type: \"formula\";\n formula: string;\n color: LCHColor;\n}\n\nexport interface GradientStyleCondition {\n type: \"gradient\";\n min:\n | { type: \"lowest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n max:\n | { type: \"highest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n}\n\nexport type StyleCondition = FormulaStyleCondition | GradientStyleCondition;\n\nexport interface ConditionalStyle {\n area: RangeAddress;\n condition: StyleCondition;\n}\n\nexport interface DirectCellStyle {\n area: RangeAddress;\n style: CellStyle\n}\n\nexport interface CellStyle {\n backgroundColor?: string; // Hex color format\n color?: string; // Text color in hex format\n fontSize?: number; // Font size in pixels\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface CopyCellsOptions {\n cut: boolean;\n type: \"value\" | \"formula\";\n formatting: boolean;\n}\n"
|
|
5
|
+
"/**\n * Core type definitions for FormulaEngine\n * This file contains all fundamental types used throughout the engine\n */\n\nimport type { EvaluationContext } from \"../evaluator/evaluation-context.cjs\";\nimport type { FormulaEvaluator } from \"../evaluator/formula-evaluator.cjs\";\nimport type { FunctionNode } from \"../parser/ast.cjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.cjs\";\nimport type { LookupOrder } from \"./managers/range-eval-order-builder.cjs\";\n\n// Cell addressing types\nexport interface CellAddress {\n sheetName: string;\n workbookName: string;\n colIndex: number;\n rowIndex: number;\n}\n\nexport interface RangeAddress {\n sheetName: string;\n workbookName: string;\n range: SpreadsheetRange;\n}\n\nexport interface LocalCellAddress {\n colIndex: number;\n rowIndex: number;\n}\n\nexport type ArethmeticEvaluator = (\n left: CellValue,\n right: CellValue,\n context: EvaluationContext\n) => CellValue | ErrorEvaluationResult;\n\nexport type PositiveInfinity = {\n type: \"infinity\";\n sign: \"positive\";\n};\n\nexport type CellInfinity = {\n type: \"infinity\";\n sign: \"positive\" | \"negative\";\n};\n\nexport type CellNumber = {\n type: \"number\";\n value: number;\n};\n\nexport type SpreadsheetRangeEnd = CellNumber | PositiveInfinity;\n\nexport type SpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: SpreadsheetRangeEnd;\n row: SpreadsheetRangeEnd;\n };\n};\n\nexport type RelativeRange = {\n start: {\n col: number;\n row: number;\n };\n width: SpreadsheetRangeEnd;\n height: SpreadsheetRangeEnd;\n};\n\nexport type FiniteSpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: number;\n row: number;\n };\n};\n\nexport type CellString = {\n type: \"string\";\n value: string;\n};\n\nexport type CellBoolean = {\n type: \"boolean\";\n value: boolean;\n};\n\n// Cell value types\nexport type CellValue = CellNumber | CellString | CellBoolean | CellInfinity;\n/**\n * undefined and \"\" are considered empty values\n * undefineds are converted to \"\" in the engine\n *\n * any empty values are deleted from the sheet content\n */\nexport type SerializedCellValue = string | number | boolean | undefined;\n\n// Named expressions\nexport interface NamedExpression {\n name: string;\n expression: string;\n}\n\nexport interface TableDefinition {\n name: string;\n start: {\n rowIndex: number;\n colIndex: number;\n };\n headers: Map<string, { name: string; index: number }>;\n endRow: SpreadsheetRangeEnd;\n sheetName: string;\n workbookName: string;\n}\n\n// Formula errors\nexport enum FormulaError {\n DIV0 = \"#DIV/0!\",\n NA = \"#N/A\",\n NAME = \"#NAME?\",\n NUM = \"#NUM!\",\n REF = \"#REF!\",\n VALUE = \"#VALUE!\",\n CYCLE = \"#CYCLE!\",\n ERROR = \"#ERROR!\",\n SPILL = \"#SPILL!\",\n}\n\n// Sheet structure\nexport interface Sheet {\n name: string;\n index: number; // 0-based index of the sheet\n content: Map<string, SerializedCellValue>;\n}\n\nexport interface Workbook {\n name: string;\n sheets: Map<string, Sheet>;\n}\n\nexport type ValueEvaluationResult = {\n type: \"value\";\n result: CellValue;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type AwaitingEvaluationResult = {\n type: \"awaiting-evaluation\";\n waitingFor: DependencyNode;\n errAddress: DependencyNode;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type DoesNotSpillResult = {\n type: \"does-not-spill\";\n};\n\nexport type ErrorEvaluationResult =\n | {\n type: \"error\";\n err: FormulaError;\n errAddress: DependencyNode;\n message: string;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n }\n | AwaitingEvaluationResult;\n\nexport type SingleEvaluationResult =\n | ValueEvaluationResult\n | ErrorEvaluationResult;\n\nexport type SpilledValuesEvaluator = (\n spillOffset: { x: number; y: number },\n context: EvaluationContext\n) => SingleEvaluationResult;\n\nexport type SpilledValuesEvaluationResult = {\n type: \"spilled-values\";\n\n /**\n * When a raw range is evaluated, we will add it to the sourceRange so it can be used e.g. for context dependent functions\n */\n sourceRange?: RangeAddress;\n\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n * sourceCell will only be defined on a spilledValue when a single value is looked up,\n */\n sourceCell?: CellAddress;\n\n spillArea: (origin: CellAddress) => SpreadsheetRange;\n /**\n * for debugging we add a source string to denote where the spilled values were created\n */\n source: string;\n evaluate: SpilledValuesEvaluator;\n /**\n * evaluateAllCells evaluates all non-empty cells in the spilled range.\n * Because a spilled range can be open-ended, we need to have logic for which cells we should evaluate.\n * e.g. when evaluating a range such as D:D only the cells in the current sheet residing in\n * column D should be evaluated and cells producing spilled values that spill onto D:D.\n *\n * In order to evaluate spilled cells in D:D the range evaluateAllCells need to get all cells in the\n * the intersection of the spilled range and D:D, for that reason evaluateAllCells gets an intersection parameter,\n * where the intersection is relative to the origin.\n *\n * #### Producers:\n * In e.g. SEQUENCE and evaluateRange we have logic for which cells in a spilled range we should evaluate,\n *\n * #### Nesting:\n * e.g. evaluation of scalar operators where we want to nest e.g. `5 * right.evaluate()`\n * can be implemented by calling\n * ```ts\n * const vals = child.evaluateAllCells.call(this, options);\n * return vals.map(val => ({ ...val, result: 5 * val.result }));\n * ```\n *\n * #### Consumers:\n * Only functions that need access to all spilled values in a range end up calling evaluateAllCells, e.g.\n * SUM, MIN, MAX, MATCH. Other types of functions like INDEX doesn't need to evaluate all cells in a range,\n * but does a lookup into a spilled range using the evaluate method.\n *\n */\n evaluateAllCells: (\n this: FormulaEvaluator,\n options: {\n /**\n * an intersection relative to the origin\n */\n intersection?: SpreadsheetRange;\n evaluate: SpilledValuesEvaluator;\n context: EvaluationContext;\n /**\n * origin is the cell address that the spilled range is spilled from\n * e.g. in A3=B2:B4 the origin is A3\n */\n origin: CellAddress;\n\n lookupOrder: LookupOrder;\n }\n ) => EvaluateAllCellsResult;\n};\n\nexport type EvaluateAllCellsResult =\n | ErrorEvaluationResult\n | {\n type: \"values\";\n values: CellInRangeResult[];\n };\n\nexport type CellInRangeResult = {\n result: SingleEvaluationResult;\n relativePos: { x: number; y: number };\n};\n\nexport type FunctionEvaluationResult =\n | SingleEvaluationResult\n | SpilledValuesEvaluationResult;\n\nexport type SpilledValue = {\n /**\n * spillOnto is the range that the spilled value is spilled onto\n */\n spillOnto: SpreadsheetRange;\n /**\n * origin is the cell address that the spilled value is spilled from\n */\n origin: CellAddress;\n};\n\n/**\n * Function definition\n */\nexport interface FunctionDefinition {\n name: string;\n evaluate: (\n this: FormulaEvaluator,\n node: FunctionNode,\n context: EvaluationContext\n ) => FunctionEvaluationResult;\n aliases?: string[];\n}\n\n/**\n * Evaluation result\n */\nexport type EvaluationResult = {\n dependencies: Set<string>;\n} & FunctionEvaluationResult;\n\nexport type SCC = {\n id: number;\n nodes: Set<DependencyNode>; // All nodes considering soft + hard edges\n evaluationOrder: DependencyNode[]; // Flat topologically ordered list\n resolved: boolean;\n hardEdgeSCCs: Set<DependencyNode>[]; // SCCs formed by only hard edges (regular dependencies)\n};\n\nexport type SCCDAG = {\n sccList: SCC[];\n sccGraph: Map<number, Set<number>>; // Adjacency list of SCC dependencies\n};\n\nexport type EvaluationOrder = {\n evaluationOrder: Set<DependencyNode>;\n hasCycle: boolean;\n cycleNodes?: Set<DependencyNode>;\n hash: string;\n sccDAG?: SCCDAG;\n};\n\n// Conditional Styling types\nexport interface LCHColor {\n l: number; // Lightness: 0-100\n c: number; // Chroma: 0-150+\n h: number; // Hue: 0-360\n}\n\nexport interface FormulaStyleCondition {\n type: \"formula\";\n formula: string;\n color: LCHColor;\n}\n\nexport interface GradientStyleCondition {\n type: \"gradient\";\n min:\n | { type: \"lowest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n max:\n | { type: \"highest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n}\n\nexport type StyleCondition = FormulaStyleCondition | GradientStyleCondition;\n\nexport interface ConditionalStyle {\n area: RangeAddress;\n condition: StyleCondition;\n}\n\nexport interface DirectCellStyle {\n area: RangeAddress;\n style: CellStyle\n}\n\nexport interface CellStyle {\n backgroundColor?: string; // Hex color format\n color?: string; // Text color in hex format\n fontSize?: number; // Font size in pixels\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface CopyCellsOptions {\n cut: boolean;\n /**\n * all: Copy everything from the source to the target\n * content: Copy only the content from the source to the target\n * style: Copy only the style from the source to the target\n */\n target: 'all' | 'content' | 'style';\n /**\n * The type of the content to copy\n * value: Copy the value from the source to the target,\n * e.g. if the cell has the formula =123 + 123 then the value is 246\n * formula: Copy the formula from the source to the target,\n * e.g. if the cell has the formula =123 + 123 then the formula is =123 + 123 is copied\n */\n type: \"value\" | \"formula\";\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HO,IAAK;AAAA,CAAL,CAAK,kBAAL;AAAA,EACL,wBAAO;AAAA,EACP,sBAAK;AAAA,EACL,wBAAO;AAAA,EACP,uBAAM;AAAA,EACN,uBAAM;AAAA,EACN,yBAAQ;AAAA,EACR,yBAAQ;AAAA,EACR,yBAAQ;AAAA,EACR,yBAAQ;AAAA,GATE;",
|
|
8
8
|
"debugId": "F54C7C141D21E24164756E2164756E21",
|
package/dist/cjs/package.json
CHANGED