@meritt/gsx-wasm 0.0.0-stage → 0.1.0
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 +20 -0
- package/gsx-1.schema.json +470 -0
- package/gsx.d.ts +272 -0
- package/gsx.js +727 -0
- package/gsx.wasm +0 -0
- package/package.json +55 -3
- package/README.md +0 -3
package/gsx.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
export type Range = readonly [start: number, end: number];
|
|
2
|
+
|
|
3
|
+
export interface Media {
|
|
4
|
+
id: string;
|
|
5
|
+
cover?: string | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface NodeBase {
|
|
9
|
+
range: Range;
|
|
10
|
+
provenance?: 'literal';
|
|
11
|
+
gapBefore?: number;
|
|
12
|
+
children?: Node[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type Align = 'left' | 'right' | 'center' | null;
|
|
16
|
+
|
|
17
|
+
export type Node =
|
|
18
|
+
| (NodeBase & {
|
|
19
|
+
type:
|
|
20
|
+
| 'paragraph'
|
|
21
|
+
| 'thematicBreak'
|
|
22
|
+
| 'blockquote'
|
|
23
|
+
| 'tableRow'
|
|
24
|
+
| 'tableCell'
|
|
25
|
+
| 'emphasis'
|
|
26
|
+
| 'strong'
|
|
27
|
+
| 'delete'
|
|
28
|
+
| 'underline'
|
|
29
|
+
| 'highlight'
|
|
30
|
+
| 'spoiler'
|
|
31
|
+
| 'break';
|
|
32
|
+
})
|
|
33
|
+
| (NodeBase & { type: 'heading'; depth: number })
|
|
34
|
+
| (NodeBase & { type: 'list'; ordered: boolean; start: number | null; spread: boolean })
|
|
35
|
+
| (NodeBase & { type: 'listItem'; spread: boolean; checked: boolean | null })
|
|
36
|
+
| (NodeBase & { type: 'code'; lang: string | null; meta: string | null; value: string })
|
|
37
|
+
| (NodeBase & { type: 'table'; align: Align[] })
|
|
38
|
+
| (NodeBase & { type: 'text' | 'inlineCode'; value: string })
|
|
39
|
+
| (NodeBase & { type: 'link'; url: string; source: string; title: string | null })
|
|
40
|
+
| (NodeBase & { type: 'datetime'; datetime: string | null; unix: number })
|
|
41
|
+
| (NodeBase & { type: 'mediaReference'; mediaId: string })
|
|
42
|
+
| (NodeBase & { type: 'mediaGroup'; mediaIds: string[]; layout: Layout });
|
|
43
|
+
|
|
44
|
+
export type Layout = 'collage' | 'slideshow';
|
|
45
|
+
|
|
46
|
+
export type MarkerKind =
|
|
47
|
+
| 'emphasis'
|
|
48
|
+
| 'strong'
|
|
49
|
+
| 'strikethrough'
|
|
50
|
+
| 'spoiler'
|
|
51
|
+
| 'underline'
|
|
52
|
+
| 'highlight'
|
|
53
|
+
| 'codeText'
|
|
54
|
+
| 'codeFence'
|
|
55
|
+
| 'heading'
|
|
56
|
+
| 'thematicBreak'
|
|
57
|
+
| 'blockQuote'
|
|
58
|
+
| 'listItem'
|
|
59
|
+
| 'taskCheck'
|
|
60
|
+
| 'tableDelimiter'
|
|
61
|
+
| 'link'
|
|
62
|
+
| 'autolink'
|
|
63
|
+
| 'escape'
|
|
64
|
+
| 'characterReference'
|
|
65
|
+
| 'hardBreak'
|
|
66
|
+
| 'directive'
|
|
67
|
+
| 'media';
|
|
68
|
+
|
|
69
|
+
export interface Marker {
|
|
70
|
+
kind: MarkerKind;
|
|
71
|
+
range: Range;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type Code =
|
|
75
|
+
| 'DATETIME_INVALID'
|
|
76
|
+
| 'DATETIME_TIMEZONE_REQUIRED'
|
|
77
|
+
| 'LINK_LITERALIZED'
|
|
78
|
+
| 'MARKDOWN_INVALID_TEXT'
|
|
79
|
+
| 'MARKDOWN_MALFORMED'
|
|
80
|
+
| 'MARKDOWN_TOO_COMPLEX'
|
|
81
|
+
| 'MEDIA_DIRECTIVE_INVALID'
|
|
82
|
+
| 'MEDIA_REFERENCE_CONTEXT_UNSUPPORTED'
|
|
83
|
+
| 'MEDIA_REFERENCE_COVER'
|
|
84
|
+
| 'MEDIA_REFERENCE_DUPLICATE'
|
|
85
|
+
| 'MEDIA_REFERENCE_UNKNOWN';
|
|
86
|
+
|
|
87
|
+
export type Details =
|
|
88
|
+
| Record<string, never>
|
|
89
|
+
| { scheme: 'http' | 'https' | 'relative' | 'unsupported' }
|
|
90
|
+
| { id: string; index?: number }
|
|
91
|
+
| { limit: string; maximum: number }
|
|
92
|
+
| { codePoint: number };
|
|
93
|
+
|
|
94
|
+
export interface Diagnostic {
|
|
95
|
+
code: Code;
|
|
96
|
+
severity: 'warning' | 'error';
|
|
97
|
+
range: Range;
|
|
98
|
+
details: Details;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface Document {
|
|
102
|
+
children: Node[];
|
|
103
|
+
markers: Marker[];
|
|
104
|
+
diagnostics: Diagnostic[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface WireError {
|
|
108
|
+
code: Code;
|
|
109
|
+
range: Range | null;
|
|
110
|
+
details: Details;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type Wire = { document: Document } | { error: WireError };
|
|
114
|
+
|
|
115
|
+
export interface Facts {
|
|
116
|
+
media?: 'image' | 'video' | null;
|
|
117
|
+
mediaCount?: number;
|
|
118
|
+
title?: string | null;
|
|
119
|
+
maxCharacters?: number | null;
|
|
120
|
+
charactersReservedPerUrl?: number | null;
|
|
121
|
+
captionLimit?: number | null;
|
|
122
|
+
entitiesAllowed?: boolean;
|
|
123
|
+
items?: Iterable<MediaFact>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** An attached media item, matched to media references by `id`. */
|
|
127
|
+
export interface MediaFact {
|
|
128
|
+
id: string;
|
|
129
|
+
format: 'image' | 'gif' | 'video' | 'audio';
|
|
130
|
+
alt?: string | null;
|
|
131
|
+
spoiler?: boolean;
|
|
132
|
+
inline?: boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type FieldName = 'text' | 'title' | 'description' | 'alt';
|
|
136
|
+
|
|
137
|
+
export type Style = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' | 'link' | 'tag';
|
|
138
|
+
|
|
139
|
+
export type Unit =
|
|
140
|
+
| 'graphemes'
|
|
141
|
+
| 'code-points'
|
|
142
|
+
| 'utf16-code-units'
|
|
143
|
+
| 'utf8-bytes'
|
|
144
|
+
| 'x-weighted'
|
|
145
|
+
| 'mastodon-weighted'
|
|
146
|
+
| 'threads-weighted';
|
|
147
|
+
|
|
148
|
+
export type Class = 'approximated' | 'textual_fallback' | 'unwrapped' | 'omitted' | 'blocked';
|
|
149
|
+
|
|
150
|
+
export type Feature =
|
|
151
|
+
| 'heading'
|
|
152
|
+
| 'thematic_break'
|
|
153
|
+
| 'blockquote'
|
|
154
|
+
| 'bullet_list'
|
|
155
|
+
| 'ordered_list'
|
|
156
|
+
| 'compound_list'
|
|
157
|
+
| 'code_block'
|
|
158
|
+
| 'table'
|
|
159
|
+
| 'task_list'
|
|
160
|
+
| 'media'
|
|
161
|
+
| 'emphasis'
|
|
162
|
+
| 'strong'
|
|
163
|
+
| 'strikethrough'
|
|
164
|
+
| 'underline'
|
|
165
|
+
| 'highlight'
|
|
166
|
+
| 'spoiler'
|
|
167
|
+
| 'inline_code'
|
|
168
|
+
| 'link'
|
|
169
|
+
| 'link_title'
|
|
170
|
+
| 'datetime'
|
|
171
|
+
| 'angle_brackets'
|
|
172
|
+
| 'text'
|
|
173
|
+
| 'title';
|
|
174
|
+
|
|
175
|
+
/** Entity ranges are in the target's `offsets` unit; links are UTF-16 ranges of the field text. */
|
|
176
|
+
export interface Entity {
|
|
177
|
+
style: Style;
|
|
178
|
+
range: Range;
|
|
179
|
+
value: string | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface Field {
|
|
183
|
+
name: FieldName;
|
|
184
|
+
text: string;
|
|
185
|
+
links: Range[];
|
|
186
|
+
entities: Entity[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface Measurement {
|
|
190
|
+
field: FieldName;
|
|
191
|
+
unit: Unit;
|
|
192
|
+
value: number;
|
|
193
|
+
maximum: number | null;
|
|
194
|
+
/** Indexes of the measured block and media item, for per-item limits of blocks targets. */
|
|
195
|
+
block?: number;
|
|
196
|
+
item?: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface Item {
|
|
200
|
+
reference: string;
|
|
201
|
+
alt: string | null;
|
|
202
|
+
spoiler: boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type Block = { text: string } | { items: Item[]; layout: Layout | null };
|
|
206
|
+
|
|
207
|
+
export interface Truncated {
|
|
208
|
+
unit: Unit;
|
|
209
|
+
maximum: number;
|
|
210
|
+
value: number;
|
|
211
|
+
exact: boolean;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface Change {
|
|
215
|
+
class: Class;
|
|
216
|
+
feature: Feature;
|
|
217
|
+
reason: string;
|
|
218
|
+
/** The reason in upper case when the change is blocked. */
|
|
219
|
+
code: string | null;
|
|
220
|
+
field: FieldName;
|
|
221
|
+
range: Range | null;
|
|
222
|
+
truncated: Truncated | null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface Projection {
|
|
226
|
+
fields: Field[];
|
|
227
|
+
measurements: Measurement[];
|
|
228
|
+
changes: Change[];
|
|
229
|
+
media: string[];
|
|
230
|
+
/** Present for targets of the `blocks/1` form only. */
|
|
231
|
+
blocks?: Block[];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type ProjectionWire = { projection: Projection } | { error: WireError };
|
|
235
|
+
|
|
236
|
+
export type SerializedWire = { serialized: string } | { error: WireError };
|
|
237
|
+
|
|
238
|
+
export interface Target {
|
|
239
|
+
name: string;
|
|
240
|
+
form: 'plain/1' | 'entities/1' | 'html/1' | 'markdown/1' | 'blocks/1';
|
|
241
|
+
offsets: 'utf8' | 'utf16' | null;
|
|
242
|
+
digest: string;
|
|
243
|
+
manifest: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export declare class ParseError extends Error {
|
|
247
|
+
readonly code: Code;
|
|
248
|
+
readonly range: Range | null;
|
|
249
|
+
readonly details: Details;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare class VersionError extends Error {
|
|
253
|
+
readonly expected: string;
|
|
254
|
+
readonly found: string | undefined;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface GSX {
|
|
258
|
+
readonly VERSION: string;
|
|
259
|
+
readonly ParseError: typeof ParseError;
|
|
260
|
+
readonly VersionError: typeof VersionError;
|
|
261
|
+
parse(text: string, media?: Iterable<Media>): Document;
|
|
262
|
+
parseJSON(text: string, media?: Iterable<Media>): string;
|
|
263
|
+
serialize(text: string, media?: Iterable<Media>): string;
|
|
264
|
+
serializeJSON(text: string, media?: Iterable<Media>): string;
|
|
265
|
+
project(text: string, target: string, facts?: Facts, media?: Iterable<Media>): Projection;
|
|
266
|
+
projectJSON(text: string, target: string, facts?: Facts, media?: Iterable<Media>): string;
|
|
267
|
+
targets(): readonly Readonly<Target>[];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare function load(
|
|
271
|
+
source?: URL | string | Response | Promise<Response> | WebAssembly.Module | BufferSource
|
|
272
|
+
): Promise<GSX>;
|