@worksheet-js/core 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -16,9 +16,15 @@
16
16
  ## 📦 Installation
17
17
 
18
18
  ```bash
19
- pnpm add @worksheet-js/core
19
+ npm install @worksheet-js/core
20
20
  ```
21
21
 
22
+ > [!TIP]
23
+ > Using React or Vue? We recommend installing the official wrapper for the best developer experience:
24
+ >
25
+ > - **React**: `npm install @worksheet-js/core @worksheet-js/react`
26
+ > - **Vue**: `npm install @worksheet-js/core @worksheet-js/vue`
27
+
22
28
  ## 🚀 Quick Start
23
29
 
24
30
  ```typescript
package/dist/index.d.mts CHANGED
@@ -539,6 +539,7 @@ declare class Viewport {
539
539
  private endCol;
540
540
  private startRow;
541
541
  private endRow;
542
+ private _renderRequested;
542
543
  private _measurer;
543
544
  constructor(ws: WorksheetModel, container: HTMLElement);
544
545
  /** Returns the view layer element for external consumers (e.g., SelectionPainter). */
@@ -570,6 +571,11 @@ declare class Viewport {
570
571
  * Render loop: recycles DOM nodes to match current visible range.
571
572
  */
572
573
  render(): void;
574
+ /**
575
+ * Schedules a render on the next animation frame.
576
+ * Collapses multiple calls into a single render to prevent loops and O(N^2) lag.
577
+ */
578
+ requestRender(): void;
573
579
  private _activeFilterPanel;
574
580
  private _openFilterPanel;
575
581
  /** Apply stored cell style properties to a DOM element */
@@ -835,27 +841,29 @@ declare class ColModel {
835
841
  type LicensePlan = 'starter' | 'pro' | 'enterprise';
836
842
 
837
843
  declare class SheetData {
838
- /** Sparse cell storage keyed by "x,y" */
844
+ /** Sparse cell storage: Map<row, Map<col, CellData>> */
839
845
  private cells;
840
846
  /** Set by Worksheet after construction to enable formula evaluation */
841
847
  formulaEngine?: FormulaEngine;
842
848
  /** Set by Worksheet to enable license-based validation */
843
849
  getEdition?: () => LicensePlan;
844
- /** Read-only access to the internal cell map (used for cloning). */
845
- protected getCells(): ReadonlyMap<string, CellData>;
846
850
  /** Get the raw input string value (e.g. "1200" or "=A1") */
847
851
  getValue(x: number, y: number): string;
848
852
  /** Iterate over all populated cells (sparse scan) */
849
853
  forEachCell(callback: (x: number, y: number, cell: CellData) => void): void;
850
- /** Get all populated cells in a specific row (sparse scan) */
854
+ /** Get all populated cells in a specific row (efficient O(cells in row)) */
851
855
  getCellsInRow(rowIdx: number): Array<[number, CellData]>;
852
856
  /**
853
857
  * Efficiently bulk-load parsed data from @worksheet/parser directly into the underlying maps.
854
858
  * Bypasses the FormatEngine's slow parsing for string/number extraction, mapping cell types directly.
855
859
  */
856
860
  loadFromParser(parsedData: SheetData$1): Promise<void>;
861
+ /** Get the total populated cell count across all rows */
862
+ private getCellCount;
857
863
  /** Get the parsed typed data */
858
864
  getCell(x: number, y: number): CellData | undefined;
865
+ /** Internal low-level cell setter */
866
+ private internalSetCell;
859
867
  /** Set a new raw input value, parsing it automatically */
860
868
  setValue(x: number, y: number, rawInput: string): void;
861
869
  /** Delete a cell entirely (including values, styles, formats, notes, comments) */
package/dist/index.d.ts CHANGED
@@ -539,6 +539,7 @@ declare class Viewport {
539
539
  private endCol;
540
540
  private startRow;
541
541
  private endRow;
542
+ private _renderRequested;
542
543
  private _measurer;
543
544
  constructor(ws: WorksheetModel, container: HTMLElement);
544
545
  /** Returns the view layer element for external consumers (e.g., SelectionPainter). */
@@ -570,6 +571,11 @@ declare class Viewport {
570
571
  * Render loop: recycles DOM nodes to match current visible range.
571
572
  */
572
573
  render(): void;
574
+ /**
575
+ * Schedules a render on the next animation frame.
576
+ * Collapses multiple calls into a single render to prevent loops and O(N^2) lag.
577
+ */
578
+ requestRender(): void;
573
579
  private _activeFilterPanel;
574
580
  private _openFilterPanel;
575
581
  /** Apply stored cell style properties to a DOM element */
@@ -835,27 +841,29 @@ declare class ColModel {
835
841
  type LicensePlan = 'starter' | 'pro' | 'enterprise';
836
842
 
837
843
  declare class SheetData {
838
- /** Sparse cell storage keyed by "x,y" */
844
+ /** Sparse cell storage: Map<row, Map<col, CellData>> */
839
845
  private cells;
840
846
  /** Set by Worksheet after construction to enable formula evaluation */
841
847
  formulaEngine?: FormulaEngine;
842
848
  /** Set by Worksheet to enable license-based validation */
843
849
  getEdition?: () => LicensePlan;
844
- /** Read-only access to the internal cell map (used for cloning). */
845
- protected getCells(): ReadonlyMap<string, CellData>;
846
850
  /** Get the raw input string value (e.g. "1200" or "=A1") */
847
851
  getValue(x: number, y: number): string;
848
852
  /** Iterate over all populated cells (sparse scan) */
849
853
  forEachCell(callback: (x: number, y: number, cell: CellData) => void): void;
850
- /** Get all populated cells in a specific row (sparse scan) */
854
+ /** Get all populated cells in a specific row (efficient O(cells in row)) */
851
855
  getCellsInRow(rowIdx: number): Array<[number, CellData]>;
852
856
  /**
853
857
  * Efficiently bulk-load parsed data from @worksheet/parser directly into the underlying maps.
854
858
  * Bypasses the FormatEngine's slow parsing for string/number extraction, mapping cell types directly.
855
859
  */
856
860
  loadFromParser(parsedData: SheetData$1): Promise<void>;
861
+ /** Get the total populated cell count across all rows */
862
+ private getCellCount;
857
863
  /** Get the parsed typed data */
858
864
  getCell(x: number, y: number): CellData | undefined;
865
+ /** Internal low-level cell setter */
866
+ private internalSetCell;
859
867
  /** Set a new raw input value, parsing it automatically */
860
868
  setValue(x: number, y: number, rawInput: string): void;
861
869
  /** Delete a cell entirely (including values, styles, formats, notes, comments) */