@twip/web 0.0.0-canary-4e9c983 → 0.0.0-canary-8e34765

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.
@@ -3384,7 +3384,7 @@ the following restrictions:
3384
3384
  3. This notice may not be removed or altered from any source distribution.
3385
3385
  ```
3386
3386
 
3387
- ## C and C++ libraries, and fonts
3387
+ ## C and C++ libraries, fonts and data
3388
3388
 
3389
3389
  ### Skia (BSD-3-Clause)
3390
3390
 
@@ -5455,3 +5455,41 @@ given a different name.
5455
5455
 
5456
5456
  $Id$
5457
5457
  ```
5458
+
5459
+ ### ECMA-376 preset shape definitions (LicenseRef-Ecma)
5460
+
5461
+ In: the native library and the WebAssembly module
5462
+
5463
+ ```
5464
+ The preset shape geometries built into the engine are generated from presetShapeDefinitions.xml, an electronic insert
5465
+ of ECMA-376 Part 1, Office Open XML File Formats - Fundamentals and Markup Language Reference, 5th edition (December
5466
+ 2016), https://ecma-international.org/publications-and-standards/standards/ecma-376/
5467
+
5468
+ COPYRIGHT NOTICE
5469
+ (c) Ecma International
5470
+ By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply
5471
+ with the following terms and conditions.
5472
+ This document may be copied, published and distributed to others, and certain derivative works of it may be
5473
+ prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and
5474
+ this Copyright License and Disclaimer are included on all such copies and derivative works. The only derivative
5475
+ works that are permissible under this Copyright License and Disclaimer are:
5476
+ (i) works which incorporate all or portion of this document for the purpose of providing commentary or
5477
+ explanation (such as an annotated version of the document),
5478
+ (ii) works which incorporate all or portion of this document for the purpose of incorporating features that
5479
+ provide accessibility,
5480
+ (iii) translations of this document into languages other than English and into different formats and
5481
+ (iv) works by making use of this specification in standard conformant products by implementing (e.g. by
5482
+ copy and paste wholly or partly) the functionality therein.
5483
+ However, the content of this document itself may not be modified in any way, including by removing the
5484
+ copyright notice or references to Ecma International, except as required to translate it into languages other
5485
+ than English or into a different format.
5486
+ The official version of an Ecma International document is the English language version on the Ecma
5487
+ International website. In the event of discrepancies between a translated version and the official version, the
5488
+ official version shall govern.
5489
+ The limited permissions granted above are perpetual and will not be revoked by Ecma International or its
5490
+ successors or assigns.
5491
+ This document and the information contained herein is provided on an "AS IS" basis and ECMA
5492
+ INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT
5493
+ THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF
5494
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
5495
+ ```
@@ -2,7 +2,7 @@ import type { RichText } from './review.js';
2
2
  import type { ControlKind, ControlOptions, DataBinding } from './services/elements.js';
3
3
  import type { TabAlignment, TabLeader } from './services/ruler.js';
4
4
  import type { HighlightColor, HorizontalPosition, LineSpacing, MarkupView, ObjectWrap, RowHeight, TableWidth, UnderlineStyle, VerticalPosition, WrapSide } from './state.js';
5
- import type { Color, CommentId, ElementId, Points, RevisionId, StyleId } from './types.js';
5
+ import type { Arrange, Color, CommentId, Degrees, EffectsChange, ElementId, FillValue, FlipAxis, LineChange, PictureAdjustChange, Points, RevisionId, ShapeAdjust, ShapeInsert, ShapePreset, ShapeTextChange, StyleId } from './types.js';
6
6
  /** Which elements a field command acts on: the given ids, or the selection's by default. */
7
7
  export interface FieldTargets {
8
8
  /** The fields; default: the selection's. */
@@ -254,6 +254,11 @@ export interface Commands {
254
254
  }): Promise<void>;
255
255
  /** Inserts a text box. */
256
256
  insertTextBox(): Promise<void>;
257
+ /**
258
+ * Inserts a floating shape at the caret's paragraph, in front of the text, with the theme's default style, and
259
+ * selects it.
260
+ */
261
+ insertShape(options: ShapeInsert): Promise<void>;
257
262
  /** Inserts a footnote. */
258
263
  insertFootnote(): Promise<void>;
259
264
  /** Inserts an endnote. */
@@ -406,6 +411,32 @@ export interface Commands {
406
411
  }): Promise<void>;
407
412
  /** Deletes the object. */
408
413
  deleteObject(): Promise<void>;
414
+ /** Changes the shape's preset geometry; its text, fill, outline and effects stay and its adjust values reset. */
415
+ setShapePreset(preset: ShapePreset): Promise<void>;
416
+ /** Sets one of the shape's adjust values. */
417
+ setShapeAdjust(options: ShapeAdjust): Promise<void>;
418
+ /** Sets the selected objects' fill; `fromStyle` gives them the style reference's again. */
419
+ setShapeFill(fill: FillValue): Promise<void>;
420
+ /** Sets the selected objects' outline; unset fields keep their value. */
421
+ setShapeLine(change: LineChange): Promise<void>;
422
+ /** Sets the selected objects' shadows, glow, soft edge and blur; unset fields keep their value, `null` removes. */
423
+ setShapeEffects(change: EffectsChange): Promise<void>;
424
+ /** Sets the shape's text insets, anchor, autofit, wrapping and direction; unset fields keep their value. */
425
+ setShapeText(change: ShapeTextChange): Promise<void>;
426
+ /** Sets the picture's transparency, greyscale, brightness and contrast; unset fields keep their value. */
427
+ setPictureAdjust(change: PictureAdjustChange): Promise<void>;
428
+ /** Sets the selected objects' rotation, 0 to 360 degrees clockwise. */
429
+ setObjectRotation(degrees: Degrees): Promise<void>;
430
+ /** Flips the selected objects. */
431
+ flipObject(axis: FlipAxis): Promise<void>;
432
+ /** Moves the floating object in the paint order, or behind or in front of the text. */
433
+ arrangeObject(where: Arrange): Promise<void>;
434
+ /** Groups the selected floating objects: two or more, in one story. The group is selected. */
435
+ groupObjects(): Promise<void>;
436
+ /** Ungroups the selected group. Its children are selected. */
437
+ ungroupObjects(): Promise<void>;
438
+ /** Selects the next or previous child of the selected group. View. */
439
+ selectGroupChild(direction: 'next' | 'previous'): Promise<void>;
409
440
  /** Changes a field's code or display. */
410
441
  setField(options: {
411
442
  id: ElementId;
@@ -597,13 +628,13 @@ export interface Commands {
597
628
  /** A command id: the method name, the batch op's `type`, the catalog id and the key in `state.commands`. */
598
629
  export type CommandId = keyof Commands;
599
630
  /**
600
- * An op's fields besides `type`. A single argument (a primitive, {@link RichText}, bytes, an array, or a union with a
601
- * primitive) goes in `value`; an options object, and a tagged value such as {@link LineSpacing} or
602
- * {@link TableWidth}, is spread into the op.
631
+ * An op's fields besides `type`. A single argument (a primitive, {@link RichText}, bytes, an array, a
632
+ * {@link FillValue}, whose `type` would clash with the op's, or a union with a primitive) goes in `value`; an options
633
+ * object, and a tagged value such as {@link LineSpacing} or {@link TableWidth}, is spread into the op.
603
634
  */
604
635
  export type OpArgs<K extends CommandId> = Parameters<Commands[K]> extends [] ? {} : [Exclude<Parameters<Commands[K]>[0], undefined>] extends [string | number | boolean | null] ? {
605
636
  value: Exclude<Parameters<Commands[K]>[0], undefined>;
606
- } : [Exclude<Parameters<Commands[K]>[0], undefined>] extends [RichText | Uint8Array | readonly unknown[]] ? {
637
+ } : [Exclude<Parameters<Commands[K]>[0], undefined>] extends [RichText | Uint8Array | FillValue | readonly unknown[]] ? {
607
638
  value: Exclude<Parameters<Commands[K]>[0], undefined>;
608
639
  } : [Exclude<Parameters<Commands[K]>[0], undefined>] extends [object] ? Exclude<Parameters<Commands[K]>[0], undefined> : {
609
640
  value: Exclude<Parameters<Commands[K]>[0], undefined>;
package/dist/commands.js CHANGED
@@ -79,6 +79,7 @@ const encodings = {
79
79
  insertTable: 'spread',
80
80
  insertPicture: 'spread',
81
81
  insertTextBox: 'none',
82
+ insertShape: 'spread',
82
83
  insertFootnote: 'none',
83
84
  insertEndnote: 'none',
84
85
  insertHyperlink: 'spread',
@@ -121,6 +122,19 @@ const encodings = {
121
122
  setObjectWrapOptions: 'spread',
122
123
  setAltText: 'spread',
123
124
  deleteObject: 'none',
125
+ setShapePreset: 'value',
126
+ setShapeAdjust: 'spread',
127
+ setShapeFill: 'value',
128
+ setShapeLine: 'spread',
129
+ setShapeEffects: 'spread',
130
+ setShapeText: 'spread',
131
+ setPictureAdjust: 'spread',
132
+ setObjectRotation: 'value',
133
+ flipObject: 'value',
134
+ arrangeObject: 'value',
135
+ groupObjects: 'none',
136
+ ungroupObjects: 'none',
137
+ selectGroupChild: 'value',
124
138
  setField: 'spread',
125
139
  setFieldResults: 'spread',
126
140
  updateFields: 'spread',
package/dist/editor.d.ts CHANGED
@@ -13,7 +13,7 @@ import { type Dictionary, type Spelling } from './services/spelling.js';
13
13
  import { type Gestures, type View } from './services/view.js';
14
14
  import type { EditorState } from './state.js';
15
15
  import { type FrameInfo, Method, type Input, type Message, type Transport } from './transport/protocol.js';
16
- import type { Author, Color, OverlayColors, Warning, WordCount } from './types.js';
16
+ import type { Author, Color, OverlayColors, ShapeGalleryGroup, Warning, WordCount } from './types.js';
17
17
  /** Options for a new session. */
18
18
  export interface SessionOptions {
19
19
  /** Start read only. Default false. */
@@ -95,6 +95,7 @@ export declare class Session {
95
95
  readonly id: number;
96
96
  state: EditorState;
97
97
  readonly catalog: readonly CommandInfo[];
98
+ readonly shapeGallery: readonly ShapeGalleryGroup[];
98
99
  destroyed: boolean;
99
100
  /** Mounted hosts listen for frame and host requests here. */
100
101
  readonly hostListeners: Set<(message: Message) => void>;
@@ -130,6 +131,8 @@ export declare class HeadlessEditor {
130
131
  readonly commands: Commands;
131
132
  /** Every command's id, label, group, shortcuts and undo grouping. */
132
133
  readonly catalog: readonly CommandInfo[];
134
+ /** Word's Insert \> Shapes gallery: its groups and their presets, in order. */
135
+ readonly shapeGallery: readonly ShapeGalleryGroup[];
133
136
  /** The context menu. */
134
137
  readonly menus: Menus;
135
138
  /** The dialogs. */
package/dist/editor.js CHANGED
@@ -40,19 +40,31 @@ export function toWire(value) {
40
40
  return value;
41
41
  }
42
42
  function deepFreeze(value) {
43
- if (value && typeof value === 'object' && !Object.isFrozen(value)) {
43
+ // Bytes can't be frozen.
44
+ if (value && typeof value === 'object' && !ArrayBuffer.isView(value) && !Object.isFrozen(value)) {
44
45
  Object.freeze(value);
45
46
  for (const v of Object.values(value))
46
47
  deepFreeze(v);
47
48
  }
48
49
  return value;
49
50
  }
51
+ /** The state in the SDK's shape: a picture fill's image, base64 as the engine sends it, as bytes. */
52
+ function fromWireState(state) {
53
+ const shape = state.selection.object?.shape;
54
+ for (const fill of shape ? [Object.values(shape.fill)[0], Object.values(shape.line)[0]?.fill] : []) {
55
+ if (fill?.type === 'picture' && typeof fill.image === 'string') {
56
+ fill.image = Uint8Array.from(atob(fill.image), (c) => c.charCodeAt(0));
57
+ }
58
+ }
59
+ return state;
60
+ }
50
61
  /** One editor's session over a transport: the state cache, the listeners and the calls. Internal. */
51
62
  export class Session {
52
63
  transport;
53
64
  id;
54
65
  state;
55
66
  catalog;
67
+ shapeGallery;
56
68
  destroyed = false;
57
69
  #subscribers = new Set();
58
70
  #listeners = new Map();
@@ -67,11 +79,12 @@ export class Session {
67
79
  #fault;
68
80
  /** Commits waiting for the state cache to reach their revision. */
69
81
  #waiting = [];
70
- constructor(transport, id, state, catalog) {
82
+ constructor(transport, id, state, catalog, shapeGallery) {
71
83
  this.transport = transport;
72
84
  this.id = id;
73
- this.state = deepFreeze(state);
85
+ this.state = deepFreeze(fromWireState(state));
74
86
  this.catalog = deepFreeze(catalog);
87
+ this.shapeGallery = deepFreeze(shapeGallery);
75
88
  this.disposers.push(transport.listen(id, (m) => this.#receive(m)));
76
89
  }
77
90
  /** Creates a session on the page's engine: on this thread, or in the page's engine worker. */
@@ -88,7 +101,8 @@ export class Session {
88
101
  return [];
89
102
  throw e;
90
103
  }));
91
- const session = new Session(transport, id, state, catalog);
104
+ const shapeGallery = (await transport.call(id, Method.ShapeGallery));
105
+ const session = new Session(transport, id, state, catalog, shapeGallery);
92
106
  for (const dictionary of options.dictionaries ?? [])
93
107
  await session.call(Method.SpellingAddDictionary, dictionary);
94
108
  return session;
@@ -185,7 +199,7 @@ export class Session {
185
199
  return;
186
200
  switch (message.kind) {
187
201
  case Kind.State: {
188
- this.state = deepFreeze(message.payload);
202
+ this.state = deepFreeze(fromWireState(message.payload));
189
203
  const revision = this.state.revision;
190
204
  for (const w of this.#waiting)
191
205
  if (w.revision <= revision)
@@ -236,6 +250,8 @@ export class HeadlessEditor {
236
250
  commands;
237
251
  /** Every command's id, label, group, shortcuts and undo grouping. */
238
252
  catalog;
253
+ /** Word's Insert \> Shapes gallery: its groups and their presets, in order. */
254
+ shapeGallery;
239
255
  /** The context menu. */
240
256
  menus;
241
257
  /** The dialogs. */
@@ -269,6 +285,7 @@ export class HeadlessEditor {
269
285
  sessions.set(this, session);
270
286
  this.commands = createCommands((op) => session.run(op));
271
287
  this.catalog = session.catalog;
288
+ this.shapeGallery = session.shapeGallery;
272
289
  this.menus = createMenus(session);
273
290
  this.dialogs = createDialogs(session);
274
291
  this.find = createFind(session);
package/dist/index.d.ts CHANGED
@@ -24,4 +24,4 @@ export type { Heading, Navigation, StyleInfo, Styles } from './services/navigati
24
24
  export type { Ruler, RulerModel, RulerModelSource, RulerUnit, RulerView, TabAlignment, TabLeader, TabSelector, } from './services/ruler.js';
25
25
  export type { GestureAction, GestureBinding, GestureEvent, GestureId, Gestures, View } from './services/view.js';
26
26
  export { cm, inches, mm, pt } from './types.js';
27
- export type { Author, ClientPoint, ClientRect, Color, CommentId, ContentPoint, ElementId, FrameStats, HeadingId, OverlayColors, MatchId, Points, RevisionId, StyleId, Warning, WordCount, } from './types.js';
27
+ export type { Arrange, ArrowKind, Arrowhead, ArrowSize, Author, ClientPoint, ClientRect, Color, ColourTransform, ColourValue, CommentId, Compound, ContentPoint, Degrees, EffectsChange, EffectsValue, ElementId, FillState, FillValue, FlipAxis, FrameStats, Glow, GradientShape, GradientStop, HeadingId, LineCap, LineChange, LineEnds, LineJoin, LineState, LineValue, OverlayColors, MatchId, PictureAdjustChange, Points, RevisionId, Shadow, ShapeAdjust, ShapeGalleryGroup, ShapeInsert, ShapePreset, ShapeState, ShapeTextChange, ShapeTextState, StyleId, TextAnchor, TextAutofit, TextDirection, ThemeColour, TransformKind, Warning, WordCount, } from './types.js';
package/dist/state.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { CommandId } from './commands.js';
2
2
  import type { DialogKind } from './services/dialogs.js';
3
3
  import type { ControlKind } from './services/elements.js';
4
4
  import type { RulerModel, RulerUnit, TabSelector } from './services/ruler.js';
5
- import type { Color, CommentId, ElementId, Points, RevisionId, StyleId } from './types.js';
5
+ import type { Color, CommentId, Degrees, ElementId, Points, RevisionId, ShapeState, StyleId } from './types.js';
6
6
  /** An on/off value over the selection: `'mixed'` where it differs, `null` where it doesn't apply. */
7
7
  export type Tri = boolean | 'mixed' | null;
8
8
  /** A value over the selection: `'mixed'` where it differs, `null` where it doesn't apply. */
@@ -72,6 +72,11 @@ export interface EditorState {
72
72
  ruler: RulerModel;
73
73
  /** Whether formatting is held for `pasteFormatting`. */
74
74
  formatPainter: boolean;
75
+ /**
76
+ * The document's 12 theme colours, in `ThemeColour` order (text1, background1, text2, background2, accent1 to
77
+ * accent6, hyperlink, followedHyperlink), for an application's colour picker.
78
+ */
79
+ themeColours: Color[];
75
80
  }
76
81
  /** The value each command reports in state, for the commands that report one. */
77
82
  export interface CommandValues {
@@ -291,10 +296,10 @@ export type TableWidth = {
291
296
  kind: 'percent';
292
297
  value: number;
293
298
  };
294
- /** The selected picture or text box. */
299
+ /** The selected object. */
295
300
  export interface ObjectSelection {
296
- /** A picture or a text box. */
297
- kind: 'picture' | 'textBox';
301
+ /** A picture, a text box, a shape, a line or connector (a shape with no filled path), or a group. */
302
+ kind: 'picture' | 'textBox' | 'shape' | 'line' | 'group';
298
303
  /** How text wraps around it. */
299
304
  wrap: ObjectWrap;
300
305
  /** The width. */
@@ -309,6 +314,18 @@ export interface ObjectSelection {
309
314
  anchorLocked: boolean | null;
310
315
  /** Where a floating object is and how text keeps from it; `null` when inline. */
311
316
  placement: ObjectPlacement | null;
317
+ /** The shape's properties as written; `null` for objects without shape properties (frames) and kept graphics. */
318
+ shape: ShapeState | null;
319
+ /** Its rotation, clockwise. */
320
+ rotation: Degrees;
321
+ /** Flipped left to right. */
322
+ flipH: boolean;
323
+ /** Flipped top to bottom. */
324
+ flipV: boolean;
325
+ /** The selected child's place in its group; empty unless a group child is selected. */
326
+ childPath: number[];
327
+ /** How many objects are selected: 2 or more for a multi-selection, the other fields describing the first. */
328
+ count: number;
312
329
  }
313
330
  /** How text wraps around an object. */
314
331
  export type ObjectWrap = 'inline' | 'square' | 'tight' | 'through' | 'topAndBottom' | 'behindText' | 'inFrontOfText';
@@ -80,6 +80,7 @@ export declare const Method: {
80
80
  readonly HostSetOverlayPalette: 73;
81
81
  readonly HostSetPaintBudget: 74;
82
82
  readonly HostSetLeaders: 75;
83
+ readonly ShapeGallery: 76;
83
84
  };
84
85
  /** A structured call number. */
85
86
  export type Method = (typeof Method)[keyof typeof Method];
@@ -79,6 +79,7 @@ export const Method = {
79
79
  HostSetOverlayPalette: 73,
80
80
  HostSetPaintBudget: 74,
81
81
  HostSetLeaders: 75,
82
+ ShapeGallery: 76,
82
83
  };
83
84
  /** What the engine sends: callback kinds of the C ABI. */
84
85
  export const Kind = {
Binary file
package/dist/types.d.ts CHANGED
@@ -105,7 +105,7 @@ export interface Author {
105
105
  /** A recoverable fidelity issue found while reading or writing a document. Aggregated per code and part. */
106
106
  export interface Warning {
107
107
  /** What kind of issue it is. */
108
- code: 'unsupported-element' | 'image-undecodable' | 'font-unresolved' | 'font-substituted' | 'rewritten-content' | 'pdf-font-fallback' | 'revision-id-missing' | 'range-unpaired' | 'author-missing' | 'comment-unanchored' | 'comment-reference-orphan';
108
+ code: 'unsupported-element' | 'image-undecodable' | 'font-unresolved' | 'font-substituted' | 'rewritten-content' | 'pdf-font-fallback' | 'revision-id-missing' | 'range-unpaired' | 'author-missing' | 'comment-unanchored' | 'comment-reference-orphan' | 'unknown-preset';
109
109
  /** A readable description. */
110
110
  message: string;
111
111
  /** How many times it occurred. */
@@ -131,4 +131,277 @@ export interface WordCount {
131
131
  /** Pages. */
132
132
  pages: number;
133
133
  }
134
+ /** An angle in degrees, clockwise. */
135
+ export type Degrees = number;
136
+ /** A preset geometry by its ECMA-376 name (`'wedgeRectCallout'`): the 187 presets, in alphabetical order. */
137
+ export type ShapePreset = 'accentBorderCallout1' | 'accentBorderCallout2' | 'accentBorderCallout3' | 'accentCallout1' | 'accentCallout2' | 'accentCallout3' | 'actionButtonBackPrevious' | 'actionButtonBeginning' | 'actionButtonBlank' | 'actionButtonDocument' | 'actionButtonEnd' | 'actionButtonForwardNext' | 'actionButtonHelp' | 'actionButtonHome' | 'actionButtonInformation' | 'actionButtonMovie' | 'actionButtonReturn' | 'actionButtonSound' | 'arc' | 'bentArrow' | 'bentConnector2' | 'bentConnector3' | 'bentConnector4' | 'bentConnector5' | 'bentUpArrow' | 'bevel' | 'blockArc' | 'borderCallout1' | 'borderCallout2' | 'borderCallout3' | 'bracePair' | 'bracketPair' | 'callout1' | 'callout2' | 'callout3' | 'can' | 'chartPlus' | 'chartStar' | 'chartX' | 'chevron' | 'chord' | 'circularArrow' | 'cloud' | 'cloudCallout' | 'corner' | 'cornerTabs' | 'cube' | 'curvedConnector2' | 'curvedConnector3' | 'curvedConnector4' | 'curvedConnector5' | 'curvedDownArrow' | 'curvedLeftArrow' | 'curvedRightArrow' | 'curvedUpArrow' | 'decagon' | 'diagStripe' | 'diamond' | 'dodecagon' | 'donut' | 'doubleWave' | 'downArrow' | 'downArrowCallout' | 'ellipse' | 'ellipseRibbon' | 'ellipseRibbon2' | 'flowChartAlternateProcess' | 'flowChartCollate' | 'flowChartConnector' | 'flowChartDecision' | 'flowChartDelay' | 'flowChartDisplay' | 'flowChartDocument' | 'flowChartExtract' | 'flowChartInputOutput' | 'flowChartInternalStorage' | 'flowChartMagneticDisk' | 'flowChartMagneticDrum' | 'flowChartMagneticTape' | 'flowChartManualInput' | 'flowChartManualOperation' | 'flowChartMerge' | 'flowChartMultidocument' | 'flowChartOfflineStorage' | 'flowChartOffpageConnector' | 'flowChartOnlineStorage' | 'flowChartOr' | 'flowChartPredefinedProcess' | 'flowChartPreparation' | 'flowChartProcess' | 'flowChartPunchedCard' | 'flowChartPunchedTape' | 'flowChartSort' | 'flowChartSummingJunction' | 'flowChartTerminator' | 'foldedCorner' | 'frame' | 'funnel' | 'gear6' | 'gear9' | 'halfFrame' | 'heart' | 'heptagon' | 'hexagon' | 'homePlate' | 'horizontalScroll' | 'irregularSeal1' | 'irregularSeal2' | 'leftArrow' | 'leftArrowCallout' | 'leftBrace' | 'leftBracket' | 'leftCircularArrow' | 'leftRightArrow' | 'leftRightArrowCallout' | 'leftRightCircularArrow' | 'leftRightRibbon' | 'leftRightUpArrow' | 'leftUpArrow' | 'lightningBolt' | 'line' | 'lineInv' | 'mathDivide' | 'mathEqual' | 'mathMinus' | 'mathMultiply' | 'mathNotEqual' | 'mathPlus' | 'moon' | 'noSmoking' | 'nonIsoscelesTrapezoid' | 'notchedRightArrow' | 'octagon' | 'parallelogram' | 'pentagon' | 'pie' | 'pieWedge' | 'plaque' | 'plaqueTabs' | 'plus' | 'quadArrow' | 'quadArrowCallout' | 'rect' | 'ribbon' | 'ribbon2' | 'rightArrow' | 'rightArrowCallout' | 'rightBrace' | 'rightBracket' | 'round1Rect' | 'round2DiagRect' | 'round2SameRect' | 'roundRect' | 'rtTriangle' | 'smileyFace' | 'snip1Rect' | 'snip2DiagRect' | 'snip2SameRect' | 'snipRoundRect' | 'squareTabs' | 'star10' | 'star12' | 'star16' | 'star24' | 'star32' | 'star4' | 'star5' | 'star6' | 'star7' | 'star8' | 'straightConnector1' | 'stripedRightArrow' | 'sun' | 'swooshArrow' | 'teardrop' | 'trapezoid' | 'triangle' | 'upArrow' | 'upArrowCallout' | 'upDownArrow' | 'upDownArrowCallout' | 'uturnArrow' | 'verticalScroll' | 'wave' | 'wedgeEllipseCallout' | 'wedgeRectCallout' | 'wedgeRoundRectCallout';
138
+ /** A theme colour, in the theme's order. */
139
+ export type ThemeColour = 'text1' | 'background1' | 'text2' | 'background2' | 'accent1' | 'accent2' | 'accent3' | 'accent4' | 'accent5' | 'accent6' | 'hyperlink' | 'followedHyperlink';
140
+ /**
141
+ * What a colour transform does: `tint` and `shade` go towards white and black by `1 - value`; `lumMod`, `satMod`,
142
+ * `hueMod` and `alphaMod` multiply the luminance, saturation, hue and opacity by `value`; `lumOff`, `satOff` and
143
+ * `hueOff` add `value` (degrees for `hueOff`); `alpha` sets the opacity.
144
+ */
145
+ export type TransformKind = 'tint' | 'shade' | 'lumMod' | 'lumOff' | 'satMod' | 'satOff' | 'hueMod' | 'hueOff' | 'alpha' | 'alphaMod';
146
+ /** One colour transform. */
147
+ export interface ColourTransform {
148
+ /** What it does. */
149
+ kind: TransformKind;
150
+ /** How much: a fraction (0.75), degrees for `hueOff`. */
151
+ value: number;
152
+ }
153
+ /** A colour as written: exactly one base (a theme colour, an RGB value or a preset colour name), then its transforms. */
154
+ export interface ColourValue {
155
+ /** A theme colour. */
156
+ theme?: ThemeColour;
157
+ /** An RGB colour. */
158
+ rgb?: Color;
159
+ /** A preset colour by its CSS name (`'cornflowerBlue'`). */
160
+ preset?: string;
161
+ /** The transforms, applied in order. */
162
+ transforms?: ColourTransform[];
163
+ }
164
+ /** A gradient's shape: along a direction, circles or rectangles from the centre, or following the shape's outline. */
165
+ export type GradientShape = 'linear' | 'radial' | 'rectangular' | 'path';
166
+ /** A gradient stop. */
167
+ export interface GradientStop {
168
+ /** 0 to 1 along the gradient. */
169
+ position: number;
170
+ /** The colour there. */
171
+ colour: ColourValue;
172
+ }
173
+ /**
174
+ * A fill: none, one colour, a gradient of two or more stops (a linear one's `angle`, 0 left to right), a two-colour
175
+ * pattern by its ECMA-376 name (`'pct50'`, `'dkDnDiag'`), a picture (PNG, JPEG, GIF, BMP; tiled at its own size, or
176
+ * stretched), or `fromStyle`: the style reference's fill, no explicit one.
177
+ */
178
+ export type FillValue = {
179
+ type: 'none';
180
+ } | {
181
+ type: 'solid';
182
+ colour: ColourValue;
183
+ } | {
184
+ type: 'gradient';
185
+ kind: GradientShape;
186
+ angle?: Degrees;
187
+ stops: GradientStop[];
188
+ } | {
189
+ type: 'pattern';
190
+ preset: string;
191
+ foreground: ColourValue;
192
+ background: ColourValue;
193
+ } | {
194
+ type: 'picture';
195
+ image: Uint8Array;
196
+ tile?: boolean;
197
+ } | {
198
+ type: 'fromStyle';
199
+ };
200
+ /** How a line is drawn along its length: one line, two equal ones, thick then thin, thin then thick, or three. */
201
+ export type Compound = 'single' | 'double' | 'thickThin' | 'thinThick' | 'triple';
202
+ /** A line's ends: square at the end, rounded, or square half the width past the end. */
203
+ export type LineCap = 'flat' | 'round' | 'square';
204
+ /** How a line's segments join: rounded, cut off, or pointed. */
205
+ export type LineJoin = 'round' | 'bevel' | 'miter';
206
+ /** An arrowhead's shape: a filled triangle, a notched triangle, a diamond, an oval or an open V. */
207
+ export type ArrowKind = 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow';
208
+ /** An arrowhead's width or length. */
209
+ export type ArrowSize = 'small' | 'medium' | 'large';
210
+ /** An arrowhead. */
211
+ export interface Arrowhead {
212
+ /** Its shape. */
213
+ kind: ArrowKind;
214
+ /** Its width; default `'medium'`. */
215
+ width?: ArrowSize;
216
+ /** Its length; default `'medium'`. */
217
+ length?: ArrowSize;
218
+ }
219
+ /** A line's arrowheads. */
220
+ export interface LineEnds {
221
+ /** At the start. */
222
+ head?: Arrowhead;
223
+ /** At the end. */
224
+ tail?: Arrowhead;
225
+ }
226
+ /** An outline as written. */
227
+ export interface LineValue {
228
+ /** The width (0.75 when the document gives none). */
229
+ width: Points;
230
+ /** `none`, `solid` or `gradient`. */
231
+ fill: FillValue;
232
+ /** The ECMA-376 dash name (`'solid'`, `'dash'`, `'sysDot'`…); `'custom'` for a custom dash. */
233
+ dash: string;
234
+ /** Single or several lines. */
235
+ compound: Compound;
236
+ /** The ends. */
237
+ cap: LineCap;
238
+ /** The joins. */
239
+ join: LineJoin;
240
+ /** The arrowheads. */
241
+ ends: LineEnds;
242
+ }
243
+ /** `setShapeLine`'s change; what isn't given is kept. */
244
+ export interface LineChange {
245
+ /** The width, 0 to 1584. */
246
+ width?: Points;
247
+ /** `none`, `solid` or `gradient`; `fromStyle` removes the whole explicit outline. */
248
+ fill?: FillValue;
249
+ /** The ECMA-376 dash name. */
250
+ dash?: string;
251
+ /** Single or several lines. */
252
+ compound?: Compound;
253
+ /** The ends. */
254
+ cap?: LineCap;
255
+ /** The joins. */
256
+ join?: LineJoin;
257
+ /** The arrowheads: both ends are replaced, and an end not given is removed. */
258
+ ends?: LineEnds;
259
+ }
260
+ /** A shadow. */
261
+ export interface Shadow {
262
+ /** Its colour, with its transparency as an `alpha` transform. */
263
+ colour: ColourValue;
264
+ /** How far it blurs. */
265
+ blur: Points;
266
+ /** How far from the shape. */
267
+ distance: Points;
268
+ /** Which way, clockwise from the right. */
269
+ direction: Degrees;
270
+ }
271
+ /** A glow. */
272
+ export interface Glow {
273
+ /** Its colour. */
274
+ colour: ColourValue;
275
+ /** How far it reaches. */
276
+ radius: Points;
277
+ }
278
+ /** A shape's effects. */
279
+ export interface EffectsValue {
280
+ /** A shadow outside the shape. */
281
+ outerShadow?: Shadow;
282
+ /** A shadow inside the shape. */
283
+ innerShadow?: Shadow;
284
+ /** A glow around the shape. */
285
+ glow?: Glow;
286
+ /** Edges faded over this distance. */
287
+ softEdge?: Points;
288
+ /** The whole shape blurred by this radius. */
289
+ blur?: Points;
290
+ }
291
+ /** `setShapeEffects`'s change: each effect given replaces that effect, `null` removes it, what isn't given is kept. */
292
+ export interface EffectsChange {
293
+ /** A shadow outside the shape. */
294
+ outerShadow?: Shadow | null;
295
+ /** A shadow inside the shape. */
296
+ innerShadow?: Shadow | null;
297
+ /** A glow around the shape. */
298
+ glow?: Glow | null;
299
+ /** Edges faded over this distance. */
300
+ softEdge?: Points | null;
301
+ /** The whole shape blurred by this radius. */
302
+ blur?: Points | null;
303
+ }
304
+ /** Where text sits in a shape vertically. */
305
+ export type TextAnchor = 'top' | 'middle' | 'bottom';
306
+ /** How a shape fits its text: it keeps its size, or its height follows the text. */
307
+ export type TextAutofit = 'none' | 'shape';
308
+ /**
309
+ * Which way a shape's text runs: left to right; turned 90° or 270° clockwise; East Asian vertical (CJK upright,
310
+ * other text turned); Mongolian vertical; letters stacked one per line, or stacked right to left.
311
+ */
312
+ export type TextDirection = 'horizontal' | 'vertical' | 'vertical270' | 'eastAsianVertical' | 'mongolianVertical' | 'stacked' | 'stackedRightToLeft';
313
+ /** A shape's text body as written. */
314
+ export interface ShapeTextState {
315
+ /** Left, top, right, bottom. */
316
+ insets: [Points, Points, Points, Points];
317
+ /** Where the text sits. */
318
+ anchor: TextAnchor;
319
+ /** How the shape fits it. */
320
+ autofit: TextAutofit;
321
+ /** Lines wrap at the shape's width. */
322
+ wrapText: boolean;
323
+ /** Which way it runs. */
324
+ direction: TextDirection;
325
+ }
326
+ /** `setShapeText`'s change; what isn't given is kept. */
327
+ export interface ShapeTextChange {
328
+ /** Left, top, right, bottom, 0 to 1584. */
329
+ insets?: [Points, Points, Points, Points];
330
+ /** Where the text sits. */
331
+ anchor?: TextAnchor;
332
+ /** How the shape fits it. */
333
+ autofit?: TextAutofit;
334
+ /** Lines wrap at the shape's width. */
335
+ wrapText?: boolean;
336
+ /** Which way it runs. */
337
+ direction?: TextDirection;
338
+ }
339
+ /** `setPictureAdjust`'s change; what isn't given is kept. */
340
+ export interface PictureAdjustChange {
341
+ /** How see-through the picture is: 0 opaque to 1 invisible. */
342
+ transparency?: number;
343
+ /** Shown in shades of grey. */
344
+ grayscale?: boolean;
345
+ /** Lighter (positive) or darker, −1 to 1. */
346
+ brightness?: number;
347
+ /** More (positive) or less contrast, −1 to 1. */
348
+ contrast?: number;
349
+ }
350
+ /** `insertShape`'s options. */
351
+ export interface ShapeInsert {
352
+ /** The preset geometry. */
353
+ preset: ShapePreset;
354
+ /** The width; default 72. */
355
+ width?: Points;
356
+ /** The height; default 72, 0 for lines. */
357
+ height?: Points;
358
+ }
359
+ /** `setShapeAdjust`'s options. */
360
+ export interface ShapeAdjust {
361
+ /** The adjust value's index, in the preset's order. */
362
+ index: number;
363
+ /** Its new value, in the preset's units (usually 100000ths). */
364
+ value: number;
365
+ }
366
+ /** Which way to flip: left to right, or top to bottom. */
367
+ export type FlipAxis = 'horizontal' | 'vertical';
368
+ /**
369
+ * Where an object goes in the paint order: over the next object above it, under the next one below it, over or
370
+ * under every object, or in front of or behind the text.
371
+ */
372
+ export type Arrange = 'forward' | 'backward' | 'toFront' | 'toBack' | 'inFrontOfText' | 'behindText';
373
+ /** A fill as written: the shape's own, or its style reference's (the theme's, with the reference's colour). */
374
+ export type FillState = {
375
+ explicit: FillValue;
376
+ } | {
377
+ fromStyle: FillValue;
378
+ };
379
+ /** An outline as written: the shape's own, or its style reference's. */
380
+ export type LineState = {
381
+ explicit: LineValue;
382
+ } | {
383
+ fromStyle: LineValue;
384
+ };
385
+ /** The selected shape's properties, as written: theme colours stay theme colours with their transforms. */
386
+ export interface ShapeState {
387
+ /** The preset geometry; `null` for a custom geometry. */
388
+ preset: ShapePreset | null;
389
+ /** The adjust values in effect, in the preset's order. */
390
+ adjust: number[];
391
+ /** The fill. */
392
+ fill: FillState;
393
+ /** The outline. */
394
+ line: LineState;
395
+ /** The effects. */
396
+ effects: EffectsValue;
397
+ /** The text body; `null` for pictures and groups. */
398
+ text: ShapeTextState | null;
399
+ }
400
+ /** A group of Word's Insert \> Shapes gallery. */
401
+ export interface ShapeGalleryGroup {
402
+ /** Its label (`'Basic Shapes'`). */
403
+ label: string;
404
+ /** Its presets, in Word's order. */
405
+ presets: ShapePreset[];
406
+ }
134
407
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twip/web",
3
- "version": "0.0.0-canary-4e9c983",
3
+ "version": "0.0.0-canary-8e34765",
4
4
  "description": "The Twip DOCX editor for the browser and Node: a managed, framework-independent editor over the WebAssembly engine.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",