@datalayer/cells 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +55 -2
- package/lib/chrome/index.d.ts +7 -0
- package/lib/chrome/index.d.ts.map +1 -0
- package/lib/chrome/index.js +7 -0
- package/lib/chrome/index.js.map +1 -0
- package/lib/collab/index.d.ts +7 -0
- package/lib/collab/index.d.ts.map +1 -0
- package/lib/collab/index.js +7 -0
- package/lib/collab/index.js.map +1 -0
- package/lib/core/axis.d.ts +103 -0
- package/lib/core/axis.d.ts.map +1 -0
- package/lib/core/axis.js +470 -0
- package/lib/core/axis.js.map +1 -0
- package/lib/core/cells.d.ts +71 -0
- package/lib/core/cells.d.ts.map +1 -0
- package/lib/core/cells.js +285 -0
- package/lib/core/cells.js.map +1 -0
- package/lib/core/commands.d.ts +157 -0
- package/lib/core/commands.d.ts.map +1 -0
- package/lib/core/commands.js +620 -0
- package/lib/core/commands.js.map +1 -0
- package/lib/core/format.d.ts +52 -0
- package/lib/core/format.d.ts.map +1 -0
- package/lib/core/format.js +264 -0
- package/lib/core/format.js.map +1 -0
- package/lib/core/history.d.ts +42 -0
- package/lib/core/history.d.ts.map +1 -0
- package/lib/core/history.js +63 -0
- package/lib/core/history.js.map +1 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +28 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/model.d.ts +116 -0
- package/lib/core/model.d.ts.map +1 -0
- package/lib/core/model.js +330 -0
- package/lib/core/model.js.map +1 -0
- package/lib/core/patches.d.ts +140 -0
- package/lib/core/patches.d.ts.map +1 -0
- package/lib/core/patches.js +272 -0
- package/lib/core/patches.js.map +1 -0
- package/lib/core/reactor.d.ts +24 -0
- package/lib/core/reactor.d.ts.map +1 -0
- package/lib/core/reactor.js +48 -0
- package/lib/core/reactor.js.map +1 -0
- package/lib/core/selection.d.ts +81 -0
- package/lib/core/selection.d.ts.map +1 -0
- package/lib/core/selection.js +175 -0
- package/lib/core/selection.js.map +1 -0
- package/lib/core/strings.d.ts +19 -0
- package/lib/core/strings.d.ts.map +1 -0
- package/lib/core/strings.js +61 -0
- package/lib/core/strings.js.map +1 -0
- package/lib/core/styles.d.ts +48 -0
- package/lib/core/styles.d.ts.map +1 -0
- package/lib/core/styles.js +102 -0
- package/lib/core/styles.js.map +1 -0
- package/lib/core/values.d.ts +20 -0
- package/lib/core/values.d.ts.map +1 -0
- package/lib/core/values.js +39 -0
- package/lib/core/values.js.map +1 -0
- package/lib/core/workbook.d.ts +59 -0
- package/lib/core/workbook.d.ts.map +1 -0
- package/lib/core/workbook.js +101 -0
- package/lib/core/workbook.js.map +1 -0
- package/lib/core/zone.d.ts +48 -0
- package/lib/core/zone.d.ts.map +1 -0
- package/lib/core/zone.js +89 -0
- package/lib/core/zone.js.map +1 -0
- package/lib/csv/index.d.ts +7 -0
- package/lib/csv/index.d.ts.map +1 -0
- package/lib/csv/index.js +7 -0
- package/lib/csv/index.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -0
- package/lib/plugin/index.d.ts +7 -0
- package/lib/plugin/index.d.ts.map +1 -0
- package/lib/plugin/index.js +7 -0
- package/lib/plugin/index.js.map +1 -0
- package/lib/points/index.d.ts +154 -0
- package/lib/points/index.d.ts.map +1 -0
- package/lib/points/index.js +50 -0
- package/lib/points/index.js.map +1 -0
- package/lib/points/resolve.d.ts +56 -0
- package/lib/points/resolve.d.ts.map +1 -0
- package/lib/points/resolve.js +106 -0
- package/lib/points/resolve.js.map +1 -0
- package/lib/xlsx/index.d.ts +7 -0
- package/lib/xlsx/index.d.ts.map +1 -0
- package/lib/xlsx/index.js +7 -0
- package/lib/xlsx/index.js.map +1 -0
- package/package.json +116 -4
- package/style/cells.css +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2026 Datalayer, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://datalayer.ai)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/sponsors/datalayer)
|
|
4
|
+
|
|
5
|
+
# ☰ 🦠 Datalayer Cells
|
|
6
|
+
|
|
7
|
+
A spreadsheet drawn on canvas and exposed as a React component, over a
|
|
8
|
+
headless model that also runs in Node and in workers. Cells is built on
|
|
9
|
+
[Reactor](https://github.com/datalayer/reactor): every extension point (formula
|
|
10
|
+
functions, cell types, commands, importers and exporters, data sources, the
|
|
11
|
+
collaboration provider) is a Reactor contribution point, and the built-in
|
|
12
|
+
features are Reactor plugins contributing through the same points.
|
|
13
|
+
|
|
14
|
+
> Work in progress: nothing is published yet.
|
|
15
|
+
|
|
16
|
+
## Packages
|
|
17
|
+
|
|
18
|
+
| Import | What |
|
|
19
|
+
| ------------------------- | ------------------------------------------------------- |
|
|
20
|
+
| `@datalayer/cells` | the React component and hooks; re-exports `./core` |
|
|
21
|
+
| `@datalayer/cells/core` | the headless model: no React, no DOM |
|
|
22
|
+
| `@datalayer/cells/csv` | CSV and TSV in and out |
|
|
23
|
+
| `@datalayer/cells/xlsx` | XLSX in and out, loaded lazily |
|
|
24
|
+
| `@datalayer/cells/collab` | real-time collaboration over Loro |
|
|
25
|
+
| `@datalayer/cells/chrome` | toolbar, formula bar and sheet tabs |
|
|
26
|
+
| `@datalayer/cells/plugin` | views for a Reactor shell |
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
The reactor is resolved from a checkout beside this repository (`../reactor`).
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
npm run lint # Prettier and the licence header on every file
|
|
35
|
+
npm run typecheck # everything, tests included, against ../reactor/src
|
|
36
|
+
npm test # unit tests (vitest, two workers)
|
|
37
|
+
npm run build # lib/
|
|
38
|
+
npm run bench # Node benches into bench/results/
|
|
39
|
+
npm run size # bundle sizes against their budgets
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Browser benches and end-to-end tests run on the system Chrome, headless:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
env -u WAYLAND_DISPLAY -u DISPLAY node scripts/bench.mjs --browser
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Credits
|
|
49
|
+
|
|
50
|
+
Cells was designed after reading [x-spreadsheet](https://github.com/myliang/x-spreadsheet)
|
|
51
|
+
(MIT) and [o-spreadsheet](https://github.com/odoo/o-spreadsheet) (LGPLv3) for
|
|
52
|
+
ideas; no code of either is included. See [THIRD_PARTY.md](THIRD_PARTY.md).
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chrome/index.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/chrome/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/collab/index.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/collab/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An axis of a sheet: its rows, or its columns.
|
|
3
|
+
*
|
|
4
|
+
* - **Ids.** Every index has a stable id that follows the row through inserts,
|
|
5
|
+
* deletes and moves. Ids are materialised only up to the last index ever
|
|
6
|
+
* named; beyond, an index has an *implicit* id derived from where the row
|
|
7
|
+
* was when the axis was created (`IMPLICIT_BASE + creation index`), so two
|
|
8
|
+
* replicas that materialise the same index independently agree on its id.
|
|
9
|
+
* Inserted indexes get fresh ids, from `FRESH_BASE` up.
|
|
10
|
+
* - **Sizes.** Default until the first resize; then a raw `Float64Array` of
|
|
11
|
+
* sizes and a Fenwick tree over the effective sizes (0 when hidden), so
|
|
12
|
+
* `offsetOf` and `indexAt` are O(log n) and a resize is O(log n). An insert
|
|
13
|
+
* or delete rebuilds the tree from the edit point only.
|
|
14
|
+
* - **Hidden** is a bitset beside the sizes: a hidden index keeps its size for
|
|
15
|
+
* unhide and contributes 0 to offsets.
|
|
16
|
+
*
|
|
17
|
+
* @module core/axis
|
|
18
|
+
*/
|
|
19
|
+
/** Implicit ids are `IMPLICIT_BASE + creation index`. */
|
|
20
|
+
export declare const IMPLICIT_BASE = 0;
|
|
21
|
+
/** Fresh ids (inserted indexes) start here, above any creation index. */
|
|
22
|
+
export declare const FRESH_BASE: number;
|
|
23
|
+
/** The state of a run of indexes, as patches carry it. */
|
|
24
|
+
export interface AxisSegment {
|
|
25
|
+
readonly ids: Int32Array;
|
|
26
|
+
/** `null`: every size is the default. */
|
|
27
|
+
readonly sizes: Float64Array | null;
|
|
28
|
+
/** `null`: none is hidden; else 1 per hidden index. */
|
|
29
|
+
readonly hidden: Uint8Array | null;
|
|
30
|
+
}
|
|
31
|
+
export interface AxisOptions {
|
|
32
|
+
/** The logical number of indexes (1,048,576 rows, 16,384 columns in Excel). */
|
|
33
|
+
readonly count: number;
|
|
34
|
+
/** The size of an index nobody resized, in CSS px. */
|
|
35
|
+
readonly defaultSize: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class Axis {
|
|
38
|
+
#private;
|
|
39
|
+
readonly count: number;
|
|
40
|
+
readonly defaultSize: number;
|
|
41
|
+
constructor(options: AxisOptions);
|
|
42
|
+
/** The id of an index, materialised or implicit. */
|
|
43
|
+
idAt(index: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Materialise ids up to `index` inclusive and return its id. Anything that
|
|
46
|
+
* names an index (content, a size, a merge corner, a reference) calls this
|
|
47
|
+
* first, so no implicit id is ever referenced.
|
|
48
|
+
*/
|
|
49
|
+
materialize(index: number): number;
|
|
50
|
+
/** How many ids are materialised. */
|
|
51
|
+
get materialized(): number;
|
|
52
|
+
/** `n` fresh ids, for the indexes an insert creates. Never reused. */
|
|
53
|
+
freshIds(n: number): Int32Array;
|
|
54
|
+
/** The index of an id, or -1. O(n) over the materialised ids; for the binding, not the hot path. */
|
|
55
|
+
indexOfId(id: number): number;
|
|
56
|
+
/** A copy of the materialised ids, for snapshots and the file format. */
|
|
57
|
+
ids(): Int32Array;
|
|
58
|
+
/** The state of `n` indexes from `at`: ids, sizes and hidden flags, for patches. */
|
|
59
|
+
segment(at: number, n: number): AxisSegment;
|
|
60
|
+
/**
|
|
61
|
+
* Insert `n` indexes before `at`. The count stays: the last `n` indexes fall
|
|
62
|
+
* off the end (the command checks they are empty), and come back as
|
|
63
|
+
* `dropped`. With `segment`, the inserted indexes take its ids, sizes and
|
|
64
|
+
* hidden flags (undo, redo, remote inserts); without, fresh ids and the
|
|
65
|
+
* default size.
|
|
66
|
+
*/
|
|
67
|
+
insert(at: number, n: number, segment?: AxisSegment): {
|
|
68
|
+
inserted: AxisSegment;
|
|
69
|
+
dropped: AxisSegment;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Delete `n` indexes from `at`; returns them. New indexes appear at the end:
|
|
73
|
+
* implicit ones, or `tail`'s when given (undoing an insert brings back the
|
|
74
|
+
* indexes it pushed off).
|
|
75
|
+
*/
|
|
76
|
+
delete(at: number, n: number, tail?: AxisSegment): AxisSegment;
|
|
77
|
+
/**
|
|
78
|
+
* Move `n` indexes from `at` to before `to` (an index in the coordinates
|
|
79
|
+
* before the move, outside `[at, at + n]`). Ids, sizes and hidden flags travel.
|
|
80
|
+
*/
|
|
81
|
+
move(at: number, n: number, to: number): void;
|
|
82
|
+
/** Set sizes and hidden flags of `n` indexes from `at` at once (patches). */
|
|
83
|
+
setSegmentSizes(at: number, sizes: Float64Array | null, hidden: Uint8Array | null, n: number): void;
|
|
84
|
+
/** The size of an index as set, hidden or not. */
|
|
85
|
+
sizeOf(index: number): number;
|
|
86
|
+
/** The size an index takes on screen: 0 when hidden. */
|
|
87
|
+
effectiveSizeOf(index: number): number;
|
|
88
|
+
/** Set the size of an index. O(log n). */
|
|
89
|
+
resize(index: number, size: number): void;
|
|
90
|
+
/** Whether any size was ever set (else every size is the default and nothing is hidden). */
|
|
91
|
+
get customized(): boolean;
|
|
92
|
+
/** Whether any index is hidden. */
|
|
93
|
+
get hasHidden(): boolean;
|
|
94
|
+
isHidden(index: number): boolean;
|
|
95
|
+
setHidden(index: number, hidden: boolean): void;
|
|
96
|
+
/** The offset of an index's start: the sum of the effective sizes before it. O(log n). */
|
|
97
|
+
offsetOf(index: number): number;
|
|
98
|
+
/** The total extent of the axis. */
|
|
99
|
+
get extent(): number;
|
|
100
|
+
/** The index under an offset: the last index whose start is at or before it. O(log n). */
|
|
101
|
+
indexAt(offset: number): number;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=axis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/core/axis.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AAEH,yDAAyD;AACzD,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,yEAAyE;AACzE,eAAO,MAAM,UAAU,QAAU,CAAC;AAElC,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,IAAI;;IACf,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAcjB,OAAO,EAAE,WAAW;IAehC,oDAAoD;IACpD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM3B;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,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