@datalayer/cells 0.0.1 → 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.
Files changed (45) hide show
  1. package/lib/core/axis.d.ts +6 -0
  2. package/lib/core/axis.d.ts.map +1 -1
  3. package/lib/core/axis.js +46 -7
  4. package/lib/core/axis.js.map +1 -1
  5. package/lib/core/commands.d.ts +157 -0
  6. package/lib/core/commands.d.ts.map +1 -0
  7. package/lib/core/commands.js +620 -0
  8. package/lib/core/commands.js.map +1 -0
  9. package/lib/core/format.d.ts +52 -0
  10. package/lib/core/format.d.ts.map +1 -0
  11. package/lib/core/format.js +264 -0
  12. package/lib/core/format.js.map +1 -0
  13. package/lib/core/history.d.ts +42 -0
  14. package/lib/core/history.d.ts.map +1 -0
  15. package/lib/core/history.js +63 -0
  16. package/lib/core/history.js.map +1 -0
  17. package/lib/core/index.d.ts +17 -2
  18. package/lib/core/index.d.ts.map +1 -1
  19. package/lib/core/index.js +22 -1
  20. package/lib/core/index.js.map +1 -1
  21. package/lib/core/model.d.ts +116 -0
  22. package/lib/core/model.d.ts.map +1 -0
  23. package/lib/core/model.js +330 -0
  24. package/lib/core/model.js.map +1 -0
  25. package/lib/core/patches.d.ts +140 -0
  26. package/lib/core/patches.d.ts.map +1 -0
  27. package/lib/core/patches.js +272 -0
  28. package/lib/core/patches.js.map +1 -0
  29. package/lib/core/reactor.d.ts +24 -0
  30. package/lib/core/reactor.d.ts.map +1 -0
  31. package/lib/core/reactor.js +48 -0
  32. package/lib/core/reactor.js.map +1 -0
  33. package/lib/core/selection.d.ts +81 -0
  34. package/lib/core/selection.d.ts.map +1 -0
  35. package/lib/core/selection.js +175 -0
  36. package/lib/core/selection.js.map +1 -0
  37. package/lib/core/workbook.d.ts +59 -0
  38. package/lib/core/workbook.d.ts.map +1 -0
  39. package/lib/core/workbook.js +101 -0
  40. package/lib/core/workbook.js.map +1 -0
  41. package/lib/points/index.d.ts +154 -0
  42. package/lib/points/index.d.ts.map +1 -0
  43. package/lib/points/index.js +50 -0
  44. package/lib/points/index.js.map +1 -0
  45. package/package.json +2 -1
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The persisted state of a workbook: sheets, their axes and cells, merges and
3
+ * frozen panes, and the pools cells reference (strings, styles, formulas).
4
+ * Only patches write it (core/patches); the model reads it through getters.
5
+ *
6
+ * @module core/workbook
7
+ */
8
+ import { Axis } from './axis.js';
9
+ import { FormulaTable, SheetCells } from './cells.js';
10
+ import { StringPool } from './strings.js';
11
+ import { StyleTable } from './styles.js';
12
+ import { type Zone } from './zone.js';
13
+ /** The size limits of a sheet. Excel's by default. */
14
+ export interface Limits {
15
+ readonly rows: number;
16
+ readonly cols: number;
17
+ readonly rowHeight: number;
18
+ readonly colWidth: number;
19
+ }
20
+ export declare const DEFAULT_LIMITS: Limits;
21
+ export interface Frozen {
22
+ readonly rows: number;
23
+ readonly cols: number;
24
+ }
25
+ export declare class Sheet {
26
+ readonly id: string;
27
+ name: string;
28
+ readonly rows: Axis;
29
+ readonly cols: Axis;
30
+ readonly cells: SheetCells;
31
+ /** Merged zones, disjoint. */
32
+ merges: Zone[];
33
+ frozen: Frozen;
34
+ constructor(id: string, name: string, limits: Limits, cells: SheetCells);
35
+ /** The merge holding a position, or `undefined`. */
36
+ mergeAt(row: number, col: number): Zone | undefined;
37
+ /** Merges overlapping a zone. */
38
+ mergesIn(zone: Zone): Zone[];
39
+ }
40
+ export declare class Workbook {
41
+ #private;
42
+ readonly limits: Limits;
43
+ readonly strings: StringPool;
44
+ readonly styles: StyleTable;
45
+ readonly formulas: FormulaTable;
46
+ /** In tab order. */
47
+ readonly sheets: Sheet[];
48
+ constructor(limits?: Limits);
49
+ /** A new, detached sheet with a fresh id; `ADD_SHEET` attaches it through a patch. */
50
+ createSheet(name: string, id?: string): Sheet;
51
+ /** The sheet of that id; throws a sentence naming the ids there are. */
52
+ sheet(id: string): Sheet;
53
+ hasSheet(id: string): boolean;
54
+ /** The sheet of that name, case-insensitively, as Excel matches names. */
55
+ sheetByName(name: string): Sheet | undefined;
56
+ /** A name no sheet has: `Sheet1`, `Sheet2`, … */
57
+ freshSheetName(): string;
58
+ }
59
+ //# sourceMappingURL=workbook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbook.d.ts","sourceRoot":"","sources":["../../src/core/workbook.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,EAAgB,MAAM,WAAW,CAAC;AAEpD,sDAAsD;AACtD,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,MAK5B,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,KAAK;IAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,8BAA8B;IAC9B,MAAM,EAAE,IAAI,EAAE,CAAM;IACpB,MAAM,EAAE,MAAM,CAAwB;gBAE1B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IAQvE,oDAAoD;IACpD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAMnD,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE;CAG7B;AAED,qBAAa,QAAQ;;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,aAAoB;IACpC,QAAQ,CAAC,MAAM,aAAoB;IACnC,QAAQ,CAAC,QAAQ,eAAsB;IACvC,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAM;gBAGlB,MAAM,GAAE,MAAuB;IAQ3C,sFAAsF;IACtF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK;IAY7C,wEAAwE;IACxE,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK;IAUxB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI7B,0EAA0E;IAC1E,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAK5C,iDAAiD;IACjD,cAAc,IAAI,MAAM;CAUzB"}
@@ -0,0 +1,101 @@
1
+ /*
2
+ * Copyright (c) 2022-2026 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * The persisted state of a workbook: sheets, their axes and cells, merges and
8
+ * frozen panes, and the pools cells reference (strings, styles, formulas).
9
+ * Only patches write it (core/patches); the model reads it through getters.
10
+ *
11
+ * @module core/workbook
12
+ */
13
+ import { Axis } from './axis.js';
14
+ import { FormulaTable, SheetCells } from './cells.js';
15
+ import { StringPool } from './strings.js';
16
+ import { StyleTable } from './styles.js';
17
+ import { zonesOverlap } from './zone.js';
18
+ export const DEFAULT_LIMITS = {
19
+ rows: 1_048_576,
20
+ cols: 16_384,
21
+ rowHeight: 21,
22
+ colWidth: 100,
23
+ };
24
+ export class Sheet {
25
+ id;
26
+ name;
27
+ rows;
28
+ cols;
29
+ cells;
30
+ /** Merged zones, disjoint. */
31
+ merges = [];
32
+ frozen = { rows: 0, cols: 0 };
33
+ constructor(id, name, limits, cells) {
34
+ this.id = id;
35
+ this.name = name;
36
+ this.rows = new Axis({ count: limits.rows, defaultSize: limits.rowHeight });
37
+ this.cols = new Axis({ count: limits.cols, defaultSize: limits.colWidth });
38
+ this.cells = cells;
39
+ }
40
+ /** The merge holding a position, or `undefined`. */
41
+ mergeAt(row, col) {
42
+ return this.merges.find((m) => row >= m.top && row <= m.bottom && col >= m.left && col <= m.right);
43
+ }
44
+ /** Merges overlapping a zone. */
45
+ mergesIn(zone) {
46
+ return this.merges.filter((m) => zonesOverlap(m, zone));
47
+ }
48
+ }
49
+ export class Workbook {
50
+ limits;
51
+ strings = new StringPool();
52
+ styles = new StyleTable();
53
+ formulas = new FormulaTable();
54
+ /** In tab order. */
55
+ sheets = [];
56
+ #nextSheet = 1;
57
+ constructor(limits = DEFAULT_LIMITS) {
58
+ for (const [key, value] of Object.entries(limits)) {
59
+ if (!(typeof value === 'number' && value > 0))
60
+ throw new Error(`limits.${key} must be positive; ${value} was given.`);
61
+ }
62
+ this.limits = limits;
63
+ }
64
+ /** A new, detached sheet with a fresh id; `ADD_SHEET` attaches it through a patch. */
65
+ createSheet(name, id) {
66
+ const sheetId = id ?? this.#freshSheetId();
67
+ if (this.sheets.some((s) => s.id === sheetId))
68
+ throw new Error(`A sheet with id '${sheetId}' exists already.`);
69
+ return new Sheet(sheetId, name, this.limits, new SheetCells({ strings: this.strings, formulas: this.formulas }));
70
+ }
71
+ /** The sheet of that id; throws a sentence naming the ids there are. */
72
+ sheet(id) {
73
+ const sheet = this.sheets.find((s) => s.id === id);
74
+ if (sheet === undefined) {
75
+ throw new Error(`No sheet '${id}'; the workbook has ${this.sheets.map((s) => s.id).join(', ') || 'none'}.`);
76
+ }
77
+ return sheet;
78
+ }
79
+ hasSheet(id) {
80
+ return this.sheets.some((s) => s.id === id);
81
+ }
82
+ /** The sheet of that name, case-insensitively, as Excel matches names. */
83
+ sheetByName(name) {
84
+ const lower = name.toLowerCase();
85
+ return this.sheets.find((s) => s.name.toLowerCase() === lower);
86
+ }
87
+ /** A name no sheet has: `Sheet1`, `Sheet2`, … */
88
+ freshSheetName() {
89
+ for (let i = 1;; i += 1)
90
+ if (this.sheetByName(`Sheet${i}`) === undefined)
91
+ return `Sheet${i}`;
92
+ }
93
+ #freshSheetId() {
94
+ for (;;) {
95
+ const id = `s${this.#nextSheet++}`;
96
+ if (!this.hasSheet(id))
97
+ return id;
98
+ }
99
+ }
100
+ }
101
+ //# sourceMappingURL=workbook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbook.js","sourceRoot":"","sources":["../../src/core/workbook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAa,YAAY,EAAE,MAAM,WAAW,CAAC;AAUpD,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,GAAG;CACd,CAAC;AAOF,MAAM,OAAO,KAAK;IACP,EAAE,CAAS;IACpB,IAAI,CAAS;IACJ,IAAI,CAAO;IACX,IAAI,CAAO;IACX,KAAK,CAAa;IAC3B,8BAA8B;IAC9B,MAAM,GAAW,EAAE,CAAC;IACpB,MAAM,GAAW,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE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C3F,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,0EAA0E;IAC1E,WAAW,CAAC,IAAY;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC;IACjE,CAAC;IAED,iDAAiD;IACjD,cAAc;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;YAAE,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,SAAS;gBAAE,OAAO,QAAQ,CAAC,EAAE,CAAC;IAChG,CAAC;IAED,aAAa;QACX,SAAS,CAAC;YACR,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAAE,OAAO,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,154 @@
1
+ import type { CommandContext, CommandResult } from '../core/commands.js';
2
+ import type { Patch, PatchOp } from '../core/patches.js';
3
+ import type { Style } from '../core/styles.js';
4
+ import type { CellValue } from '../core/values.js';
5
+ import type { Zone } from '../core/zone.js';
6
+ export type { PatchOp } from '../core/patches.js';
7
+ /** A command handler: refuses with reasons, or turns a command into patches. */
8
+ export interface CommandHandler<C extends {
9
+ type: string;
10
+ } = {
11
+ type: string;
12
+ } & Record<string, unknown>> {
13
+ readonly type: C['type'];
14
+ /** Refusals with reasons; omitted means always allowed. */
15
+ allow?(context: CommandContext, command: C): CommandResult;
16
+ /** The patches that perform the command, computed from the current state; applied in order. */
17
+ apply(context: CommandContext, command: C): Patch[];
18
+ /** F4 when not editing: the same command at a new selection (§3.2). */
19
+ repeat?(command: C, selection: {
20
+ sheet: string;
21
+ zones: readonly Zone[];
22
+ }): C | undefined;
23
+ }
24
+ /** An argument of a formula function, as autocomplete and the compiler read it. */
25
+ export interface FunctionArgument {
26
+ readonly name: string;
27
+ readonly type: 'scalar' | 'range' | 'lazy';
28
+ readonly optional?: boolean;
29
+ readonly repeating?: boolean;
30
+ readonly description?: string;
31
+ }
32
+ /** A formula function (§3.4). The engine's calling convention lands with the compiler (C4-02). */
33
+ export interface FormulaFunction {
34
+ /** Upper-case, as typed: `SUM`, `XLOOKUP`. */
35
+ readonly name: string;
36
+ readonly args: readonly FunctionArgument[];
37
+ readonly returns: 'number' | 'string' | 'boolean' | 'any';
38
+ readonly compute: (...args: unknown[]) => CellValue | Promise<CellValue>;
39
+ readonly volatile?: boolean;
40
+ readonly async?: boolean;
41
+ readonly description: string;
42
+ readonly examples: readonly string[];
43
+ }
44
+ /** A cell type drawn on canvas: a checkbox, a link, a progress bar. */
45
+ export interface CellType {
46
+ readonly id: string;
47
+ render(ctx: CanvasRenderingContext2D, rect: {
48
+ x: number;
49
+ y: number;
50
+ width: number;
51
+ height: number;
52
+ }, value: CellValue, style: Style, theme: Readonly<Record<string, unknown>>): void;
53
+ hitTest?(point: {
54
+ x: number;
55
+ y: number;
56
+ }, rect: {
57
+ width: number;
58
+ height: number;
59
+ }): boolean;
60
+ onClick?(cell: {
61
+ sheet: string;
62
+ row: number;
63
+ col: number;
64
+ }, value: CellValue): Patch[] | void;
65
+ /** A React component editing this type; typed loosely so the core needs no React. */
66
+ readonly editor?: unknown;
67
+ accessibleName?(value: CellValue): string;
68
+ }
69
+ /** A render layer, drawn after the core layers of the same kind (§3.3). */
70
+ export interface RenderLayer {
71
+ readonly id: string;
72
+ readonly layer: 'background' | 'cells' | 'overlay';
73
+ draw(ctx: CanvasRenderingContext2D, viewport: {
74
+ sheet: string;
75
+ zone: Zone;
76
+ }, model: unknown): void;
77
+ }
78
+ /** A clipboard handler: one per feature (§3.5). */
79
+ export interface ClipboardHandler {
80
+ readonly id: string;
81
+ copy(context: CommandContext, zone: Zone): unknown;
82
+ paste(context: CommandContext, slice: unknown, target: Zone, options: {
83
+ special?: string;
84
+ }): Patch[];
85
+ }
86
+ /** A fill-handle series rule (§3.5). */
87
+ export interface FillRule {
88
+ readonly id: string;
89
+ match(values: readonly CellValue[]): unknown | undefined;
90
+ next(series: unknown, index: number): CellValue;
91
+ }
92
+ /** Reads a file format into the native format (`CellsWorkbook`). */
93
+ export interface Importer {
94
+ readonly id: string;
95
+ readonly mime: string;
96
+ readonly extensions: readonly string[];
97
+ read(input: ReadableStream<Uint8Array> | Uint8Array | string): Promise<unknown>;
98
+ }
99
+ /** Writes a workbook out. */
100
+ export interface Exporter {
101
+ readonly id: string;
102
+ readonly mime: string;
103
+ readonly extension: string;
104
+ write(model: unknown): Promise<Blob | Uint8Array | string>;
105
+ }
106
+ /** A read-only, paged virtual source of columns (§3.11). */
107
+ export interface DataSource {
108
+ readonly id: string;
109
+ readonly rowCount: number;
110
+ readonly columns: readonly {
111
+ readonly name: string;
112
+ readonly type?: string;
113
+ }[];
114
+ fetch(rows: {
115
+ from: number;
116
+ to: number;
117
+ }): Promise<readonly (readonly CellValue[])[]>;
118
+ }
119
+ /** The collaboration provider: exactly one, or none for "collaboration off" (§3.9). */
120
+ export interface CollabProvider {
121
+ readonly id: string;
122
+ connect(doc: unknown, room: string): unknown;
123
+ }
124
+ /** A toolbar or menu entry, naming a Reactor command by id. */
125
+ export interface CommandItem {
126
+ readonly command: string;
127
+ readonly group?: string;
128
+ }
129
+ export declare const CellsPatchOps: import("@datalayer/reactor").ContributionPoint<PatchOp<any>>;
130
+ export declare const CellsCommands: import("@datalayer/reactor").ContributionPoint<CommandHandler<any>>;
131
+ export declare const CellsFunctions: import("@datalayer/reactor").ContributionPoint<FormulaFunction>;
132
+ export declare const CellsCellTypes: import("@datalayer/reactor").ContributionPoint<CellType>;
133
+ export declare const CellsRenderLayers: import("@datalayer/reactor").ContributionPoint<RenderLayer>;
134
+ export declare const CellsClipboard: import("@datalayer/reactor").ContributionPoint<ClipboardHandler>;
135
+ export declare const CellsFillRules: import("@datalayer/reactor").ContributionPoint<FillRule>;
136
+ export declare const CellsImporters: import("@datalayer/reactor").ContributionPoint<Importer>;
137
+ export declare const CellsExporters: import("@datalayer/reactor").ContributionPoint<Exporter>;
138
+ export declare const CellsDataSources: import("@datalayer/reactor").ContributionPoint<DataSource>;
139
+ export declare const CellsCollabProvider: import("@datalayer/reactor").ContributionPoint<CollabProvider>;
140
+ export declare const CellsToolbarItems: import("@datalayer/reactor").ContributionPoint<CommandItem>;
141
+ export declare const CellsMenuItems: import("@datalayer/reactor").ContributionPoint<CommandItem>;
142
+ /** What an edit gate is asked about: may this command apply? */
143
+ export interface EditGateContext {
144
+ readonly command: {
145
+ readonly type: string;
146
+ };
147
+ readonly context: CommandContext;
148
+ }
149
+ /** A plugin may veto a command before it applies; the veto is a refusal with the gate's reason. */
150
+ export declare const CellsEditGate: import("@datalayer/reactor").Gate<EditGateContext>;
151
+ /** Every point Cells opens, as `CellsCorePlugin` declares them. */
152
+ export declare const CELLS_POINTS: readonly [import("@datalayer/reactor").ContributionPoint<PatchOp<any>>, import("@datalayer/reactor").ContributionPoint<CommandHandler<any>>, import("@datalayer/reactor").ContributionPoint<FormulaFunction>, import("@datalayer/reactor").ContributionPoint<CellType>, import("@datalayer/reactor").ContributionPoint<RenderLayer>, import("@datalayer/reactor").ContributionPoint<ClipboardHandler>, import("@datalayer/reactor").ContributionPoint<FillRule>, import("@datalayer/reactor").ContributionPoint<Importer>, import("@datalayer/reactor").ContributionPoint<Exporter>, import("@datalayer/reactor").ContributionPoint<DataSource>, import("@datalayer/reactor").ContributionPoint<CollabProvider>, import("@datalayer/reactor").ContributionPoint<CommandItem>, import("@datalayer/reactor").ContributionPoint<CommandItem>, import("@datalayer/reactor").Gate<EditGateContext>];
153
+ export { PointTable, firstContribution, optionalContribution, type CellsPlatform, type PointTableOptions, type Resolved, } from './resolve.js';
154
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/points/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,gFAAgF;AAChF,MAAM,WAAW,cAAc,CAC7B,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEvE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACzB,2DAA2D;IAC3D,KAAK,CAAC,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,GAAG,aAAa,CAAC;IAC3D,+FAA+F;IAC/F,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC;IACpD,uEAAuE;IACvE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;KAAE,GAAG,CAAC,GAAG,SAAS,CA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K,iBAAiB,EACtB,KAAK,QAAQ,GACd,MAAM,cAAc,CAAC"}
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright (c) 2022-2026 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * The Reactor contribution points of Cells, and what each takes.
8
+ *
9
+ * Every extension of Cells is a contribution to one of these points, from a
10
+ * Reactor plugin (`definePlugin` from `@datalayer/reactor`); the built-in
11
+ * features contribute through the same points. The ids are the contract
12
+ * between plugins: `datalayer.cells.*`.
13
+ *
14
+ * @module points
15
+ */
16
+ import { defineContributionPoint, defineGate } from '@datalayer/reactor';
17
+ export const CellsPatchOps = defineContributionPoint('datalayer.cells.patchOp');
18
+ export const CellsCommands = defineContributionPoint('datalayer.cells.command');
19
+ export const CellsFunctions = defineContributionPoint('datalayer.cells.function');
20
+ export const CellsCellTypes = defineContributionPoint('datalayer.cells.cellType');
21
+ export const CellsRenderLayers = defineContributionPoint('datalayer.cells.renderLayer');
22
+ export const CellsClipboard = defineContributionPoint('datalayer.cells.clipboard');
23
+ export const CellsFillRules = defineContributionPoint('datalayer.cells.fillRule');
24
+ export const CellsImporters = defineContributionPoint('datalayer.cells.importer');
25
+ export const CellsExporters = defineContributionPoint('datalayer.cells.exporter');
26
+ export const CellsDataSources = defineContributionPoint('datalayer.cells.dataSource');
27
+ export const CellsCollabProvider = defineContributionPoint('datalayer.cells.collabProvider');
28
+ export const CellsToolbarItems = defineContributionPoint('datalayer.cells.toolbarItem');
29
+ export const CellsMenuItems = defineContributionPoint('datalayer.cells.menuItem');
30
+ /** A plugin may veto a command before it applies; the veto is a refusal with the gate's reason. */
31
+ export const CellsEditGate = defineGate('datalayer.cells.gate.edit');
32
+ /** Every point Cells opens, as `CellsCorePlugin` declares them. */
33
+ export const CELLS_POINTS = [
34
+ CellsPatchOps,
35
+ CellsCommands,
36
+ CellsFunctions,
37
+ CellsCellTypes,
38
+ CellsRenderLayers,
39
+ CellsClipboard,
40
+ CellsFillRules,
41
+ CellsImporters,
42
+ CellsExporters,
43
+ CellsDataSources,
44
+ CellsCollabProvider,
45
+ CellsToolbarItems,
46
+ CellsMenuItems,
47
+ CellsEditGate,
48
+ ];
49
+ export { PointTable, firstContribution, optionalContribution, } from './resolve.js';
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/points/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA+HzE,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAe,yBAAyB,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,aAAa,GACxB,uBAAuB,CAAsB,yBAAyB,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAkB,0BAA0B,CAAC,CAAC;AACnG,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAW,0BAA0B,CAAC,CAAC;AAC5F,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CACtD,6BAA6B,CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CACnD,2BAA2B,CAC5B,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAW,0BAA0B,CAAC,CAAC;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAW,0BAA0B,CAAC,CAAC;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAW,0BAA0B,CAAC,CAAC;AAC5F,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAa,4BAA4B,CAAC,CAAC;AAClG,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CACxD,gCAAgC,CACjC,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CACtD,6BAA6B,CAC9B,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAc,0BAA0B,CAAC,CAAC;AAQ/F,mGAAmG;AACnG,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAkB,2BAA2B,CAAC,CAAC;AAEtF,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,mBAAmB;IACnB,iBAAiB;IACjB,cAAc;IACd,aAAa;CACL,CAAC;AAEX,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,oBAAoB,GAIrB,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/cells",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/datalayer/cells.git"
@@ -101,6 +101,7 @@
101
101
  "react-dom": "^18.3.1 || ^19.0.0"
102
102
  },
103
103
  "devDependencies": {
104
+ "@datalayer/reactor": "^1.3.2",
104
105
  "@playwright/test": "^1.56.0",
105
106
  "@types/node": "^24",
106
107
  "@types/react": "19.2.18",