@sheetxl/sdk 0.8.0-beta.6 → 0.8.0-beta.9

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 (115) hide show
  1. package/browser/cjs/BAtZ8a7H7zsRvWqe.cjs +90 -0
  2. package/browser/cjs/CQPMWBxBUmkORmxV.cjs +1 -0
  3. package/browser/cjs/{CMrcyRRWS0gjwpr2.cjs → CvQ1tIq7wZ7HIGPq.cjs} +1 -1
  4. package/browser/cjs/CwvGOe42j8KpAF0v.cjs +1 -0
  5. package/browser/cjs/{KMBs7XyoINajcR-L.cjs → DCOqoH-T4Ux_1dQj.cjs} +1 -1
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{7_M82_Otn5kHQ0qd.mjs → BdHD3v-u8irI1XhZ.mjs} +2 -2
  8. package/browser/esm/{DRsp6JAObqXYGvhz.mjs → C8btlUQcQwNyzHY3.mjs} +2 -2
  9. package/browser/esm/{CfoNUsKHL7SzfO8c.mjs → CF3VfWX7bJu8kO_Z.mjs} +2 -2
  10. package/browser/esm/{DBjWjEUK9qrHG5VD.mjs → D3ll0ybMQOP4uPyW.mjs} +1 -1
  11. package/browser/esm/{CEk-nufZXNFx5jDl.mjs → DXmFrSnh3xSBfoD7.mjs} +9233 -8740
  12. package/browser/esm/{iLZfKwfSx5bQgCOp.mjs → DzgIc4oyekwA-fkl.mjs} +96 -96
  13. package/browser/esm/{J1egfq2ajlXPw3Ki.mjs → Iw280tlGmTHKDqzd.mjs} +2 -2
  14. package/browser/esm/index.mjs +920 -593
  15. package/node/esm/{BMtLBfP7JzIsG9_G.mjs → B_FOXd5PSfVcg0ED.mjs} +1 -1
  16. package/node/esm/{CynxiHhVY9UGe_h6.mjs → BzgnLKSVfN-mrMSW.mjs} +1 -1
  17. package/node/esm/{DYRjFZ75QYgmgEWF.mjs → D4PsEIRHxAahp5kn.mjs} +1 -1
  18. package/node/esm/{DpyQm1VnGyCmRRKJ.mjs → dinqlP3jU8gDOjso.mjs} +1 -1
  19. package/node/esm/index.mjs +10520 -9698
  20. package/package.json +7 -6
  21. package/resources/locales/de/model.msg.json +19 -0
  22. package/resources/locales/en/model.msg.json +25 -0
  23. package/types/scripting-api.json +7337 -6890
  24. package/types/scripting-enums.json +101 -21
  25. package/types/scripting.d.ts +1961 -466
  26. package/types/src/calculation/Calculation.d.ts +37 -45
  27. package/types/src/calculation/grid/CalcGrid.d.ts +12 -4
  28. package/types/src/calculation/grid/CalcGridBackend.d.ts +0 -6
  29. package/types/src/calculation/grid/CalcGridProxy.d.ts +1 -6
  30. package/types/src/calculation/grid/ICalcGrid.d.ts +12 -4
  31. package/types/src/calculation/grid/_CalcRequest.d.ts +4 -9
  32. package/types/src/cell/ICell.d.ts +3 -3
  33. package/types/src/cell/ICellHeader.d.ts +24 -2
  34. package/types/src/cellRange/ICellRange.d.ts +67 -3
  35. package/types/src/cellRange/ICellRanges.d.ts +12 -12
  36. package/types/src/chart/Chart.d.ts +2 -13
  37. package/types/src/condition/AnchoredConditional.d.ts +2 -0
  38. package/types/src/condition/BuiltInOperators/ColorOperator.d.ts +4 -0
  39. package/types/src/condition/BuiltInOperators/IconOperator.d.ts +4 -0
  40. package/types/src/condition/ICondition.d.ts +36 -28
  41. package/types/src/condition/_ConditionUtils.d.ts +32 -8
  42. package/types/src/fill/IFill.d.ts +46 -11
  43. package/types/src/fill/IStroke.d.ts +34 -42
  44. package/types/src/filter/IFilter.d.ts +51 -6
  45. package/types/src/hyperlink/IHyperlink.d.ts +8 -0
  46. package/types/src/index.d.ts +1 -0
  47. package/types/src/movable/AbstractMovableContent.d.ts +6 -0
  48. package/types/src/movable/FormControl.d.ts +206 -0
  49. package/types/src/movable/IFormControl.d.ts +424 -0
  50. package/types/src/movable/IMovable.d.ts +37 -8
  51. package/types/src/movable/IMovableCollection.d.ts +19 -1
  52. package/types/src/movable/Movable.d.ts +20 -0
  53. package/types/src/movable/MovableContentRegistry.d.ts +64 -0
  54. package/types/src/movable/_BuiltInContents.d.ts +2 -0
  55. package/types/src/movable/_DrawnBounds.d.ts +33 -0
  56. package/types/src/movable/_RotatedFrame.d.ts +20 -0
  57. package/types/src/movable/index.d.ts +6 -4
  58. package/types/src/numFmt/BuiltInFormats.d.ts +5 -0
  59. package/types/src/numFmt/_NumFmtUtils.d.ts +0 -1
  60. package/types/src/numFmt/vendor/numfmt/_sheetxl.d.ts +6 -0
  61. package/types/src/outline/IOutline.d.ts +186 -0
  62. package/types/src/outline/Outline.d.ts +157 -0
  63. package/types/src/outline/index.d.ts +2 -0
  64. package/types/src/shape/GeometryPreset.d.ts +197 -0
  65. package/types/src/shape/IGeometry.d.ts +398 -0
  66. package/types/src/shape/IShape.d.ts +177 -204
  67. package/types/src/shape/Shape.d.ts +39 -13
  68. package/types/src/shape/ShapeStyleUtils.d.ts +48 -0
  69. package/types/src/shape/_Geometry.d.ts +14 -0
  70. package/types/src/shape/_GeometryLoader.d.ts +21 -0
  71. package/types/src/shape/_builtIn/_BuiltInChunks.d.ts +10 -0
  72. package/types/src/shape/_builtIn/_BuiltInDef.d.ts +9 -0
  73. package/types/src/shape/_builtIn/arrows.d.ts +6 -0
  74. package/types/src/shape/_builtIn/basic.d.ts +6 -0
  75. package/types/src/shape/_builtIn/callouts.d.ts +6 -0
  76. package/types/src/shape/_builtIn/flowchart.d.ts +6 -0
  77. package/types/src/shape/_builtIn/lines.d.ts +6 -0
  78. package/types/src/shape/_builtIn/math.d.ts +6 -0
  79. package/types/src/shape/_builtIn/other.d.ts +6 -0
  80. package/types/src/shape/_builtIn/rectangles.d.ts +6 -0
  81. package/types/src/shape/_builtIn/starsBanners.d.ts +6 -0
  82. package/types/src/shape/geometry/_strokeEnds.d.ts +7 -0
  83. package/types/src/shape/geometry/format.d.ts +3 -0
  84. package/types/src/shape/geometry/geometry.d.ts +84 -0
  85. package/types/src/shape/geometry/guides.d.ts +54 -0
  86. package/types/src/shape/geometry/handles.d.ts +14 -0
  87. package/types/src/shape/geometry/index.d.ts +7 -0
  88. package/types/src/shape/geometry/lineEnds.d.ts +53 -0
  89. package/types/src/shape/geometry/paths.d.ts +35 -0
  90. package/types/src/shape/geometry/segments.d.ts +114 -0
  91. package/types/src/shape/index.d.ts +2 -0
  92. package/types/src/sheet/ISheet.d.ts +10 -45
  93. package/types/src/sheet/Sheet.d.ts +19 -5
  94. package/types/src/sheet/SheetRange.d.ts +16 -1
  95. package/types/src/sheet/_SheetUtils.d.ts +10 -2
  96. package/types/src/sheetHeader/ISheetHeader.d.ts +4 -0
  97. package/types/src/sheetHeader/SheetCellHeader.d.ts +4 -0
  98. package/types/src/sheetHeader/SheetHeader.d.ts +10 -0
  99. package/types/src/sheetHeader/_HeaderUtils.d.ts +3 -1
  100. package/types/src/sheetView/ISheetView.d.ts +17 -0
  101. package/types/src/sheetView/SheetView.d.ts +4 -0
  102. package/types/src/table/AnchoredTable.d.ts +7 -2
  103. package/types/src/text/IText.d.ts +182 -0
  104. package/types/src/text/ITextFrame.d.ts +85 -0
  105. package/types/src/text/TextRotation.d.ts +3 -3
  106. package/types/src/text/TextStacked.d.ts +2 -2
  107. package/types/src/theme/ITheme.d.ts +24 -0
  108. package/types/src/workbook/Workbook.d.ts +16 -5
  109. package/browser/cjs/-wfVn4ubg563jjqj.cjs +0 -93
  110. package/browser/cjs/B2GVAGA-CBeu_7U4.cjs +0 -1
  111. package/browser/cjs/DFKGFVvoELb8_p_B.cjs +0 -1
  112. package/types/src/movable/Control.d.ts +0 -55
  113. package/types/src/movable/IControl.d.ts +0 -86
  114. package/types/src/movable/IGroup.d.ts +0 -30
  115. package/types/src/shape/_ShapeXml.d.ts +0 -28
@@ -1,13 +1,13 @@
1
- import { Point, Rectangle } from '@sheetxl/utils';
2
- import { IListener } from '../listener';
1
+ import { Bounds } from '@sheetxl/utils';
3
2
  import { ITransaction } from '../transaction';
4
3
  import { IResource } from '../resource';
5
4
  import { IModel } from '../model';
6
5
  import { IMovable } from '../movable';
7
6
  import { IHyperlink } from '../hyperlink';
8
- import { IFill } from '../fill';
9
- import { IStroke } from '../fill/IStroke';
10
- import { ITextFrame } from '../text/ITextFrame';
7
+ import { IStroke, IFill, IEffect } from '../fill';
8
+ import { ITheme } from '../theme';
9
+ import { ITextFrame } from '../text';
10
+ import { IGeometry } from './IGeometry';
11
11
  /**
12
12
  * A drawn shape: a text box, a callout, a rectangle, a connector, or a group of them.
13
13
  *
@@ -16,8 +16,8 @@ import { ITextFrame } from '../text/ITextFrame';
16
16
  * whose content type is `'shape'`. The movable carries the position; the shape carries what is
17
17
  * drawn there and what is written on it.
18
18
  *
19
- * Reading only: a shape's preset and its text. An imported shape is otherwise kept as the source
20
- * wrote it and saved back unchanged.
19
+ * Reading, and adjust values: a shape is JSON ({@link IShape.JSON}) that a file reads into and
20
+ * writes from; the editing API beyond `setAdjustments` is still to come.
21
21
  */
22
22
  export interface IShape extends IModel, IMovable.IContent {
23
23
  toJSON(toResourceId?: (resource: IResource) => number | null): IShape.JSON | null;
@@ -25,6 +25,12 @@ export interface IShape extends IModel, IMovable.IContent {
25
25
  * Returns the name of the shape.
26
26
  */
27
27
  getName(): string | null;
28
+ /**
29
+ * The image a resource id in this shape's JSON names: an image fill's `resId`, a picture
30
+ * member's among them, as {@link toJSON} with no scope names them. `null` when the shape holds
31
+ * no such resource.
32
+ */
33
+ getResource(resourceId: number): IResource | null;
28
34
  /**
29
35
  * Deletes the shape, and with it the movable that places it.
30
36
  */
@@ -33,8 +39,9 @@ export interface IShape extends IModel, IMovable.IContent {
33
39
  * Returns the kind of shape this is: its preset geometry.
34
40
  *
35
41
  * @remarks
36
- * A DrawingML preset id — `rect`, `borderCallout2`, `curvedConnector3` — or `'custom'` for a
37
- * shape drawn from its own path, or `'group'` for a group of shapes.
42
+ * A DrawingML preset id ({@link IGeometry.Preset}) — `rect`, `borderCallout2`, `curvedConnector3` —
43
+ * or `'custom'` for a shape drawn from its own path, or `'group'` for a group of shapes. A file
44
+ * may name a preset this SDK does not know; it is returned as the file states it.
38
45
  *
39
46
  * The preset says what a shape is for where its name does not: a callout annotates something,
40
47
  * a connector links two shapes, and a rectangle with no text is usually a box drawn around the
@@ -60,6 +67,48 @@ export interface IShape extends IModel, IMovable.IContent {
60
67
  * ```
61
68
  */
62
69
  getTextFrame(): ITextFrame.IText | null;
70
+ /**
71
+ * Returns the adjust values set on this shape, by name.
72
+ *
73
+ * @remarks
74
+ * A preset's handles move its adjust values — how rounded a `roundRect` is, where a callout
75
+ * points. Only values that differ from the preset's defaults are stored.
76
+ *
77
+ * The values are the geometry definition's own numbers (a ratio in 100,000ths, an angle in
78
+ * 60,000ths of a degree), opaque to a caller: a handle drag produces them through
79
+ * {@link IGeometry.adjustmentsFromHandle}, and a file reads and writes them as they are.
80
+ */
81
+ getAdjustments(): Readonly<Record<string, number>>;
82
+ /**
83
+ * Sets the adjust values, replacing any already set.
84
+ *
85
+ * @param adjustments Values by name, as {@link IGeometry.adjustmentsFromHandle} returns them;
86
+ * `null` restores the preset's defaults. Names the preset does not declare are kept but have no
87
+ * effect.
88
+ */
89
+ setAdjustments(adjustments: Record<string, number> | null, options?: ITransaction.OperationOptions): this;
90
+ /**
91
+ * Evaluates the shape's geometry at a size.
92
+ *
93
+ * @remarks
94
+ * What evaluates a shape loads on first use, and only what that shape needs, so this is
95
+ * asynchronous; a workbook with no shapes loads none of it. Everything on the geometry it
96
+ * returns is synchronous, including evaluating it again at another size or with other adjust
97
+ * values. Paths, handles and sites are in sheet pixels, in the shape's own frame (its top-left
98
+ * is 0,0), which is how the movable layer draws them.
99
+ *
100
+ * An open path takes the line ends the shape's line declares (its own over its theme style's):
101
+ * its stroke is trimmed under them, and they are visited as {@link IGeometry.PathLayer.Marker}
102
+ * paths. A group's geometry is its members', each placed in the group's frame.
103
+ *
104
+ * @param width Width in pixels. @defaultValue the movable's bounds.
105
+ * @param height Height in pixels. @defaultValue the movable's bounds.
106
+ * @returns `null` for a shape whose preset is unknown, or a shape with no size. A custom
107
+ * geometry evaluates like a preset, from its own definition.
108
+ */
109
+ getGeometry(width?: number, height?: number): Promise<IGeometry | null>;
110
+ /** For runtime type checking. */
111
+ readonly isIShape: true;
63
112
  }
64
113
  /**
65
114
  * {@inheritDoc IShape}
@@ -69,6 +118,25 @@ export interface IShape extends IModel, IMovable.IContent {
69
118
  * {@link IShape}
70
119
  */
71
120
  export declare namespace IShape {
121
+ /**
122
+ * What kind of drawing a shape's JSON describes.
123
+ *
124
+ * @remarks
125
+ * Every kind is an `IShape` whose {@link IMovable.IContent.getType | content type} is `'shape'`;
126
+ * this is the one place the distinction survives a round trip. A JSON that states none is a
127
+ * {@link IShape.Type.Shape | shape}.
128
+ */
129
+ const Type: {
130
+ /** A shape drawn from a preset or custom geometry, with or without text. */
131
+ readonly Shape: "shape";
132
+ /** A connector: a line that may be glued to other shapes' connection sites. */
133
+ readonly Connector: "connector";
134
+ /** A group of shapes, placed together; its members are its {@link JSON.children}. */
135
+ readonly Group: "group";
136
+ /** A picture inside a group; see {@link PictureMemberJSON}. */
137
+ readonly Picture: "picture";
138
+ };
139
+ type Type = typeof Type[keyof typeof Type];
72
140
  /**
73
141
  * A set of values that can be set on a IShape.
74
142
  *
@@ -77,15 +145,20 @@ export declare namespace IShape {
77
145
  */
78
146
  interface Properties {
79
147
  /**
80
- * The unique name of the table
148
+ * The name of the shape.
81
149
  */
82
150
  name?: string;
83
151
  /**
84
- * The preset Geometry for the shape. This could also be custom.
152
+ * The geometry: a DrawingML preset name (`'rect'`, `'roundRect'`, `'wedgeEllipseCallout'`…)
153
+ * or a custom definition in the same form as a preset.
85
154
  *
86
155
  * @defaultValue 'rect'
87
156
  */
88
- geometry?: PresetGeometry | GeometryProperties;
157
+ geometry?: string | IGeometry.Def;
158
+ /**
159
+ * Adjust values that differ from the preset's defaults, by name (`adj`, `adj1`…).
160
+ */
161
+ adjustments?: Record<string, number>;
89
162
  /**
90
163
  * The fill.
91
164
  */
@@ -97,223 +170,123 @@ export declare namespace IShape {
97
170
  /**
98
171
  * A hyperlink for the entire shape.
99
172
  */
100
- hyperlink?: string | IHyperlink.JSON;
173
+ hyperlink?: IHyperlink.JSON;
101
174
  }
102
175
  /**
103
176
  * A JSON representation useful for persistence.
104
177
  */
105
- interface JSON extends Omit<Properties, 'fill' | 'stroke' | 'geometry'> {
106
- fill?: IFill.SolidJSON | IFill.GradientJSON | IFill.PatternJSON | IFill.NoneJSON;
107
- stroke?: IStroke.JSON;
108
- geometry?: string | GeometryJSON;
109
- /** Which drawing element this was read from ("sp" | "cxnSp" | "grpSp") — `getType()` always
110
- * reports "shape" regardless, so this is the only place the distinction survives a round trip. */
111
- type?: string;
112
- /** Opaque source XML fragment, captured verbatim from the source file and replayed as-is on
113
- * save, for whatever this shape doesn't (yet) model structurally. */
114
- xml?: string;
115
- /** The `mc:Fallback` rendition of `xml`, captured verbatim, when the source offered the shape as an
116
- * `mc:AlternateContent`. An equation's fallback is where its linear text form is. */
117
- fallbackXml?: string;
118
- /** Original `cNvPr` id from the captured source fragment, if any; used to avoid id collisions
119
- * with freshly-generated ids on write. */
120
- sourceId?: number;
121
- }
122
- interface GeometryProperties {
123
- geometry?: PresetGeometry;
124
- ah: (PolarAdjustmentHandle | XYAdjustmentHandle)[];
125
- av?: IShape.AdjustmentGuide[];
126
- connections?: IShape.ConnectionSite[];
127
- guides?: IShape.AdjustmentGuide[];
128
- paths?: IShape.Path[] | string[] | string;
178
+ interface JSON extends Omit<Properties, 'fill' | 'stroke' | 'geometry' | 'hyperlink'> {
129
179
  /**
130
- * Specifies the rectangular bounding box for text within the shape.
131
- * @defaultValue `null` - The bounds of the shape,
180
+ * What kind of drawing this is. Absent for a {@link Type.Shape | shape}; a connector, a group
181
+ * and a group's picture member state theirs.
132
182
  */
133
- textBounds?: Rectangle;
134
- }
135
- interface Path {
136
- paths: string[];
183
+ type?: Type;
184
+ fill?: IFill.SolidJSON | IFill.GradientJSON | IFill.PatternJSON | IFill.ImageJSON | IFill.NoneJSON;
185
+ stroke?: IStroke.JSON;
137
186
  /**
138
- * Specifies that the use of 3D extrusions are possible on this path. This allows the generating application to know whether
139
- * 3D extrusion can be applied in any form.
140
- *
141
- * @defaultValue `false`
187
+ * The shape's effects (`spPr/effectLst`). An empty list is an explicit none: the element
188
+ * present and empty, which turns off the effects the shape's theme style would give it.
142
189
  */
143
- extrusionOk?: boolean;
190
+ effects?: IEffect.JSON[];
191
+ /** The 3-D scene (`spPr/scene3d`) as the file states it: an opaque DrawingML fragment. */
192
+ scene3d?: string;
193
+ /** The 3-D shape properties (`spPr/sp3d`) as the file states it: an opaque DrawingML fragment. */
194
+ shape3d?: string;
195
+ /** Extension lists kept as the file states them, by the element each extends. */
196
+ extLst?: ExtLstJSON;
197
+ geometry?: string | IGeometry.Def;
198
+ /** The hyperlink on the whole shape (`cNvPr/hlinkClick`). */
199
+ hyperlink?: IHyperlink.JSON;
200
+ /** The hyperlink followed on hover (`cNvPr/hlinkHover`). */
201
+ hoverHyperlink?: IHyperlink.JSON;
202
+ /** The title (`cNvPr/@title`), beside the description. */
203
+ title?: string;
204
+ /** The macro bound to the shape (`sp/@macro`), as the file states it. */
205
+ macro?: string;
206
+ /** The cell a text box's text is linked to (`sp/@textlink`), as the file states it. */
207
+ textLink?: string;
208
+ /** The text cannot be edited while the sheet is protected (`sp/@fLocksText`). */
209
+ locksText?: boolean;
210
+ /** `sp/@fPublished`. */
211
+ published?: boolean;
212
+ /** The shape was inserted as a text box (`cNvSpPr/@txBox`). */
213
+ textBox?: boolean;
144
214
  /**
145
- * Specifies how the corresponding path should be filled.
146
- *
147
- * @defaultValue `PathFill.Normal`
215
+ * Edit locks (`spLocks`/`cxnSpLocks`) by the file's own names: `noGrp`, `noSelect`, `noRot`,
216
+ * `noChangeAspect`, `noMove`, `noResize`, `noEditPoints`, `noAdjustHandles`,
217
+ * `noChangeArrowheads`, `noChangeShapeType`, `noTextEdit`.
148
218
  */
149
- pathFill?: PathFill;
219
+ locks?: Record<string, boolean>;
220
+ /** A connector's glued ends. */
221
+ connectorEnds?: {
222
+ start?: ConnectorEndJSON;
223
+ end?: ConnectorEndJSON;
224
+ };
225
+ /** The text written on the shape, by paragraph. Absent for a shape with no text body. */
226
+ text?: ITextFrame.JSON;
150
227
  /**
151
- * Specifies the height, or maximum y coordinate that should be used for within the path coordinate system. This value determines
152
- * the vertical placement of all points within the corresponding path as they will all be calculated using this height attribute
153
- * as the max y coordinate.
154
- *
155
- * @defaultValue `null`
228
+ * A group's members in z-order. A member is read like any shape but is not captured on its
229
+ * own: the group's markup holds it. A member's `bounds` are in the group's child space. A
230
+ * picture among them is a {@link PictureMemberJSON}.
156
231
  */
157
- h?: number;
232
+ children?: (JSON | PictureMemberJSON)[];
233
+ /** Where the shape sits as the file states it (`xfrm`), in pixels. For a group member, in the group's child space. */
234
+ bounds?: Bounds;
235
+ /** A group's child space (`chOff`/`chExt`), in pixels: what its members' `bounds` are stated in. */
236
+ childBounds?: Bounds;
237
+ /** Rotation in degrees as the file states it on the shape's own `xfrm`. */
238
+ rotation?: number;
239
+ /** Mirrored left to right (`xfrm/@flipH`), as the file states it. */
240
+ flipH?: boolean;
241
+ /** Mirrored top to bottom (`xfrm/@flipV`), as the file states it. */
242
+ flipV?: boolean;
158
243
  /**
159
- * Specifies if the corresponding path should have a path stroke shown. This is a boolean value that will effect on the outline of the path.
160
- *
161
- * @defaultValue `true`
244
+ * The theme style the shape draws with wherever it states no fill, stroke or text color of its
245
+ * own: the file's `style` element, which refers into the theme's format scheme by position.
246
+ * A reference not stated is Excel's for a new shape (a connector's differ: the first line, no
247
+ * fill); `null`, the shape has no style and draws only what it states itself.
162
248
  */
163
- stroke?: boolean;
249
+ style?: ITheme.StyleRefsJSON | null;
164
250
  /**
165
- * Specifies the width, or maximum x coordinate that should be used for within the path coordinate system. This value determines
166
- * the horizontal placement of all points within the corresponding path as they will all be calculated using this width attribute
167
- * as the max x coordinate.
168
- *
169
- * @defaultValue `null`
251
+ * The id the file gave the shape (`cNvPr/@id`), which is what a connector's
252
+ * {@link connectorEnds} name their targets by. A file writes the shape with this id again
253
+ * (made unique when two shapes share one, as a copy does); a shape without one takes the next.
170
254
  */
171
- w?: number;
255
+ sourceId?: number;
172
256
  }
173
257
  /**
174
- * Specifies the manner in which a path should be filled. The lightening and darkening of a path allow for certain parts of the shape
175
- * to be colored lighter of darker depending on user preference.
176
- */
177
- const PathFill: {
178
- readonly Darken: "darken";
179
- readonly DarkenLess: "darkenLess";
180
- readonly Lighten: "lighten";
181
- readonly LightenLess: "lightenLess";
182
- readonly None: "none";
183
- readonly Normal: "normal";
184
- };
185
- type PathFill = typeof PathFill[keyof typeof PathFill];
186
- /**
187
- * Specifies the presence of a shape guide that will be used to govern the geometry of the specified shape.
258
+ * The `extLst` fragments of a shape's elements: opaque DrawingML kept as the file states it and
259
+ * written back as it was, the one markup that stays once the shape is otherwise JSON. A line's
260
+ * is on its stroke, a text body's on its body.
188
261
  */
189
- interface AdjustmentGuide {
190
- /**
191
- * Specifies the name that will be used to reference to this guide. This name may be used just as a variable
192
- * would within an equation. That is this name may be substituted for literal values within other guides or
193
- * the specification of the shape path.
194
- */
195
- name: string;
196
- /**
197
- * Specifies the formula that will be used to calculate the value for a guide. Each formula has a certain
198
- * number of arguments and a specific set of operations to perform on these arguments in order to generate a
199
- * value for a guide. There are a total of 17 different formulas available. These are shown below with the usage
200
- * for each defined
201
- */
202
- fmla: string;
262
+ interface ExtLstJSON {
263
+ /** `cNvPr/extLst`: the creation id and whatever else extends the non-visual properties. */
264
+ nonVisual?: string;
265
+ /** `spPr/extLst`. */
266
+ properties?: string;
203
267
  }
204
268
  /**
205
- * These adjust handles will specify points within the geometric shape that can be used to perform certain
206
- * transform operations on the shape.
269
+ * A picture inside a group (`pic`): a member like any other, placed by its `bounds` in the
270
+ * group's child space. Its geometry is a rectangle and its image is its fill.
271
+ *
272
+ * @remarks
273
+ * The fill's `resId` names the image the way {@link IPicture.JSON.resId} names a placed
274
+ * picture's, and like it is meaningful only inside the persist scope the JSON was made in: a
275
+ * shape resolves it to the resource when it is created and names the resource again when it
276
+ * is serialized.
207
277
  */
208
- interface AdjustmentHandle {
209
- /**
210
- * The point of the adjustment
211
- */
212
- pos: Point;
213
- }
214
- interface PolarAdjustmentHandle extends AdjustmentHandle {
215
- type: 'polar';
216
- /**
217
- * Specifies the name of the guide that will be updated with the adjustment angle from this adjust handle.
218
- */
219
- gdRefAng: string;
220
- /**
221
- * Specifies the name of the guide that will be updated with the adjustment radius from this adjust handle.
222
- */
223
- gdRefR: string;
224
- /**
225
- * Specifies the maximum angle position that is allowed for this adjustment handle. If this attribute is omitted,
226
- * then it will be assumed that this adjust handle cannot move angularly.
227
- */
228
- maxAng: number;
229
- /**
230
- * Specifies the maximum radial position that is allowed for this adjustment handle. If this attribute is omitted,
231
- * then it will be assumed that this adjust handle cannot move radially.
232
- */
233
- maxR: number;
234
- /**
235
- * Specifies the minimum angle position that is allowed for this adjustment handle. If this attribute is omitted,
236
- * then it will be assumed that this adjust handle cannot move angularly.
237
- */
238
- minAng: number;
239
- /**
240
- * Specifies the minimum radial position that is allowed for this adjustment handle. If this attribute is omitted,
241
- * then it will be assumed that this adjust handle cannot move radially.
242
- */
243
- minR: number;
244
- }
245
- interface XYAdjustmentHandle extends AdjustmentHandle {
246
- type: 'xy';
247
- /**
248
- * Specifies the name of the guide that will be updated with the adjustment x position from this adjust handle.
249
- */
250
- gdRefX: string;
251
- /**
252
- * Specifies the name of the guide that will be updated with the adjustment y position from this adjust handle.
253
- */
254
- gdRefY: string;
255
- /**
256
- * Specifies the maximum horizontal position that is allowed for this adjustment handle. If this attribute is omitted,
257
- * then it will be assumed that this adjust handle cannot move in the x direction.
258
- */
259
- maxX: number;
260
- /**
261
- * Specifies the maximum vertical position that is allowed for this adjustment handle. If this attribute is omitted,
262
- * then it will be assumed that this adjust handle cannot move in the y direction.
263
- */
264
- maxY: number;
265
- /**
266
- * Specifies the minimum horizontal position that is allowed for this adjustment handle. If this attribute is omitted,
267
- * then it will be assumed that this adjust handle cannot move in the x direction.
268
- */
269
- minX: number;
270
- /**
271
- * Specifies the minimum vertical position that is allowed for this adjustment handle. If this attribute is omitted,
272
- * then it will be assumed that this adjust handle cannot move in the y direction.
273
- */
274
- minY: number;
278
+ interface PictureMemberJSON extends JSON {
279
+ type: typeof Type.Picture;
280
+ /** The image, as an image fill. */
281
+ fill?: IFill.ImageJSON;
275
282
  }
276
283
  /**
277
- * A connection site allows a `ConnectionShape` to be attached to this shape. This connection will be maintained
278
- * when the shape is repositioned. It should be noted that this connection is placed within the shape
279
- * bounding box using the transform coordinate system which is also called the shape coordinate system,
280
- * as it encompasses the entire shape.
284
+ * One glued end of a connector: the shape it is attached to, by the id the file gives that
285
+ * shape (its `sourceId` here), and which of that shape's connection sites.
281
286
  */
282
- interface ConnectionSite {
283
- /**
284
- * Specifies the incoming connector angle. This angle is the angle around the connection site that an
285
- * incoming connector will try to be routed to. This allows connectors to know where the shape is in
286
- * relation to the connection site and route connectors so as to avoid any overlap with the shape.
287
- */
288
- angle: string;
289
- /**
290
- * Specifies a position coordinate within the shape bounding box. It should be noted that this coordinate
291
- * is placed within the shape bounding box using the transform coordinate system which is also called the
292
- * shape coordinate system, as it encompasses the entire shape.
293
- */
294
- pos: Point;
295
- }
296
- interface GeometryJSON extends GeometryProperties {
297
- }
298
- interface Events extends IModel.Events {
299
- }
300
- interface IListeners extends IListener.Callbacks<IShape, IShape.Events> {
287
+ interface ConnectorEndJSON {
288
+ id: number;
289
+ index: number;
301
290
  }
302
- interface IConnection {
303
- }
304
- interface Connection extends IShape.JSON {
305
- cxnSp?: any;
306
- }
307
- /**
308
- * @see {@link https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_ShapeType_topic_ID0EBTFOB.html#topic_ID0EBTFOB}
309
- */
310
- const PresetGeometry: {
311
- readonly Line: "line";
312
- readonly LineInv: "lineInv";
313
- readonly triangle: "triangle";
314
- readonly rtTriangle: "rtTriangle";
315
- readonly Rect: "rect";
316
- };
317
- type PresetGeometry = typeof PresetGeometry[keyof typeof PresetGeometry];
318
291
  }
319
292
  //# sourceMappingURL=IShape.d.ts.map
@@ -1,6 +1,8 @@
1
- import { IResource, IResourceCollection } from '../resource';
1
+ import { ITransaction } from '../transaction';
2
+ import { IResource } from '../resource';
3
+ import { ITextFrame } from '../text';
2
4
  import { AbstractMovableContent } from '../movable/AbstractMovableContent';
3
- import { ITextFrame } from '../text/ITextFrame';
5
+ import { IGeometry } from './IGeometry';
4
6
  import { IShape } from './IShape';
5
7
  interface State extends AbstractMovableContent.State {
6
8
  data?: any;
@@ -9,27 +11,55 @@ interface State extends AbstractMovableContent.State {
9
11
  * Implementation for {@link IShape}.
10
12
  */
11
13
  export declare class Shape extends AbstractMovableContent<State, IShape.JSON> implements IShape {
12
- /** The state `_facts` was read from; a new state object is a new read. */
13
- private _factsSource;
14
- private _facts;
14
+ /** The state the text frame was read from; a new state object is a new read. */
15
+ private _textSource;
16
+ private _textFrame;
17
+ /**
18
+ * The images the JSON names — an image fill's, a group's picture members' — by the resource id
19
+ * it names them with. Held the way a picture holds its one resource: the id is only good inside
20
+ * the persist scope that made the JSON, the resource is good for as long as the shape is.
21
+ */
22
+ private _resources;
23
+ private _getStyles;
24
+ /** The last evaluation {@link _getDrawnRect} answers from, and the one in flight. */
25
+ private _drawn;
26
+ private _drawnPending;
15
27
  constructor(options: Shape.ConstructorOptions);
28
+ protected _processAfterStateChange(state: State, commit: ITransaction.ICommit): void;
29
+ /** {@inheritDoc IShape.getResource} */
30
+ getResource(resourceId: number): IResource | null;
16
31
  /** {@inheritDoc IModel.getType} */
17
32
  getType(): string;
18
33
  /** {@inheritDoc IShape.getShapeType} */
19
34
  getShapeType(): string;
20
35
  /** {@inheritDoc IShape.getTextFrame} */
21
36
  getTextFrame(): ITextFrame.IText | null;
22
- /** The captured fragment is read once per state, on first ask; most shapes are never asked. */
23
- private _getFacts;
37
+ /** {@inheritDoc IShape.getAdjustments} */
38
+ getAdjustments(): Readonly<Record<string, number>>;
39
+ /** {@inheritDoc IShape.setAdjustments} */
40
+ setAdjustments(adjustments: Record<string, number> | null, options?: ITransaction.OperationOptions): this;
41
+ /** {@inheritDoc IShape.getGeometry} */
42
+ getGeometry(width?: number, height?: number): Promise<IGeometry | null>;
43
+ /**
44
+ * What the shape paints, in pixels in its `width` by `height` frame: its geometry's paths grown
45
+ * by its line. Answered from the last evaluation, scaled to the size asked; `null` before the
46
+ * first. A stale answer starts a new evaluation and `onReady` is called when it lands.
47
+ * @internal
48
+ */
49
+ _getDrawnRect(width: number, height: number, onReady: () => void): IGeometry.Rect | null;
50
+ /** The workbook theme the shape's style references resolve against; `null` with none to ask. */
51
+ private _theme;
24
52
  /** {@inheritDoc Movable.Content.toJSON} */
25
- toJSON(_toResourceId?: (resource: IResource) => number | null): IShape.JSON | null;
53
+ toJSON(toResourceId?: (resource: IResource) => number | null): IShape.JSON | null;
26
54
  /** {@inheritDoc IMovable.IContent.getTypeDescription} */
27
55
  getTypeDescription(): string;
56
+ /** {@inheritDoc IShape.isIShape} */
57
+ get isIShape(): true;
28
58
  get [Symbol.toStringTag](): string;
29
59
  toString(): string;
30
60
  }
31
61
  /**
32
- * Interfaces for creating `Chart` items.
62
+ * Interfaces for creating `Shape` items.
33
63
  *
34
64
  * @see
35
65
  * ### **Interface**
@@ -45,10 +75,6 @@ export declare namespace Shape {
45
75
  * Returns an IResource from the resourceId or null if not found.
46
76
  */
47
77
  fromResourceId?: (resourceId: number) => IResource;
48
- /**
49
- * Useful for load/save/copying.
50
- */
51
- beginPersistResource: () => IResourceCollection.IPersistScope<IResource.JSON>;
52
78
  /**
53
79
  * Allow for the default lock aspect ratio to be overwritten.
54
80
  */
@@ -0,0 +1,48 @@
1
+ import { IFill, IStroke } from '../fill';
2
+ import { ITheme } from '../theme';
3
+ import { IText, ITextFrame } from '../text';
4
+ import { IShape } from './IShape';
5
+ /** The style references a shape takes for each one it does not state; a connector's and a picture's differ. */
6
+ export declare function defaultStyleRefs(json: IShape.JSON | null | undefined): Readonly<ITheme.StyleRefsJSON>;
7
+ /**
8
+ * `style` with every reference equal to its default left out: `undefined` when none is left,
9
+ * `null` (no style at all) kept.
10
+ */
11
+ export declare function withoutDefaultStyleRefs(json: IShape.JSON): ITheme.StyleRefsJSON | null | undefined;
12
+ /**
13
+ * SheetXL's defaults for what a shape's text does not state. A file format's writer states them in
14
+ * that format's terms, and its reader leaves out what equals them.
15
+ */
16
+ export declare const TEXT_DEFAULTS: Readonly<{
17
+ /** Text is kept inside the shape ("Allow text to overflow shape" off). */
18
+ readonly verticalOverflow: "clip";
19
+ readonly horizontalOverflow: "clip";
20
+ /** The size of a run nothing gives one, in points. */
21
+ readonly size: 11;
22
+ }>;
23
+ /**
24
+ * The size a paragraph's runs inherit — its own default run, then the body's list style for its
25
+ * level — or `undefined` when nothing above the run states one, which is when
26
+ * {@link TEXT_DEFAULTS} applies.
27
+ */
28
+ export declare function inheritedTextSize(text: ITextFrame.JSON, paragraph: IText.ParagraphPropertiesJSON): number | undefined;
29
+ export interface ResolvedShapeStyle {
30
+ /** The fill, with the style's placeholder color substituted; `undefined` when nothing states one. */
31
+ fill: IFill.JSON | undefined;
32
+ /**
33
+ * The line: the shape's own over its style's, field by field, with the style's color when the
34
+ * shape states a line without one (an `<a:ln w="…">` alone), as in Excel. `undefined` when
35
+ * nothing states one.
36
+ */
37
+ stroke: Partial<IStroke.JSON> | undefined;
38
+ /** The line width in points: stated, or Excel's implied width. */
39
+ strokeWidth: number;
40
+ /** The text color's serialized form: the style's, or by whether there is a fill to read on. */
41
+ fontColor: string;
42
+ }
43
+ /**
44
+ * Resolves a shape's fill, line and text color from its JSON and its workbook's theme. No style
45
+ * stated (`undefined`) takes SheetXL's defaults; a stated none (`null`) takes nothing.
46
+ */
47
+ export declare function resolve(json: IShape.JSON | null | undefined, theme: ITheme.JSON | null): ResolvedShapeStyle;
48
+ //# sourceMappingURL=ShapeStyleUtils.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { ITheme } from '../theme';
2
+ import { IGeometry } from './IGeometry';
3
+ import { IShape } from './IShape';
4
+ /**
5
+ * What a geometry paints, in pixels in the shape's frame: its paths' box grown by the reach of the
6
+ * line each is stroked with.
7
+ */
8
+ export declare const getDrawnRect: (geometry: IGeometry) => IGeometry.Rect;
9
+ /**
10
+ * A shape's geometry from its JSON, at `width` by `height` in pixels, loading only what it needs.
11
+ * `null` for a picture or a shape whose preset is not known.
12
+ */
13
+ export declare const createGeometry: (json: IShape.JSON, theme: ITheme.JSON | null, width: number, height: number) => Promise<IGeometry | null>;
14
+ //# sourceMappingURL=_Geometry.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { IGeometry } from './IGeometry';
2
+ /**
3
+ * The lazily loaded parts of shape geometry. None is imported statically: a workbook with no
4
+ * shapes never loads them, a sheet of rectangles and straight lines loads at most the line ends,
5
+ * and any other preset loads the engine and the one chunk of definitions that holds it.
6
+ *
7
+ * Each promise is memoized once it resolves and dropped on failure, so a transient load error is
8
+ * retried on the next ask rather than cached forever (the same pattern as the scripting and
9
+ * compiler loaders).
10
+ */
11
+ export type Engine = typeof import('./geometry');
12
+ export type StrokeEnds = typeof import('./geometry/_strokeEnds');
13
+ /** Guides, paths, handles and line ends: everything but the preset definitions. */
14
+ export declare const loadEngine: () => Promise<Engine>;
15
+ /** Line ends alone, for a straight line that declares a head or tail. */
16
+ export declare const loadStrokeEnds: () => Promise<StrokeEnds>;
17
+ /** Whether a name is a preset this SDK defines. */
18
+ export declare const isPreset: (name: string) => boolean;
19
+ /** A preset's built-in definition, loading the chunk that holds it; `undefined` for a name that is not a preset. */
20
+ export declare const loadBuiltInDef: (name: string) => Promise<IGeometry.Def | undefined>;
21
+ //# sourceMappingURL=_GeometryLoader.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { BuiltInDef } from './_BuiltInDef';
2
+ /** A chunk of built-in definitions. */
3
+ export interface BuiltInChunk {
4
+ /** Connection-site lists shared by more than one shape in the chunk; `BuiltInDef.cxn` indexes into this. */
5
+ CXN_SHARED: readonly (readonly string[])[];
6
+ BUILT_IN: Readonly<Record<string, BuiltInDef>>;
7
+ }
8
+ /** Each chunk's loader and the presets it holds. */
9
+ export declare const BUILT_IN_CHUNKS: readonly (readonly [load: () => Promise<BuiltInChunk>, names: readonly string[]])[];
10
+ //# sourceMappingURL=_BuiltInChunks.d.ts.map