@ai-matrx/office 0.8.11 → 0.8.13
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/CHANGELOG.md +5 -1
- package/dist/collab-sheets-transform.cjs +457 -39
- package/dist/collab-sheets-transform.cjs.map +1 -1
- package/dist/collab-sheets-transform.d.cts +65 -7
- package/dist/collab-sheets-transform.d.ts +65 -7
- package/dist/collab-sheets-transform.js +463 -36
- package/dist/collab-sheets-transform.js.map +1 -1
- package/dist/docs.cjs +35 -21
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.cts +32 -2
- package/dist/docs.d.ts +32 -2
- package/dist/docs.js +16 -2
- package/dist/docs.js.map +1 -1
- package/dist/univer-collab.cjs +201 -5
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +71 -2
- package/dist/univer-collab.d.ts +71 -2
- package/dist/univer-collab.js +201 -5
- package/dist/univer-collab.js.map +1 -1
- package/dist/univer.cjs +4 -0
- package/dist/univer.cjs.map +1 -1
- package/dist/univer.d.cts +3 -1
- package/dist/univer.d.ts +3 -1
- package/dist/univer.js +4 -0
- package/dist/univer.js.map +1 -1
- package/package.json +5 -5
|
@@ -42,9 +42,10 @@ interface SheetRange {
|
|
|
42
42
|
* `census.test.ts` fails when an emitted id is missing or a declared id is stale.
|
|
43
43
|
*
|
|
44
44
|
* Covered in C5a: cell values and styles, row/column insert, remove and move, merge/unmerge, row height,
|
|
45
|
-
* column width, worksheet name.
|
|
45
|
+
* column width, worksheet name. C5b: formula text in cells (`f`, array `ref`) and defined names. Shared
|
|
46
|
+
* formulas (`si`) stay barriers (see transform.ts cellBarrier); ranged resources are C5c.
|
|
46
47
|
*/
|
|
47
|
-
type SheetFamily = "cell" | "structure" | "merge" | "size" | "name";
|
|
48
|
+
type SheetFamily = "cell" | "structure" | "merge" | "size" | "name" | "defname";
|
|
48
49
|
interface CoveredEntry {
|
|
49
50
|
readonly kind: "covered";
|
|
50
51
|
readonly family: SheetFamily;
|
|
@@ -57,8 +58,8 @@ interface NeverEntry {
|
|
|
57
58
|
}
|
|
58
59
|
interface BarrierEntry {
|
|
59
60
|
readonly kind: "barrier";
|
|
60
|
-
/** The unit that owns its transform (
|
|
61
|
-
readonly until: "
|
|
61
|
+
/** The unit that owns its transform (C5c resources) or "X" (no unit yet). */
|
|
62
|
+
readonly until: "C5c" | "X";
|
|
62
63
|
readonly reason: string;
|
|
63
64
|
}
|
|
64
65
|
type RegistryEntry = CoveredEntry | NeverEntry | BarrierEntry;
|
|
@@ -102,7 +103,7 @@ declare function mapIndex(op: AxisOp, i: number): number | null;
|
|
|
102
103
|
*/
|
|
103
104
|
declare function transformAxis(x: AxisOp, y: AxisOp, side: Side): AxisOp[] | null;
|
|
104
105
|
|
|
105
|
-
declare const SHEET_TRANSFORMER_VERSION = "
|
|
106
|
+
declare const SHEET_TRANSFORMER_VERSION = "c5b-1";
|
|
106
107
|
/**
|
|
107
108
|
* Pairs the fuzz proved divergent (or that have no transform yet), as unordered mutation-id pairs, with the
|
|
108
109
|
* failing seed. Each returns a Barrier until it has its own correct transform under a new proto.
|
|
@@ -133,13 +134,24 @@ declare function mergeThrough(s: Structural, m: SheetRange): {
|
|
|
133
134
|
declare function exactMergeRemovals(group: SheetGroup, merges: Readonly<Record<string, readonly SheetRange[]>>): SheetMutation[];
|
|
134
135
|
type Cell = Record<string, unknown> | null;
|
|
135
136
|
/** The content slot of a cell. A traveling entry that touches content must carry all of them (see completeCellContent). */
|
|
136
|
-
declare const CONTENT_KEYS: readonly ["v", "t", "p", "f", "si", "custom"];
|
|
137
|
+
declare const CONTENT_KEYS: readonly ["v", "t", "p", "f", "si", "custom", "ref", "xf", "ft", "fd"];
|
|
137
138
|
/**
|
|
138
139
|
* Completes a captured cell entry's content slot from the sender's post-state, so content writes are full
|
|
139
140
|
* replacements (an entry that sets `v` alone would otherwise keep a stale `p` on some seats). C6's capture
|
|
140
141
|
* calls this per touched cell with the cell as it stands right after the command.
|
|
141
142
|
*/
|
|
142
143
|
declare function completeCellContent(entry: Cell, post: Record<string, unknown> | null | undefined): Cell;
|
|
144
|
+
/** Params that travel for the transformer only; `forApply` strips them before Univer sees the mutation. */
|
|
145
|
+
declare const SIDE_CAR_PARAMS: readonly ["refSheets", "previousName", "derived"];
|
|
146
|
+
declare function forApply(m: SheetMutation): SheetMutation;
|
|
147
|
+
/**
|
|
148
|
+
* Capture-time annotation (C6 calls it per group, like completeCellContent): every op whose formula text
|
|
149
|
+
* qualifies a reference with a sheet name gets `refSheets`, and every set-defined-name gets `previousName`
|
|
150
|
+
* (the name its id had before the command; null for a new name). Rewrites that follow a structural op, a
|
|
151
|
+
* rename or a defined-name change in the same group are marked `derived`. `sheets` is sheet id → name and
|
|
152
|
+
* `definedNames` defined-name id → name, both read right before the command ran.
|
|
153
|
+
*/
|
|
154
|
+
declare function annotateFormulas(group: SheetGroup, sheets: Readonly<Record<string, string>>, definedNames: Readonly<Record<string, string>>): SheetMutation[];
|
|
143
155
|
/** x over y for single mutations. */
|
|
144
156
|
declare function transformMutation(x: SheetMutation, y: SheetMutation, side: Side): TransformResult;
|
|
145
157
|
/** Command group x rewritten to apply after command group y. One Barrier makes the whole group a barrier. */
|
|
@@ -156,4 +168,50 @@ declare const sheetTransformer: {
|
|
|
156
168
|
isNoop(op: SheetGroup): boolean;
|
|
157
169
|
};
|
|
158
170
|
|
|
159
|
-
|
|
171
|
+
/** Sheet name → sheet id (null: the name is no sheet of this workbook). */
|
|
172
|
+
type RefSheets = Readonly<Record<string, string | null>>;
|
|
173
|
+
/** What changed under a formula: rows/columns of one sheet, or one sheet's name. */
|
|
174
|
+
type RefChange = {
|
|
175
|
+
readonly kind: "axis";
|
|
176
|
+
readonly sheet: string;
|
|
177
|
+
readonly axis: Axis;
|
|
178
|
+
readonly op: AxisOp;
|
|
179
|
+
} | {
|
|
180
|
+
readonly kind: "rename";
|
|
181
|
+
readonly sheet: string;
|
|
182
|
+
readonly name: string;
|
|
183
|
+
} | {
|
|
184
|
+
readonly kind: "defined-name";
|
|
185
|
+
readonly from: string;
|
|
186
|
+
readonly to: string | null;
|
|
187
|
+
};
|
|
188
|
+
interface FormulaCtx {
|
|
189
|
+
/** The sheet the formula lives in (its unqualified references point here). */
|
|
190
|
+
readonly ownSheet: string;
|
|
191
|
+
readonly refSheets: RefSheets | undefined;
|
|
192
|
+
/** Defined names keep the sheet qualifier of a moved reference (sheets-formula `preserveSheetQualifier`). */
|
|
193
|
+
readonly keepQualifier?: boolean;
|
|
194
|
+
}
|
|
195
|
+
declare const REF_ERROR = "#REF!";
|
|
196
|
+
declare const isFormulaText: (f: unknown) => f is string;
|
|
197
|
+
/** Why a formula cannot be transformed (null = it can). */
|
|
198
|
+
declare function formulaBarrier(text: string, ctx: FormulaCtx): string | null;
|
|
199
|
+
interface Rewritten {
|
|
200
|
+
readonly text: string;
|
|
201
|
+
readonly changed: boolean;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The formula (or defined-name ref string) after `change`, exactly as Univer rewrites it: every reference into
|
|
205
|
+
* the changed sheet moves (or becomes #REF!), and once anything changed every other reference is re-serialized
|
|
206
|
+
* (`updateRefOffset`). Returns a reason string when the text cannot be transformed.
|
|
207
|
+
*/
|
|
208
|
+
declare function rewriteFormula(text: string, ctx: FormulaCtx, change: RefChange): Rewritten | string;
|
|
209
|
+
/**
|
|
210
|
+
* An op's `refSheets` after a rename: the renamed sheet answers to its new name only, and a name that was
|
|
211
|
+
* no sheet before now names it. Unchanged (same object) when the rename touches nothing it lists.
|
|
212
|
+
*/
|
|
213
|
+
declare function refSheetsAfter(refSheets: RefSheets | undefined, change: RefChange): RefSheets | undefined;
|
|
214
|
+
/** `refSheets` for the given formula texts: every sheet name they qualify a reference with, resolved now. */
|
|
215
|
+
declare function refSheetsFor(texts: Iterable<string>, sheets: Readonly<Record<string, string>>): RefSheets | undefined;
|
|
216
|
+
|
|
217
|
+
export { type Axis, type AxisOp, type Barrier, type BarrierEntry, CONTENT_KEYS, type CoveredEntry, type FormulaCtx, type NeverEntry, PAIR_BARRIERS, REF_ERROR, type RefChange, type RefSheets, type RegistryEntry, type Rewritten, SHEET_MUTATIONS, SHEET_TRANSFORMER_VERSION, SIDE_CAR_PARAMS, type SheetFamily, type SheetGroup, type SheetMutation, type SheetRange, type Side, type TransformResult, type Transformed, allowParams, annotateFormulas, cellRef, completeCellContent, exactMergeRemovals, forApply, formulaBarrier, isBarrier, isFormulaText, mapIndex, mergeThrough, refSheetsAfter, refSheetsFor, rewriteFormula, sheetTransformer, transformAxis, transformGroup, transformMutation };
|
|
@@ -42,9 +42,10 @@ interface SheetRange {
|
|
|
42
42
|
* `census.test.ts` fails when an emitted id is missing or a declared id is stale.
|
|
43
43
|
*
|
|
44
44
|
* Covered in C5a: cell values and styles, row/column insert, remove and move, merge/unmerge, row height,
|
|
45
|
-
* column width, worksheet name.
|
|
45
|
+
* column width, worksheet name. C5b: formula text in cells (`f`, array `ref`) and defined names. Shared
|
|
46
|
+
* formulas (`si`) stay barriers (see transform.ts cellBarrier); ranged resources are C5c.
|
|
46
47
|
*/
|
|
47
|
-
type SheetFamily = "cell" | "structure" | "merge" | "size" | "name";
|
|
48
|
+
type SheetFamily = "cell" | "structure" | "merge" | "size" | "name" | "defname";
|
|
48
49
|
interface CoveredEntry {
|
|
49
50
|
readonly kind: "covered";
|
|
50
51
|
readonly family: SheetFamily;
|
|
@@ -57,8 +58,8 @@ interface NeverEntry {
|
|
|
57
58
|
}
|
|
58
59
|
interface BarrierEntry {
|
|
59
60
|
readonly kind: "barrier";
|
|
60
|
-
/** The unit that owns its transform (
|
|
61
|
-
readonly until: "
|
|
61
|
+
/** The unit that owns its transform (C5c resources) or "X" (no unit yet). */
|
|
62
|
+
readonly until: "C5c" | "X";
|
|
62
63
|
readonly reason: string;
|
|
63
64
|
}
|
|
64
65
|
type RegistryEntry = CoveredEntry | NeverEntry | BarrierEntry;
|
|
@@ -102,7 +103,7 @@ declare function mapIndex(op: AxisOp, i: number): number | null;
|
|
|
102
103
|
*/
|
|
103
104
|
declare function transformAxis(x: AxisOp, y: AxisOp, side: Side): AxisOp[] | null;
|
|
104
105
|
|
|
105
|
-
declare const SHEET_TRANSFORMER_VERSION = "
|
|
106
|
+
declare const SHEET_TRANSFORMER_VERSION = "c5b-1";
|
|
106
107
|
/**
|
|
107
108
|
* Pairs the fuzz proved divergent (or that have no transform yet), as unordered mutation-id pairs, with the
|
|
108
109
|
* failing seed. Each returns a Barrier until it has its own correct transform under a new proto.
|
|
@@ -133,13 +134,24 @@ declare function mergeThrough(s: Structural, m: SheetRange): {
|
|
|
133
134
|
declare function exactMergeRemovals(group: SheetGroup, merges: Readonly<Record<string, readonly SheetRange[]>>): SheetMutation[];
|
|
134
135
|
type Cell = Record<string, unknown> | null;
|
|
135
136
|
/** The content slot of a cell. A traveling entry that touches content must carry all of them (see completeCellContent). */
|
|
136
|
-
declare const CONTENT_KEYS: readonly ["v", "t", "p", "f", "si", "custom"];
|
|
137
|
+
declare const CONTENT_KEYS: readonly ["v", "t", "p", "f", "si", "custom", "ref", "xf", "ft", "fd"];
|
|
137
138
|
/**
|
|
138
139
|
* Completes a captured cell entry's content slot from the sender's post-state, so content writes are full
|
|
139
140
|
* replacements (an entry that sets `v` alone would otherwise keep a stale `p` on some seats). C6's capture
|
|
140
141
|
* calls this per touched cell with the cell as it stands right after the command.
|
|
141
142
|
*/
|
|
142
143
|
declare function completeCellContent(entry: Cell, post: Record<string, unknown> | null | undefined): Cell;
|
|
144
|
+
/** Params that travel for the transformer only; `forApply` strips them before Univer sees the mutation. */
|
|
145
|
+
declare const SIDE_CAR_PARAMS: readonly ["refSheets", "previousName", "derived"];
|
|
146
|
+
declare function forApply(m: SheetMutation): SheetMutation;
|
|
147
|
+
/**
|
|
148
|
+
* Capture-time annotation (C6 calls it per group, like completeCellContent): every op whose formula text
|
|
149
|
+
* qualifies a reference with a sheet name gets `refSheets`, and every set-defined-name gets `previousName`
|
|
150
|
+
* (the name its id had before the command; null for a new name). Rewrites that follow a structural op, a
|
|
151
|
+
* rename or a defined-name change in the same group are marked `derived`. `sheets` is sheet id → name and
|
|
152
|
+
* `definedNames` defined-name id → name, both read right before the command ran.
|
|
153
|
+
*/
|
|
154
|
+
declare function annotateFormulas(group: SheetGroup, sheets: Readonly<Record<string, string>>, definedNames: Readonly<Record<string, string>>): SheetMutation[];
|
|
143
155
|
/** x over y for single mutations. */
|
|
144
156
|
declare function transformMutation(x: SheetMutation, y: SheetMutation, side: Side): TransformResult;
|
|
145
157
|
/** Command group x rewritten to apply after command group y. One Barrier makes the whole group a barrier. */
|
|
@@ -156,4 +168,50 @@ declare const sheetTransformer: {
|
|
|
156
168
|
isNoop(op: SheetGroup): boolean;
|
|
157
169
|
};
|
|
158
170
|
|
|
159
|
-
|
|
171
|
+
/** Sheet name → sheet id (null: the name is no sheet of this workbook). */
|
|
172
|
+
type RefSheets = Readonly<Record<string, string | null>>;
|
|
173
|
+
/** What changed under a formula: rows/columns of one sheet, or one sheet's name. */
|
|
174
|
+
type RefChange = {
|
|
175
|
+
readonly kind: "axis";
|
|
176
|
+
readonly sheet: string;
|
|
177
|
+
readonly axis: Axis;
|
|
178
|
+
readonly op: AxisOp;
|
|
179
|
+
} | {
|
|
180
|
+
readonly kind: "rename";
|
|
181
|
+
readonly sheet: string;
|
|
182
|
+
readonly name: string;
|
|
183
|
+
} | {
|
|
184
|
+
readonly kind: "defined-name";
|
|
185
|
+
readonly from: string;
|
|
186
|
+
readonly to: string | null;
|
|
187
|
+
};
|
|
188
|
+
interface FormulaCtx {
|
|
189
|
+
/** The sheet the formula lives in (its unqualified references point here). */
|
|
190
|
+
readonly ownSheet: string;
|
|
191
|
+
readonly refSheets: RefSheets | undefined;
|
|
192
|
+
/** Defined names keep the sheet qualifier of a moved reference (sheets-formula `preserveSheetQualifier`). */
|
|
193
|
+
readonly keepQualifier?: boolean;
|
|
194
|
+
}
|
|
195
|
+
declare const REF_ERROR = "#REF!";
|
|
196
|
+
declare const isFormulaText: (f: unknown) => f is string;
|
|
197
|
+
/** Why a formula cannot be transformed (null = it can). */
|
|
198
|
+
declare function formulaBarrier(text: string, ctx: FormulaCtx): string | null;
|
|
199
|
+
interface Rewritten {
|
|
200
|
+
readonly text: string;
|
|
201
|
+
readonly changed: boolean;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The formula (or defined-name ref string) after `change`, exactly as Univer rewrites it: every reference into
|
|
205
|
+
* the changed sheet moves (or becomes #REF!), and once anything changed every other reference is re-serialized
|
|
206
|
+
* (`updateRefOffset`). Returns a reason string when the text cannot be transformed.
|
|
207
|
+
*/
|
|
208
|
+
declare function rewriteFormula(text: string, ctx: FormulaCtx, change: RefChange): Rewritten | string;
|
|
209
|
+
/**
|
|
210
|
+
* An op's `refSheets` after a rename: the renamed sheet answers to its new name only, and a name that was
|
|
211
|
+
* no sheet before now names it. Unchanged (same object) when the rename touches nothing it lists.
|
|
212
|
+
*/
|
|
213
|
+
declare function refSheetsAfter(refSheets: RefSheets | undefined, change: RefChange): RefSheets | undefined;
|
|
214
|
+
/** `refSheets` for the given formula texts: every sheet name they qualify a reference with, resolved now. */
|
|
215
|
+
declare function refSheetsFor(texts: Iterable<string>, sheets: Readonly<Record<string, string>>): RefSheets | undefined;
|
|
216
|
+
|
|
217
|
+
export { type Axis, type AxisOp, type Barrier, type BarrierEntry, CONTENT_KEYS, type CoveredEntry, type FormulaCtx, type NeverEntry, PAIR_BARRIERS, REF_ERROR, type RefChange, type RefSheets, type RegistryEntry, type Rewritten, SHEET_MUTATIONS, SHEET_TRANSFORMER_VERSION, SIDE_CAR_PARAMS, type SheetFamily, type SheetGroup, type SheetMutation, type SheetRange, type Side, type TransformResult, type Transformed, allowParams, annotateFormulas, cellRef, completeCellContent, exactMergeRemovals, forApply, formulaBarrier, isBarrier, isFormulaText, mapIndex, mergeThrough, refSheetsAfter, refSheetsFor, rewriteFormula, sheetTransformer, transformAxis, transformGroup, transformMutation };
|