@twip/web 0.1.0-alpha.1 → 0.1.0-pre.1
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/README.md +35 -0
- package/dist/THIRD-PARTY-NOTICES.md +1009 -221
- package/dist/commands.d.ts +637 -0
- package/dist/commands.js +188 -0
- package/dist/editor.d.ts +218 -0
- package/dist/editor.js +460 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +26 -0
- package/dist/events.d.ts +126 -0
- package/dist/events.js +1 -0
- package/dist/fonts/google.d.ts +3 -0
- package/dist/fonts/google.js +39 -0
- package/dist/fonts/library.d.ts +65 -0
- package/dist/fonts/library.js +130 -0
- package/dist/host/a11y.d.ts +3 -0
- package/dist/host/a11y.js +62 -0
- package/dist/host/chrome.d.ts +28 -0
- package/dist/host/chrome.js +144 -0
- package/dist/host/clipboard.d.ts +16 -0
- package/dist/host/clipboard.js +128 -0
- package/dist/host/dom.d.ts +45 -0
- package/dist/host/dom.js +122 -0
- package/dist/host/frames.d.ts +14 -0
- package/dist/host/frames.js +87 -0
- package/dist/host/gpu.d.ts +58 -0
- package/dist/host/gpu.js +79 -0
- package/dist/host/ime.d.ts +3 -0
- package/dist/host/ime.js +11 -0
- package/dist/host/input.d.ts +12 -0
- package/dist/host/input.js +86 -0
- package/dist/host/keys.d.ts +16 -0
- package/dist/host/keys.js +27 -0
- package/dist/host/mount.d.ts +11 -0
- package/dist/host/mount.js +72 -0
- package/dist/host/pointer.d.ts +4 -0
- package/dist/host/pointer.js +171 -0
- package/dist/host/scroll.d.ts +14 -0
- package/dist/host/scroll.js +95 -0
- package/dist/index.d.ts +27 -98
- package/dist/index.js +10 -0
- package/dist/review.d.ts +156 -0
- package/dist/review.js +38 -0
- package/dist/services/accessibility.d.ts +52 -0
- package/dist/services/accessibility.js +71 -0
- package/dist/services/dialogs.d.ts +181 -0
- package/dist/services/dialogs.js +18 -0
- package/dist/services/elements.d.ts +146 -0
- package/dist/services/elements.js +18 -0
- package/dist/services/find.d.ts +50 -0
- package/dist/services/find.js +12 -0
- package/dist/services/menus.d.ts +82 -0
- package/dist/services/menus.js +8 -0
- package/dist/services/navigation.d.ts +58 -0
- package/dist/services/navigation.js +12 -0
- package/dist/services/ruler.d.ts +95 -0
- package/dist/services/ruler.js +16 -0
- package/dist/services/spelling.d.ts +34 -0
- package/dist/services/spelling.js +14 -0
- package/dist/services/view.d.ts +70 -0
- package/dist/services/view.js +19 -0
- package/dist/state.d.ts +483 -0
- package/dist/state.js +1 -0
- package/dist/transport/direct.d.ts +31 -0
- package/dist/transport/direct.js +405 -0
- package/dist/transport/module.d.ts +51 -0
- package/dist/transport/module.js +17 -0
- package/dist/transport/protocol.d.ts +265 -0
- package/dist/transport/protocol.js +132 -0
- package/dist/transport/worker.d.ts +54 -0
- package/dist/transport/worker.js +203 -0
- package/dist/twip-wasm.js +1 -1
- package/dist/twip_wasm.wasm +0 -0
- package/dist/types.d.ts +134 -0
- package/dist/types.js +16 -0
- package/dist/worker/entry.d.ts +1 -0
- package/dist/worker/entry.js +53 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +2 -0
- package/package.json +12 -7
- package/dist/AccessibleNode.d.ts +0 -51
- package/dist/AccessibleNode.mjs +0 -177
- package/dist/Alignment.d.ts +0 -38
- package/dist/Alignment.mjs +0 -90
- package/dist/BorderEdges.d.ts +0 -50
- package/dist/BorderEdges.mjs +0 -114
- package/dist/BorderStyle.d.ts +0 -27
- package/dist/BorderStyle.mjs +0 -81
- package/dist/Bytes.d.ts +0 -19
- package/dist/Bytes.mjs +0 -76
- package/dist/CaretPosition.d.ts +0 -34
- package/dist/CaretPosition.mjs +0 -148
- package/dist/CellAlignment.d.ts +0 -25
- package/dist/CellAlignment.mjs +0 -75
- package/dist/CellShift.d.ts +0 -30
- package/dist/CellShift.mjs +0 -78
- package/dist/Clipboard.d.ts +0 -22
- package/dist/Clipboard.mjs +0 -90
- package/dist/ColumnSide.d.ts +0 -24
- package/dist/ColumnSide.mjs +0 -72
- package/dist/ControlKind.d.ts +0 -28
- package/dist/ControlKind.mjs +0 -84
- package/dist/ControlLock.d.ts +0 -42
- package/dist/ControlLock.mjs +0 -96
- package/dist/DocumentStatus.d.ts +0 -34
- package/dist/DocumentStatus.mjs +0 -148
- package/dist/Editor.d.ts +0 -773
- package/dist/Editor.mjs +0 -2269
- package/dist/EditorMode.d.ts +0 -34
- package/dist/EditorMode.mjs +0 -84
- package/dist/Element.d.ts +0 -57
- package/dist/Element.mjs +0 -201
- package/dist/ElementKind.d.ts +0 -28
- package/dist/ElementKind.mjs +0 -78
- package/dist/ElementList.d.ts +0 -20
- package/dist/ElementList.mjs +0 -71
- package/dist/ElementText.d.ts +0 -34
- package/dist/ElementText.mjs +0 -84
- package/dist/Event.d.ts +0 -45
- package/dist/Event.mjs +0 -159
- package/dist/EventKind.d.ts +0 -39
- package/dist/EventKind.mjs +0 -93
- package/dist/EventList.d.ts +0 -20
- package/dist/EventList.mjs +0 -71
- package/dist/Fonts.d.ts +0 -29
- package/dist/Fonts.mjs +0 -107
- package/dist/Highlight.d.ts +0 -41
- package/dist/Highlight.mjs +0 -117
- package/dist/MarginPreset.d.ts +0 -38
- package/dist/MarginPreset.mjs +0 -90
- package/dist/MarkSeverity.d.ts +0 -25
- package/dist/MarkSeverity.mjs +0 -75
- package/dist/Modifiers.d.ts +0 -34
- package/dist/Modifiers.mjs +0 -148
- package/dist/OpenError.d.ts +0 -30
- package/dist/OpenError.mjs +0 -78
- package/dist/Orientation.d.ts +0 -30
- package/dist/Orientation.mjs +0 -78
- package/dist/PageNumber.d.ts +0 -34
- package/dist/PageNumber.mjs +0 -84
- package/dist/PaperSize.d.ts +0 -50
- package/dist/PaperSize.mjs +0 -108
- package/dist/ParagraphBorders.d.ts +0 -34
- package/dist/ParagraphBorders.mjs +0 -84
- package/dist/PictureWrap.d.ts +0 -34
- package/dist/PictureWrap.mjs +0 -90
- package/dist/PointerKind.d.ts +0 -23
- package/dist/PointerKind.mjs +0 -75
- package/dist/Rect.d.ts +0 -34
- package/dist/Rect.mjs +0 -148
- package/dist/Request.d.ts +0 -55
- package/dist/Request.mjs +0 -207
- package/dist/RequestKind.d.ts +0 -45
- package/dist/RequestKind.mjs +0 -105
- package/dist/RequestList.d.ts +0 -20
- package/dist/RequestList.mjs +0 -71
- package/dist/RowHeightRule.d.ts +0 -34
- package/dist/RowHeightRule.mjs +0 -84
- package/dist/RowSide.d.ts +0 -24
- package/dist/RowSide.mjs +0 -72
- package/dist/SaveError.d.ts +0 -24
- package/dist/SaveError.mjs +0 -72
- package/dist/SelectionInfo.d.ts +0 -39
- package/dist/SelectionInfo.mjs +0 -166
- package/dist/SelectionKind.d.ts +0 -37
- package/dist/SelectionKind.mjs +0 -93
- package/dist/TableAlignment.d.ts +0 -25
- package/dist/TableAlignment.mjs +0 -75
- package/dist/TableSelection.d.ts +0 -38
- package/dist/TableSelection.mjs +0 -90
- package/dist/TableWidthUnit.d.ts +0 -31
- package/dist/TableWidthUnit.mjs +0 -81
- package/dist/TextUnit.d.ts +0 -25
- package/dist/TextUnit.mjs +0 -75
- package/dist/diplomat-runtime.d.ts +0 -15
- package/dist/diplomat-runtime.mjs +0 -786
- package/dist/diplomat-wasm.mjs +0 -18
- package/dist/gpu.d.ts +0 -15
- package/dist/gpu.mjs +0 -42
- package/dist/index.mjs +0 -101
package/dist/twip_wasm.wasm
CHANGED
|
Binary file
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/** A length in points (1/72 inch). Every length in the API is in points. */
|
|
2
|
+
export type Points = number;
|
|
3
|
+
/** A colour as `#RRGGBB`. */
|
|
4
|
+
export type Color = `#${string}`;
|
|
5
|
+
/** Converts inches to points. */
|
|
6
|
+
export declare function inches(n: number): Points;
|
|
7
|
+
/** Converts centimetres to points. */
|
|
8
|
+
export declare function cm(n: number): Points;
|
|
9
|
+
/** Converts millimetres to points. */
|
|
10
|
+
export declare function mm(n: number): Points;
|
|
11
|
+
/** Returns `n` points: for call sites that state their unit. */
|
|
12
|
+
export declare function pt(n: number): Points;
|
|
13
|
+
declare const brand: unique symbol;
|
|
14
|
+
/** A merge-designer element (a field or a content control). Stable while the document is open. */
|
|
15
|
+
export type ElementId = string & {
|
|
16
|
+
readonly [brand]: 'element';
|
|
17
|
+
};
|
|
18
|
+
/** A comment. Stable while the document is open. */
|
|
19
|
+
export type CommentId = string & {
|
|
20
|
+
readonly [brand]: 'comment';
|
|
21
|
+
};
|
|
22
|
+
/** A tracked revision. Stable while the document is open. */
|
|
23
|
+
export type RevisionId = string & {
|
|
24
|
+
readonly [brand]: 'revision';
|
|
25
|
+
};
|
|
26
|
+
/** A heading in the navigation list. */
|
|
27
|
+
export type HeadingId = string & {
|
|
28
|
+
readonly [brand]: 'heading';
|
|
29
|
+
};
|
|
30
|
+
/** A find match. */
|
|
31
|
+
export type MatchId = string & {
|
|
32
|
+
readonly [brand]: 'match';
|
|
33
|
+
};
|
|
34
|
+
/** A style. */
|
|
35
|
+
export type StyleId = string & {
|
|
36
|
+
readonly [brand]: 'style';
|
|
37
|
+
};
|
|
38
|
+
/** A point relative to the browser viewport, in CSS pixels, like `MouseEvent.clientX`. */
|
|
39
|
+
export interface ClientPoint {
|
|
40
|
+
/** CSS pixels from the viewport's left edge. */
|
|
41
|
+
clientX: number;
|
|
42
|
+
/** CSS pixels from the viewport's top edge. */
|
|
43
|
+
clientY: number;
|
|
44
|
+
}
|
|
45
|
+
/** The colours of what the editor draws over the document (`view.setOverlayColors`). */
|
|
46
|
+
export interface OverlayColors {
|
|
47
|
+
/** The caret. Default black. */
|
|
48
|
+
caret: Color;
|
|
49
|
+
/** The selection, blended under the text (multiply), so black text stays black. Default `'#4A90D9'`. */
|
|
50
|
+
selection: Color;
|
|
51
|
+
/** A selected object's outline and handles. Default `'#606060'`. */
|
|
52
|
+
object: Color;
|
|
53
|
+
/** The drop caret of a drag. Default `'#404040'`. */
|
|
54
|
+
drop: Color;
|
|
55
|
+
/** Formatting marks and text boundaries. Default `'#2F6FB5'`. */
|
|
56
|
+
marks: Color;
|
|
57
|
+
/** The markup pane's leader lines. Default `'#767676'`. */
|
|
58
|
+
leaders: Color;
|
|
59
|
+
}
|
|
60
|
+
/** What a mounted editor's frames have cost so far (`view.frameStats()`): for benchmarks and tests. */
|
|
61
|
+
export interface FrameStats {
|
|
62
|
+
/** Frames drawn. */
|
|
63
|
+
frames: number;
|
|
64
|
+
/** Page recordings made: an unchanged page is recorded once. */
|
|
65
|
+
pagesRecorded: number;
|
|
66
|
+
/** Pages drawn again from their recordings. */
|
|
67
|
+
pagesReused: number;
|
|
68
|
+
/** The page recordings kept now, bytes. */
|
|
69
|
+
recordingBytes: number;
|
|
70
|
+
/** The last frame's time, ms. */
|
|
71
|
+
lastFrameMs: number;
|
|
72
|
+
/** The 95th percentile of the last 120 frames' times, ms. */
|
|
73
|
+
p95FrameMs: number;
|
|
74
|
+
}
|
|
75
|
+
/** A rectangle relative to the browser viewport, in CSS pixels. */
|
|
76
|
+
export interface ClientRect {
|
|
77
|
+
/** The left edge. */
|
|
78
|
+
left: number;
|
|
79
|
+
/** The top edge. */
|
|
80
|
+
top: number;
|
|
81
|
+
/** The width. */
|
|
82
|
+
width: number;
|
|
83
|
+
/** The height. */
|
|
84
|
+
height: number;
|
|
85
|
+
}
|
|
86
|
+
/** A point relative to the editor's balloon layer, in CSS pixels: it scrolls and zooms with the document. */
|
|
87
|
+
export interface ContentPoint {
|
|
88
|
+
/** CSS pixels from the layer's left edge. */
|
|
89
|
+
x: number;
|
|
90
|
+
/** CSS pixels from the layer's top edge. */
|
|
91
|
+
y: number;
|
|
92
|
+
}
|
|
93
|
+
/** Who makes changes: recorded on transactions, revisions and comments. */
|
|
94
|
+
export interface Author {
|
|
95
|
+
/** The display name. */
|
|
96
|
+
name: string;
|
|
97
|
+
/** The initials shown on comments. */
|
|
98
|
+
initials?: string;
|
|
99
|
+
/** The identity in a directory, written to the document with the author. */
|
|
100
|
+
identity?: {
|
|
101
|
+
provider: string;
|
|
102
|
+
userId: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** A recoverable fidelity issue found while reading or writing a document. Aggregated per code and part. */
|
|
106
|
+
export interface Warning {
|
|
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';
|
|
109
|
+
/** A readable description. */
|
|
110
|
+
message: string;
|
|
111
|
+
/** How many times it occurred. */
|
|
112
|
+
count: number;
|
|
113
|
+
/** Where it occurred, when known. */
|
|
114
|
+
location?: {
|
|
115
|
+
part: string;
|
|
116
|
+
paragraph?: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Word, character, paragraph, line and page counts, computed on request. */
|
|
120
|
+
export interface WordCount {
|
|
121
|
+
/** Words. */
|
|
122
|
+
words: number;
|
|
123
|
+
/** Characters, without spaces. */
|
|
124
|
+
characters: number;
|
|
125
|
+
/** Characters, with spaces. */
|
|
126
|
+
charactersWithSpaces: number;
|
|
127
|
+
/** Paragraphs. */
|
|
128
|
+
paragraphs: number;
|
|
129
|
+
/** Lines. */
|
|
130
|
+
lines: number;
|
|
131
|
+
/** Pages. */
|
|
132
|
+
pages: number;
|
|
133
|
+
}
|
|
134
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Converts inches to points. */
|
|
2
|
+
export function inches(n) {
|
|
3
|
+
return n * 72;
|
|
4
|
+
}
|
|
5
|
+
/** Converts centimetres to points. */
|
|
6
|
+
export function cm(n) {
|
|
7
|
+
return (n * 72) / 2.54;
|
|
8
|
+
}
|
|
9
|
+
/** Converts millimetres to points. */
|
|
10
|
+
export function mm(n) {
|
|
11
|
+
return (n * 72) / 25.4;
|
|
12
|
+
}
|
|
13
|
+
/** Returns `n` points: for call sites that state their unit. */
|
|
14
|
+
export function pt(n) {
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// The page's engine worker: one per page hosts every editor's session in one module instance, so fonts, dictionaries
|
|
2
|
+
// and the internal clipboard are shared. It runs each posted call through a DirectTransport, whose queue keeps them in
|
|
3
|
+
// arrival order, and relays the sessions' { kind, sessionId, payload } messages ahead of each reply. A session's canvas
|
|
4
|
+
// moves here, and its frames are drawn here when the page's frame loop asks (host/frames.ts); the engine's timers run
|
|
5
|
+
// on this thread.
|
|
6
|
+
import { EditorError } from '../errors.js';
|
|
7
|
+
import { directTransport } from '../transport/direct.js';
|
|
8
|
+
import { fromError } from '../transport/protocol.js';
|
|
9
|
+
const engine = directTransport();
|
|
10
|
+
const signals = new Map();
|
|
11
|
+
/** Posts to the page, moving the buffer of exported bytes instead of copying it. */
|
|
12
|
+
function post(message) {
|
|
13
|
+
const bytes = 'ok' in message ? message.ok?.bytes : undefined;
|
|
14
|
+
postMessage(message, { transfer: bytes instanceof Uint8Array && bytes.buffer instanceof ArrayBuffer ? [bytes.buffer] : [] });
|
|
15
|
+
}
|
|
16
|
+
/** Runs one request on the engine. */
|
|
17
|
+
function run(t, { id, op, args }) {
|
|
18
|
+
switch (op) {
|
|
19
|
+
case 'createSession':
|
|
20
|
+
return t.createSession(args[0]).then((session) => {
|
|
21
|
+
t.listen(session, post);
|
|
22
|
+
return session;
|
|
23
|
+
});
|
|
24
|
+
case 'attachCanvas':
|
|
25
|
+
// An OffscreenCanvas: the GPU and CPU paths take either kind of canvas.
|
|
26
|
+
return t.attachCanvas(args[0], args[1]);
|
|
27
|
+
case 'open':
|
|
28
|
+
case 'export': {
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
signals.set(id, controller);
|
|
31
|
+
const call = t[op];
|
|
32
|
+
return call.call(t, ...args, controller.signal).finally(() => signals.delete(id));
|
|
33
|
+
}
|
|
34
|
+
default:
|
|
35
|
+
return t[op].apply(t, args);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Session 0 is the engine's own: font requests.
|
|
39
|
+
engine.then((t) => t.listen(0, post), () => { });
|
|
40
|
+
onmessage = ({ data }) => {
|
|
41
|
+
if (data.op === 'abort') {
|
|
42
|
+
signals.get(data.id)?.abort();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Every request waits on the same promise, so they reach the engine's queue in arrival order. Id 0 is a replayed
|
|
46
|
+
// library change: nothing waits for its reply.
|
|
47
|
+
engine.then((t) => run(t, data)).then((ok) => data.id && post({ id: data.id, ok }), (e) => {
|
|
48
|
+
if (!data.id)
|
|
49
|
+
return console.error(e);
|
|
50
|
+
const error = e instanceof EditorError ? e : new EditorError('internal', String(e), { cause: e });
|
|
51
|
+
post({ id: data.id, error: fromError(error), fatal: error.fatal });
|
|
52
|
+
});
|
|
53
|
+
};
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './worker/entry.js';
|
package/dist/worker.js
ADDED
package/package.json
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twip/web",
|
|
3
|
-
"version": "0.1.0-
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-pre.1",
|
|
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",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
"node": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./worker.js": "./dist/worker.js"
|
|
12
14
|
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
13
16
|
"files": [
|
|
14
17
|
"dist"
|
|
15
18
|
],
|
|
16
19
|
"devDependencies": {
|
|
17
|
-
"@
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
"@microsoft/api-extractor": "7.60.0",
|
|
21
|
+
"@playwright/test": "1.64.1",
|
|
22
|
+
"@types/node": "26.6.5",
|
|
23
|
+
"typescript": "7.0.2"
|
|
24
|
+
}
|
|
20
25
|
}
|
package/dist/AccessibleNode.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// generated by diplomat-tool
|
|
2
|
-
import type { Rect } from "./Rect"
|
|
3
|
-
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A node of the document's reading structure (headings, paragraphs, lists, tables, rows, cells), for screen
|
|
9
|
-
* readers and other assistive technology.
|
|
10
|
-
*/
|
|
11
|
-
export class AccessibleNode {
|
|
12
|
-
/** @internal */
|
|
13
|
-
get ffiValue(): pointer;
|
|
14
|
-
/** @internal */
|
|
15
|
-
constructor();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The role: `document`, `heading`, `paragraph`, `list`, `listitem`, `table`, `row`, `cell`, ...
|
|
20
|
-
*/
|
|
21
|
-
role(): string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The heading level (0 when not a heading).
|
|
25
|
-
*/
|
|
26
|
-
get level(): number;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The accessible name (a list item's label, a cell's position, ...), empty if none.
|
|
30
|
-
*/
|
|
31
|
-
label(): string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* How many drawn lines the node's own text has.
|
|
35
|
-
*/
|
|
36
|
-
get lineCount(): number;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* A line's text.
|
|
40
|
-
*/
|
|
41
|
-
lineText(index: number): string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A line's box, content pixels.
|
|
45
|
-
*/
|
|
46
|
-
lineRect(index: number): Rect;
|
|
47
|
-
|
|
48
|
-
get childCount(): number;
|
|
49
|
-
|
|
50
|
-
child(index: number): AccessibleNode | null;
|
|
51
|
-
}
|
package/dist/AccessibleNode.mjs
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// generated by diplomat-tool
|
|
2
|
-
import { Rect } from "./Rect.mjs"
|
|
3
|
-
import wasm from "./diplomat-wasm.mjs";
|
|
4
|
-
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
5
|
-
|
|
6
|
-
const AccessibleNode_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
-
wasm.AccessibleNode_destroy(ptr);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A node of the document's reading structure (headings, paragraphs, lists, tables, rows, cells), for screen
|
|
12
|
-
* readers and other assistive technology.
|
|
13
|
-
*/
|
|
14
|
-
export class AccessibleNode {
|
|
15
|
-
// Internal ptr reference:
|
|
16
|
-
#ptr = null;
|
|
17
|
-
|
|
18
|
-
// Lifetimes are only to keep dependencies alive.
|
|
19
|
-
// Since JS won't garbage collect until there are no incoming edges.
|
|
20
|
-
#selfEdge = [];
|
|
21
|
-
|
|
22
|
-
#internalConstructor(symbol, ptr, selfEdge) {
|
|
23
|
-
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
24
|
-
console.error("AccessibleNode is an Opaque type. You cannot call its constructor.");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.#ptr = ptr;
|
|
28
|
-
this.#selfEdge = selfEdge;
|
|
29
|
-
|
|
30
|
-
// Are we being borrowed? If not, we can register.
|
|
31
|
-
if (this.#selfEdge.length === 0) {
|
|
32
|
-
AccessibleNode_box_destroy_registry.register(this, this.#ptr);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
/** @internal */
|
|
38
|
-
get ffiValue() {
|
|
39
|
-
return this.#ptr;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The role: `document`, `heading`, `paragraph`, `list`, `listitem`, `table`, `row`, `cell`, ...
|
|
45
|
-
*/
|
|
46
|
-
role() {
|
|
47
|
-
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
48
|
-
|
|
49
|
-
wasm.AccessibleNode_role(this.ffiValue, write.buffer);
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
return write.readString8();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
finally {
|
|
56
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
57
|
-
write.free();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The heading level (0 when not a heading).
|
|
63
|
-
*/
|
|
64
|
-
get level() {
|
|
65
|
-
|
|
66
|
-
const result = wasm.AccessibleNode_level(this.ffiValue);
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
finally {
|
|
73
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The accessible name (a list item's label, a cell's position, ...), empty if none.
|
|
79
|
-
*/
|
|
80
|
-
label() {
|
|
81
|
-
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
82
|
-
|
|
83
|
-
wasm.AccessibleNode_label(this.ffiValue, write.buffer);
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
return write.readString8();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
finally {
|
|
90
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
91
|
-
write.free();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* How many drawn lines the node's own text has.
|
|
97
|
-
*/
|
|
98
|
-
get lineCount() {
|
|
99
|
-
|
|
100
|
-
const result = wasm.AccessibleNode_line_count(this.ffiValue);
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
finally {
|
|
107
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* A line's text.
|
|
113
|
-
*/
|
|
114
|
-
lineText(index) {
|
|
115
|
-
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
116
|
-
|
|
117
|
-
wasm.AccessibleNode_line_text(this.ffiValue, index, write.buffer);
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
return write.readString8();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
finally {
|
|
124
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
125
|
-
write.free();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* A line's box, content pixels.
|
|
131
|
-
*/
|
|
132
|
-
lineRect(index) {
|
|
133
|
-
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 32, 8, false);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const result = wasm.AccessibleNode_line_rect(diplomatReceive.buffer, this.ffiValue, index);
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
return Rect._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
finally {
|
|
143
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
144
|
-
diplomatReceive.free();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
get childCount() {
|
|
149
|
-
|
|
150
|
-
const result = wasm.AccessibleNode_child_count(this.ffiValue);
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
finally {
|
|
157
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
child(index) {
|
|
162
|
-
|
|
163
|
-
const result = wasm.AccessibleNode_child(this.ffiValue, index);
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
return result === 0 ? null : new AccessibleNode(diplomatRuntime.internalConstructor, result, []);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
finally {
|
|
170
|
-
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
constructor(symbol, ptr, selfEdge) {
|
|
175
|
-
return this.#internalConstructor(...arguments)
|
|
176
|
-
}
|
|
177
|
-
}
|
package/dist/Alignment.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// generated by diplomat-tool
|
|
2
|
-
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Paragraph alignment.
|
|
8
|
-
*/
|
|
9
|
-
export class Alignment {
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
static fromValue(value: Alignment | string): Alignment;
|
|
13
|
-
|
|
14
|
-
get value(): string;
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
get ffiValue(): number;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Lines start at the left margin.
|
|
21
|
-
*/
|
|
22
|
-
static Left : Alignment;
|
|
23
|
-
/**
|
|
24
|
-
* Lines are centred.
|
|
25
|
-
*/
|
|
26
|
-
static Center : Alignment;
|
|
27
|
-
/**
|
|
28
|
-
* Lines end at the right margin.
|
|
29
|
-
*/
|
|
30
|
-
static Right : Alignment;
|
|
31
|
-
/**
|
|
32
|
-
* Lines fill the width, except a paragraph's last.
|
|
33
|
-
*/
|
|
34
|
-
static Justify : Alignment;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
constructor(value: Alignment | string );
|
|
38
|
-
}
|
package/dist/Alignment.mjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// generated by diplomat-tool
|
|
2
|
-
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
-
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Paragraph alignment.
|
|
9
|
-
*/
|
|
10
|
-
export class Alignment {
|
|
11
|
-
#value = undefined;
|
|
12
|
-
|
|
13
|
-
static #values = new Map([
|
|
14
|
-
["Left", 0],
|
|
15
|
-
["Center", 1],
|
|
16
|
-
["Right", 2],
|
|
17
|
-
["Justify", 3]
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
static getAllEntries() {
|
|
21
|
-
return Alignment.#values.entries();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
#internalConstructor(value) {
|
|
25
|
-
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
26
|
-
// We pass in two internalConstructor arguments to create *new*
|
|
27
|
-
// instances of this type, otherwise the enums are treated as singletons.
|
|
28
|
-
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
29
|
-
this.#value = arguments[2];
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
return Alignment.#objectValues[arguments[1]];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (value instanceof Alignment) {
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let intVal = Alignment.#values.get(value);
|
|
40
|
-
|
|
41
|
-
// Nullish check, checks for null or undefined
|
|
42
|
-
if (intVal != null) {
|
|
43
|
-
return Alignment.#objectValues[intVal];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
throw TypeError(value + " is not a Alignment and does not correspond to any of its enumerator values.");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** @internal */
|
|
50
|
-
static fromValue(value) {
|
|
51
|
-
return new Alignment(value);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get value(){
|
|
55
|
-
return [...Alignment.#values.keys()][this.#value];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** @internal */
|
|
59
|
-
get ffiValue(){
|
|
60
|
-
return this.#value;
|
|
61
|
-
}
|
|
62
|
-
static #objectValues = [
|
|
63
|
-
new Alignment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
64
|
-
new Alignment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
65
|
-
new Alignment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
66
|
-
new Alignment(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Lines start at the left margin.
|
|
71
|
-
*/
|
|
72
|
-
static Left = Alignment.#objectValues[0];
|
|
73
|
-
/**
|
|
74
|
-
* Lines are centred.
|
|
75
|
-
*/
|
|
76
|
-
static Center = Alignment.#objectValues[1];
|
|
77
|
-
/**
|
|
78
|
-
* Lines end at the right margin.
|
|
79
|
-
*/
|
|
80
|
-
static Right = Alignment.#objectValues[2];
|
|
81
|
-
/**
|
|
82
|
-
* Lines fill the width, except a paragraph's last.
|
|
83
|
-
*/
|
|
84
|
-
static Justify = Alignment.#objectValues[3];
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
constructor(value) {
|
|
88
|
-
return this.#internalConstructor(...arguments)
|
|
89
|
-
}
|
|
90
|
-
}
|
package/dist/BorderEdges.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// generated by diplomat-tool
|
|
2
|
-
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Which cell edges a border applies to.
|
|
8
|
-
*/
|
|
9
|
-
export class BorderEdges {
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
static fromValue(value: BorderEdges | string): BorderEdges;
|
|
13
|
-
|
|
14
|
-
get value(): string;
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
get ffiValue(): number;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Every edge.
|
|
21
|
-
*/
|
|
22
|
-
static All : BorderEdges;
|
|
23
|
-
/**
|
|
24
|
-
* The outer edges of the selection.
|
|
25
|
-
*/
|
|
26
|
-
static Outside : BorderEdges;
|
|
27
|
-
/**
|
|
28
|
-
* The inner edges, horizontal and vertical.
|
|
29
|
-
*/
|
|
30
|
-
static Inside : BorderEdges;
|
|
31
|
-
/**
|
|
32
|
-
* The inner horizontal edges.
|
|
33
|
-
*/
|
|
34
|
-
static InsideHorizontal : BorderEdges;
|
|
35
|
-
/**
|
|
36
|
-
* The inner vertical edges.
|
|
37
|
-
*/
|
|
38
|
-
static InsideVertical : BorderEdges;
|
|
39
|
-
static Top : BorderEdges;
|
|
40
|
-
static Bottom : BorderEdges;
|
|
41
|
-
static Left : BorderEdges;
|
|
42
|
-
static Right : BorderEdges;
|
|
43
|
-
/**
|
|
44
|
-
* Removes the borders.
|
|
45
|
-
*/
|
|
46
|
-
static Clear : BorderEdges;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
constructor(value: BorderEdges | string );
|
|
50
|
-
}
|