@twip/web 0.0.0 → 0.1.0-alpha.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/LICENSE +202 -0
- package/dist/AccessibleNode.d.ts +51 -0
- package/dist/AccessibleNode.mjs +177 -0
- package/dist/Alignment.d.ts +38 -0
- package/dist/Alignment.mjs +90 -0
- package/dist/BorderEdges.d.ts +50 -0
- package/dist/BorderEdges.mjs +114 -0
- package/dist/BorderStyle.d.ts +27 -0
- package/dist/BorderStyle.mjs +81 -0
- package/dist/Bytes.d.ts +19 -0
- package/dist/Bytes.mjs +76 -0
- package/dist/CaretPosition.d.ts +34 -0
- package/dist/CaretPosition.mjs +148 -0
- package/dist/CellAlignment.d.ts +25 -0
- package/dist/CellAlignment.mjs +75 -0
- package/dist/CellShift.d.ts +30 -0
- package/dist/CellShift.mjs +78 -0
- package/dist/Clipboard.d.ts +22 -0
- package/dist/Clipboard.mjs +90 -0
- package/dist/ColumnSide.d.ts +24 -0
- package/dist/ColumnSide.mjs +72 -0
- package/dist/ControlKind.d.ts +28 -0
- package/dist/ControlKind.mjs +84 -0
- package/dist/ControlLock.d.ts +42 -0
- package/dist/ControlLock.mjs +96 -0
- package/dist/DocumentStatus.d.ts +34 -0
- package/dist/DocumentStatus.mjs +148 -0
- package/dist/Editor.d.ts +773 -0
- package/dist/Editor.mjs +2269 -0
- package/dist/EditorMode.d.ts +34 -0
- package/dist/EditorMode.mjs +84 -0
- package/dist/Element.d.ts +57 -0
- package/dist/Element.mjs +201 -0
- package/dist/ElementKind.d.ts +28 -0
- package/dist/ElementKind.mjs +78 -0
- package/dist/ElementList.d.ts +20 -0
- package/dist/ElementList.mjs +71 -0
- package/dist/ElementText.d.ts +34 -0
- package/dist/ElementText.mjs +84 -0
- package/dist/Event.d.ts +45 -0
- package/dist/Event.mjs +159 -0
- package/dist/EventKind.d.ts +39 -0
- package/dist/EventKind.mjs +93 -0
- package/dist/EventList.d.ts +20 -0
- package/dist/EventList.mjs +71 -0
- package/dist/Fonts.d.ts +29 -0
- package/dist/Fonts.mjs +107 -0
- package/dist/Highlight.d.ts +41 -0
- package/dist/Highlight.mjs +117 -0
- package/dist/MarginPreset.d.ts +38 -0
- package/dist/MarginPreset.mjs +90 -0
- package/dist/MarkSeverity.d.ts +25 -0
- package/dist/MarkSeverity.mjs +75 -0
- package/dist/Modifiers.d.ts +34 -0
- package/dist/Modifiers.mjs +148 -0
- package/dist/OpenError.d.ts +30 -0
- package/dist/OpenError.mjs +78 -0
- package/dist/Orientation.d.ts +30 -0
- package/dist/Orientation.mjs +78 -0
- package/dist/PageNumber.d.ts +34 -0
- package/dist/PageNumber.mjs +84 -0
- package/dist/PaperSize.d.ts +50 -0
- package/dist/PaperSize.mjs +108 -0
- package/dist/ParagraphBorders.d.ts +34 -0
- package/dist/ParagraphBorders.mjs +84 -0
- package/dist/PictureWrap.d.ts +34 -0
- package/dist/PictureWrap.mjs +90 -0
- package/dist/PointerKind.d.ts +23 -0
- package/dist/PointerKind.mjs +75 -0
- package/dist/Rect.d.ts +34 -0
- package/dist/Rect.mjs +148 -0
- package/dist/Request.d.ts +55 -0
- package/dist/Request.mjs +207 -0
- package/dist/RequestKind.d.ts +45 -0
- package/dist/RequestKind.mjs +105 -0
- package/dist/RequestList.d.ts +20 -0
- package/dist/RequestList.mjs +71 -0
- package/dist/RowHeightRule.d.ts +34 -0
- package/dist/RowHeightRule.mjs +84 -0
- package/dist/RowSide.d.ts +24 -0
- package/dist/RowSide.mjs +72 -0
- package/dist/SaveError.d.ts +24 -0
- package/dist/SaveError.mjs +72 -0
- package/dist/SelectionInfo.d.ts +39 -0
- package/dist/SelectionInfo.mjs +166 -0
- package/dist/SelectionKind.d.ts +37 -0
- package/dist/SelectionKind.mjs +93 -0
- package/dist/THIRD-PARTY-NOTICES.md +4475 -0
- package/dist/TableAlignment.d.ts +25 -0
- package/dist/TableAlignment.mjs +75 -0
- package/dist/TableSelection.d.ts +38 -0
- package/dist/TableSelection.mjs +90 -0
- package/dist/TableWidthUnit.d.ts +31 -0
- package/dist/TableWidthUnit.mjs +81 -0
- package/dist/TextUnit.d.ts +25 -0
- package/dist/TextUnit.mjs +75 -0
- package/dist/diplomat-runtime.d.ts +15 -0
- package/dist/diplomat-runtime.mjs +786 -0
- package/dist/diplomat-wasm.mjs +18 -0
- package/dist/gpu.d.ts +15 -0
- package/dist/gpu.mjs +42 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.mjs +101 -0
- package/dist/twip-wasm.js +2 -0
- package/dist/twip_wasm.wasm +0 -0
- package/package.json +18 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the editor lets the user do.
|
|
8
|
+
*/
|
|
9
|
+
export class EditorMode {
|
|
10
|
+
|
|
11
|
+
/** @internal */
|
|
12
|
+
static fromValue(value: EditorMode | string): EditorMode;
|
|
13
|
+
|
|
14
|
+
get value(): string;
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
get ffiValue(): number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Normal editing.
|
|
21
|
+
*/
|
|
22
|
+
static Editing : EditorMode;
|
|
23
|
+
/**
|
|
24
|
+
* Template design: fields and controls show their names.
|
|
25
|
+
*/
|
|
26
|
+
static Design : EditorMode;
|
|
27
|
+
/**
|
|
28
|
+
* Viewing only: nothing can change the document.
|
|
29
|
+
*/
|
|
30
|
+
static ReadOnly : EditorMode;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
constructor(value: EditorMode | string );
|
|
34
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
* What the editor lets the user do.
|
|
9
|
+
*/
|
|
10
|
+
export class EditorMode {
|
|
11
|
+
#value = undefined;
|
|
12
|
+
|
|
13
|
+
static #values = new Map([
|
|
14
|
+
["Editing", 0],
|
|
15
|
+
["Design", 1],
|
|
16
|
+
["ReadOnly", 2]
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
static getAllEntries() {
|
|
20
|
+
return EditorMode.#values.entries();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#internalConstructor(value) {
|
|
24
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
25
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
26
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
27
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
28
|
+
this.#value = arguments[2];
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
return EditorMode.#objectValues[arguments[1]];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (value instanceof EditorMode) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let intVal = EditorMode.#values.get(value);
|
|
39
|
+
|
|
40
|
+
// Nullish check, checks for null or undefined
|
|
41
|
+
if (intVal != null) {
|
|
42
|
+
return EditorMode.#objectValues[intVal];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw TypeError(value + " is not a EditorMode and does not correspond to any of its enumerator values.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
static fromValue(value) {
|
|
50
|
+
return new EditorMode(value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get value(){
|
|
54
|
+
return [...EditorMode.#values.keys()][this.#value];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @internal */
|
|
58
|
+
get ffiValue(){
|
|
59
|
+
return this.#value;
|
|
60
|
+
}
|
|
61
|
+
static #objectValues = [
|
|
62
|
+
new EditorMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
63
|
+
new EditorMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
64
|
+
new EditorMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Normal editing.
|
|
69
|
+
*/
|
|
70
|
+
static Editing = EditorMode.#objectValues[0];
|
|
71
|
+
/**
|
|
72
|
+
* Template design: fields and controls show their names.
|
|
73
|
+
*/
|
|
74
|
+
static Design = EditorMode.#objectValues[1];
|
|
75
|
+
/**
|
|
76
|
+
* Viewing only: nothing can change the document.
|
|
77
|
+
*/
|
|
78
|
+
static ReadOnly = EditorMode.#objectValues[2];
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
constructor(value) {
|
|
82
|
+
return this.#internalConstructor(...arguments)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A field or content control in the document.
|
|
8
|
+
*/
|
|
9
|
+
export class Element {
|
|
10
|
+
/** @internal */
|
|
11
|
+
get ffiValue(): pointer;
|
|
12
|
+
/** @internal */
|
|
13
|
+
constructor();
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Its id, for the element methods (`select_element`, `set_field`, ...).
|
|
18
|
+
*/
|
|
19
|
+
id(): string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `field`, or the control's kind (`plain_text`, `rich_text`, `checkbox`, `date`, `dropdown`, `picture`, ...).
|
|
23
|
+
*/
|
|
24
|
+
kind(): string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* What the document shows for it.
|
|
28
|
+
*/
|
|
29
|
+
display(): string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A field's code (`MERGEFIELD Name`), empty for a control.
|
|
33
|
+
*/
|
|
34
|
+
code(): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A control's tag, empty for a field.
|
|
38
|
+
*/
|
|
39
|
+
tag(): string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A control's title, empty for a field.
|
|
43
|
+
*/
|
|
44
|
+
alias(): string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The id of the element it's nested in, empty at the top.
|
|
48
|
+
*/
|
|
49
|
+
parent(): string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The story it's in: `body`, `header`, `footer`, `footnote`, `endnote`, `textbox`.
|
|
53
|
+
*/
|
|
54
|
+
story(): string;
|
|
55
|
+
|
|
56
|
+
get locked(): boolean;
|
|
57
|
+
}
|
package/dist/Element.mjs
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
const Element_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
6
|
+
wasm.Element_destroy(ptr);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A field or content control in the document.
|
|
11
|
+
*/
|
|
12
|
+
export class Element {
|
|
13
|
+
// Internal ptr reference:
|
|
14
|
+
#ptr = null;
|
|
15
|
+
|
|
16
|
+
// Lifetimes are only to keep dependencies alive.
|
|
17
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
18
|
+
#selfEdge = [];
|
|
19
|
+
|
|
20
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
21
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
22
|
+
console.error("Element is an Opaque type. You cannot call its constructor.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.#ptr = ptr;
|
|
26
|
+
this.#selfEdge = selfEdge;
|
|
27
|
+
|
|
28
|
+
// Are we being borrowed? If not, we can register.
|
|
29
|
+
if (this.#selfEdge.length === 0) {
|
|
30
|
+
Element_box_destroy_registry.register(this, this.#ptr);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
get ffiValue() {
|
|
37
|
+
return this.#ptr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Its id, for the element methods (`select_element`, `set_field`, ...).
|
|
43
|
+
*/
|
|
44
|
+
id() {
|
|
45
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
46
|
+
|
|
47
|
+
wasm.Element_id(this.ffiValue, write.buffer);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
return write.readString8();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
finally {
|
|
54
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
55
|
+
write.free();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* `field`, or the control's kind (`plain_text`, `rich_text`, `checkbox`, `date`, `dropdown`, `picture`, ...).
|
|
61
|
+
*/
|
|
62
|
+
kind() {
|
|
63
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
64
|
+
|
|
65
|
+
wasm.Element_kind(this.ffiValue, write.buffer);
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
return write.readString8();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
finally {
|
|
72
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
73
|
+
write.free();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* What the document shows for it.
|
|
79
|
+
*/
|
|
80
|
+
display() {
|
|
81
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
82
|
+
|
|
83
|
+
wasm.Element_display(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
|
+
* A field's code (`MERGEFIELD Name`), empty for a control.
|
|
97
|
+
*/
|
|
98
|
+
code() {
|
|
99
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
100
|
+
|
|
101
|
+
wasm.Element_code(this.ffiValue, write.buffer);
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
return write.readString8();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
finally {
|
|
108
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
109
|
+
write.free();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A control's tag, empty for a field.
|
|
115
|
+
*/
|
|
116
|
+
tag() {
|
|
117
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
118
|
+
|
|
119
|
+
wasm.Element_tag(this.ffiValue, write.buffer);
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
return write.readString8();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
finally {
|
|
126
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
127
|
+
write.free();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A control's title, empty for a field.
|
|
133
|
+
*/
|
|
134
|
+
alias() {
|
|
135
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
136
|
+
|
|
137
|
+
wasm.Element_alias(this.ffiValue, write.buffer);
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
return write.readString8();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
finally {
|
|
144
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
145
|
+
write.free();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The id of the element it's nested in, empty at the top.
|
|
151
|
+
*/
|
|
152
|
+
parent() {
|
|
153
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
154
|
+
|
|
155
|
+
wasm.Element_parent(this.ffiValue, write.buffer);
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
return write.readString8();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
finally {
|
|
162
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
163
|
+
write.free();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The story it's in: `body`, `header`, `footer`, `footnote`, `endnote`, `textbox`.
|
|
169
|
+
*/
|
|
170
|
+
story() {
|
|
171
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
172
|
+
|
|
173
|
+
wasm.Element_story(this.ffiValue, write.buffer);
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
return write.readString8();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
finally {
|
|
180
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
181
|
+
write.free();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
get locked() {
|
|
186
|
+
|
|
187
|
+
const result = wasm.Element_locked(this.ffiValue);
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
return result === 1;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
finally {
|
|
194
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
constructor(symbol, ptr, selfEdge) {
|
|
199
|
+
return this.#internalConstructor(...arguments)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which elements to include.
|
|
8
|
+
*/
|
|
9
|
+
export class ElementKind {
|
|
10
|
+
|
|
11
|
+
/** @internal */
|
|
12
|
+
static fromValue(value: ElementKind | string): ElementKind;
|
|
13
|
+
|
|
14
|
+
get value(): string;
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
get ffiValue(): number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fields and controls.
|
|
21
|
+
*/
|
|
22
|
+
static Any : ElementKind;
|
|
23
|
+
static Field : ElementKind;
|
|
24
|
+
static Control : ElementKind;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
constructor(value: ElementKind | string );
|
|
28
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
* Which elements to include.
|
|
9
|
+
*/
|
|
10
|
+
export class ElementKind {
|
|
11
|
+
#value = undefined;
|
|
12
|
+
|
|
13
|
+
static #values = new Map([
|
|
14
|
+
["Any", 0],
|
|
15
|
+
["Field", 1],
|
|
16
|
+
["Control", 2]
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
static getAllEntries() {
|
|
20
|
+
return ElementKind.#values.entries();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#internalConstructor(value) {
|
|
24
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
25
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
26
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
27
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
28
|
+
this.#value = arguments[2];
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
return ElementKind.#objectValues[arguments[1]];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (value instanceof ElementKind) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let intVal = ElementKind.#values.get(value);
|
|
39
|
+
|
|
40
|
+
// Nullish check, checks for null or undefined
|
|
41
|
+
if (intVal != null) {
|
|
42
|
+
return ElementKind.#objectValues[intVal];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw TypeError(value + " is not a ElementKind and does not correspond to any of its enumerator values.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
static fromValue(value) {
|
|
50
|
+
return new ElementKind(value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get value(){
|
|
54
|
+
return [...ElementKind.#values.keys()][this.#value];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @internal */
|
|
58
|
+
get ffiValue(){
|
|
59
|
+
return this.#value;
|
|
60
|
+
}
|
|
61
|
+
static #objectValues = [
|
|
62
|
+
new ElementKind(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
63
|
+
new ElementKind(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
64
|
+
new ElementKind(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Fields and controls.
|
|
69
|
+
*/
|
|
70
|
+
static Any = ElementKind.#objectValues[0];
|
|
71
|
+
static Field = ElementKind.#objectValues[1];
|
|
72
|
+
static Control = ElementKind.#objectValues[2];
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
constructor(value) {
|
|
76
|
+
return this.#internalConstructor(...arguments)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { Element } from "./Element"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Elements in document order.
|
|
9
|
+
*/
|
|
10
|
+
export class ElementList {
|
|
11
|
+
/** @internal */
|
|
12
|
+
get ffiValue(): pointer;
|
|
13
|
+
/** @internal */
|
|
14
|
+
constructor();
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
get len(): number;
|
|
18
|
+
|
|
19
|
+
get(index: number): Element | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { Element } from "./Element.mjs"
|
|
3
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
4
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
5
|
+
|
|
6
|
+
const ElementList_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.ElementList_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Elements in document order.
|
|
12
|
+
*/
|
|
13
|
+
export class ElementList {
|
|
14
|
+
// Internal ptr reference:
|
|
15
|
+
#ptr = null;
|
|
16
|
+
|
|
17
|
+
// Lifetimes are only to keep dependencies alive.
|
|
18
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
19
|
+
#selfEdge = [];
|
|
20
|
+
|
|
21
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
22
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
23
|
+
console.error("ElementList is an Opaque type. You cannot call its constructor.");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.#ptr = ptr;
|
|
27
|
+
this.#selfEdge = selfEdge;
|
|
28
|
+
|
|
29
|
+
// Are we being borrowed? If not, we can register.
|
|
30
|
+
if (this.#selfEdge.length === 0) {
|
|
31
|
+
ElementList_box_destroy_registry.register(this, this.#ptr);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
get ffiValue() {
|
|
38
|
+
return this.#ptr;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
get len() {
|
|
43
|
+
|
|
44
|
+
const result = wasm.ElementList_len(this.ffiValue);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
finally {
|
|
51
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get(index) {
|
|
56
|
+
|
|
57
|
+
const result = wasm.ElementList_get(this.ffiValue, index);
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
return result === 0 ? null : new Element(diplomatRuntime.internalConstructor, result, []);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
finally {
|
|
64
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
constructor(symbol, ptr, selfEdge) {
|
|
69
|
+
return this.#internalConstructor(...arguments)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which text of an element to search.
|
|
8
|
+
*/
|
|
9
|
+
export class ElementText {
|
|
10
|
+
|
|
11
|
+
/** @internal */
|
|
12
|
+
static fromValue(value: ElementText | string): ElementText;
|
|
13
|
+
|
|
14
|
+
get value(): string;
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
get ffiValue(): number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Field codes.
|
|
21
|
+
*/
|
|
22
|
+
static Code : ElementText;
|
|
23
|
+
/**
|
|
24
|
+
* Control tags.
|
|
25
|
+
*/
|
|
26
|
+
static Tag : ElementText;
|
|
27
|
+
/**
|
|
28
|
+
* Control titles.
|
|
29
|
+
*/
|
|
30
|
+
static Alias : ElementText;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
constructor(value: ElementText | string );
|
|
34
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
* Which text of an element to search.
|
|
9
|
+
*/
|
|
10
|
+
export class ElementText {
|
|
11
|
+
#value = undefined;
|
|
12
|
+
|
|
13
|
+
static #values = new Map([
|
|
14
|
+
["Code", 0],
|
|
15
|
+
["Tag", 1],
|
|
16
|
+
["Alias", 2]
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
static getAllEntries() {
|
|
20
|
+
return ElementText.#values.entries();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#internalConstructor(value) {
|
|
24
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
25
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
26
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
27
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
28
|
+
this.#value = arguments[2];
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
return ElementText.#objectValues[arguments[1]];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (value instanceof ElementText) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let intVal = ElementText.#values.get(value);
|
|
39
|
+
|
|
40
|
+
// Nullish check, checks for null or undefined
|
|
41
|
+
if (intVal != null) {
|
|
42
|
+
return ElementText.#objectValues[intVal];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw TypeError(value + " is not a ElementText and does not correspond to any of its enumerator values.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
static fromValue(value) {
|
|
50
|
+
return new ElementText(value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get value(){
|
|
54
|
+
return [...ElementText.#values.keys()][this.#value];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @internal */
|
|
58
|
+
get ffiValue(){
|
|
59
|
+
return this.#value;
|
|
60
|
+
}
|
|
61
|
+
static #objectValues = [
|
|
62
|
+
new ElementText(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
63
|
+
new ElementText(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
64
|
+
new ElementText(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Field codes.
|
|
69
|
+
*/
|
|
70
|
+
static Code = ElementText.#objectValues[0];
|
|
71
|
+
/**
|
|
72
|
+
* Control tags.
|
|
73
|
+
*/
|
|
74
|
+
static Tag = ElementText.#objectValues[1];
|
|
75
|
+
/**
|
|
76
|
+
* Control titles.
|
|
77
|
+
*/
|
|
78
|
+
static Alias = ElementText.#objectValues[2];
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
constructor(value) {
|
|
82
|
+
return this.#internalConstructor(...arguments)
|
|
83
|
+
}
|
|
84
|
+
}
|