glost-processor 0.5.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 +21 -0
- package/README.md +262 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/processor.d.ts +256 -0
- package/dist/processor.d.ts.map +1 -0
- package/dist/processor.js +482 -0
- package/dist/processor.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
- package/src/index.ts +76 -0
- package/src/processor.ts +574 -0
- package/src/types.ts +203 -0
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GLOST Processor
|
|
3
|
+
*
|
|
4
|
+
* Unified-style processor for GLOST documents with fluent API.
|
|
5
|
+
* Similar to unified/remark processors.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { processGLOSTWithExtensionsAsync, extensionRegistry } from "glost-extensions";
|
|
10
|
+
/**
|
|
11
|
+
* GLOST Processor
|
|
12
|
+
*
|
|
13
|
+
* Fluent API for processing GLOST documents through plugin pipelines.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { GLOSTProcessor } from "glost-processor";
|
|
18
|
+
*
|
|
19
|
+
* const processor = new GLOSTProcessor()
|
|
20
|
+
* .use(transcription, { scheme: "ipa" })
|
|
21
|
+
* .use(translation, { target: "en" })
|
|
22
|
+
* .use(frequency);
|
|
23
|
+
*
|
|
24
|
+
* const result = await processor.process(document);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class GLOSTProcessor {
|
|
28
|
+
plugins = [];
|
|
29
|
+
hooks = {
|
|
30
|
+
before: new Map(),
|
|
31
|
+
after: new Map(),
|
|
32
|
+
onError: [],
|
|
33
|
+
onSkip: [],
|
|
34
|
+
onProgress: [],
|
|
35
|
+
};
|
|
36
|
+
dataStore = new Map();
|
|
37
|
+
options = {};
|
|
38
|
+
frozen = false;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new processor instance
|
|
41
|
+
*
|
|
42
|
+
* @param options - Initial processor options
|
|
43
|
+
*/
|
|
44
|
+
constructor(options = {}) {
|
|
45
|
+
this.options = { ...options };
|
|
46
|
+
if (options.data) {
|
|
47
|
+
this.dataStore = new Map(options.data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Use a plugin, preset, or extension
|
|
52
|
+
*
|
|
53
|
+
* @param spec - Plugin function, extension object, preset, or plugin ID
|
|
54
|
+
* @param options - Plugin options
|
|
55
|
+
* @returns This processor for chaining
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* processor
|
|
60
|
+
* .use(transcription, { scheme: "ipa" })
|
|
61
|
+
* .use(translation)
|
|
62
|
+
* .use("frequency");
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
use(spec, options) {
|
|
66
|
+
this.assertNotFrozen();
|
|
67
|
+
// Handle presets
|
|
68
|
+
if (this.isPreset(spec)) {
|
|
69
|
+
return this.usePreset(spec);
|
|
70
|
+
}
|
|
71
|
+
// Add plugin to pipeline
|
|
72
|
+
this.plugins.push({ spec, options });
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Apply a preset (collection of plugins)
|
|
77
|
+
*
|
|
78
|
+
* @param preset - Preset to apply
|
|
79
|
+
* @returns This processor for chaining
|
|
80
|
+
*/
|
|
81
|
+
usePreset(preset) {
|
|
82
|
+
for (const pluginEntry of preset.plugins) {
|
|
83
|
+
if (Array.isArray(pluginEntry)) {
|
|
84
|
+
const [plugin, opts] = pluginEntry;
|
|
85
|
+
this.use(plugin, opts);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.use(pluginEntry);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Register a hook to run before a plugin
|
|
95
|
+
*
|
|
96
|
+
* @param pluginId - Plugin ID to hook into
|
|
97
|
+
* @param hook - Hook function to run
|
|
98
|
+
* @returns This processor for chaining
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* processor.before("translation", (doc) => {
|
|
103
|
+
* console.log("About to translate");
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
before(pluginId, hook) {
|
|
108
|
+
this.assertNotFrozen();
|
|
109
|
+
if (!this.hooks.before.has(pluginId)) {
|
|
110
|
+
this.hooks.before.set(pluginId, []);
|
|
111
|
+
}
|
|
112
|
+
this.hooks.before.get(pluginId).push(hook);
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Register a hook to run after a plugin
|
|
117
|
+
*
|
|
118
|
+
* @param pluginId - Plugin ID to hook into
|
|
119
|
+
* @param hook - Hook function to run
|
|
120
|
+
* @returns This processor for chaining
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* processor.after("translation", (doc) => {
|
|
125
|
+
* console.log("Translation complete");
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
after(pluginId, hook) {
|
|
130
|
+
this.assertNotFrozen();
|
|
131
|
+
if (!this.hooks.after.has(pluginId)) {
|
|
132
|
+
this.hooks.after.set(pluginId, []);
|
|
133
|
+
}
|
|
134
|
+
this.hooks.after.get(pluginId).push(hook);
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Register an error handler
|
|
139
|
+
*
|
|
140
|
+
* @param hook - Error handler function
|
|
141
|
+
* @returns This processor for chaining
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* processor.onError((error, plugin) => {
|
|
146
|
+
* console.error(`Plugin ${plugin} failed:`, error);
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
onError(hook) {
|
|
151
|
+
this.assertNotFrozen();
|
|
152
|
+
this.hooks.onError.push(hook);
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Register a skip handler
|
|
157
|
+
*
|
|
158
|
+
* @param hook - Skip handler function
|
|
159
|
+
* @returns This processor for chaining
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* processor.onSkip((plugin, reason) => {
|
|
164
|
+
* console.log(`Plugin ${plugin} skipped: ${reason}`);
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
onSkip(hook) {
|
|
169
|
+
this.assertNotFrozen();
|
|
170
|
+
this.hooks.onSkip.push(hook);
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Register a progress handler
|
|
175
|
+
*
|
|
176
|
+
* @param hook - Progress handler function
|
|
177
|
+
* @returns This processor for chaining
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* processor.onProgress((stats) => {
|
|
182
|
+
* console.log(`Progress: ${stats.completed}/${stats.total}`);
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
onProgress(hook) {
|
|
187
|
+
this.assertNotFrozen();
|
|
188
|
+
this.hooks.onProgress.push(hook);
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
data(key, value) {
|
|
192
|
+
if (arguments.length === 1) {
|
|
193
|
+
return this.dataStore.get(key);
|
|
194
|
+
}
|
|
195
|
+
this.assertNotFrozen();
|
|
196
|
+
this.dataStore.set(key, value);
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Freeze the processor
|
|
201
|
+
*
|
|
202
|
+
* Returns a frozen processor that cannot be modified.
|
|
203
|
+
* Useful for reusing the same configuration across multiple documents.
|
|
204
|
+
*
|
|
205
|
+
* @returns A frozen copy of this processor
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* const frozen = processor
|
|
210
|
+
* .use(transcription)
|
|
211
|
+
* .use(translation)
|
|
212
|
+
* .freeze();
|
|
213
|
+
*
|
|
214
|
+
* // Can process multiple documents with the same pipeline
|
|
215
|
+
* const result1 = await frozen.process(doc1);
|
|
216
|
+
* const result2 = await frozen.process(doc2);
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
freeze() {
|
|
220
|
+
const frozen = new GLOSTProcessor(this.options);
|
|
221
|
+
frozen.plugins = [...this.plugins];
|
|
222
|
+
frozen.hooks = {
|
|
223
|
+
before: new Map(this.hooks.before),
|
|
224
|
+
after: new Map(this.hooks.after),
|
|
225
|
+
onError: [...this.hooks.onError],
|
|
226
|
+
onSkip: [...this.hooks.onSkip],
|
|
227
|
+
onProgress: [...this.hooks.onProgress],
|
|
228
|
+
};
|
|
229
|
+
frozen.dataStore = new Map(this.dataStore);
|
|
230
|
+
frozen.frozen = true;
|
|
231
|
+
return frozen;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Process a document through the pipeline
|
|
235
|
+
*
|
|
236
|
+
* @param document - GLOST document to process
|
|
237
|
+
* @returns Promise resolving to the processed document
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* const result = await processor.process(document);
|
|
242
|
+
* console.log(result);
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
async process(document) {
|
|
246
|
+
const result = await this.processWithMeta(document);
|
|
247
|
+
return result.document;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Process a document and return detailed metadata
|
|
251
|
+
*
|
|
252
|
+
* @param document - GLOST document to process
|
|
253
|
+
* @returns Promise resolving to processing result with metadata
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const result = await processor.processWithMeta(document);
|
|
258
|
+
* console.log(result.metadata.appliedPlugins);
|
|
259
|
+
* console.log(result.metadata.stats.totalTime);
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
async processWithMeta(document) {
|
|
263
|
+
const startTime = Date.now();
|
|
264
|
+
const extensions = await this.resolveExtensions();
|
|
265
|
+
const timing = new Map();
|
|
266
|
+
const errors = [];
|
|
267
|
+
const warnings = [];
|
|
268
|
+
const appliedPlugins = [];
|
|
269
|
+
const skippedPlugins = [];
|
|
270
|
+
// Emit initial progress
|
|
271
|
+
this.emitProgress({
|
|
272
|
+
total: extensions.length,
|
|
273
|
+
completed: 0,
|
|
274
|
+
startTime,
|
|
275
|
+
elapsed: 0,
|
|
276
|
+
});
|
|
277
|
+
// Process extensions with hooks
|
|
278
|
+
let processedDoc = document;
|
|
279
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
280
|
+
const extension = extensions[i];
|
|
281
|
+
const pluginStart = Date.now();
|
|
282
|
+
try {
|
|
283
|
+
// Run before hooks
|
|
284
|
+
await this.runBeforeHooks(processedDoc, extension.id);
|
|
285
|
+
// Process with this extension
|
|
286
|
+
const { data: _, ...extensionOptions } = this.options;
|
|
287
|
+
const result = await processGLOSTWithExtensionsAsync(processedDoc, [extension], extensionOptions);
|
|
288
|
+
processedDoc = result.document;
|
|
289
|
+
// Check for errors/skips
|
|
290
|
+
if (result.metadata.errors.length > 0) {
|
|
291
|
+
for (const err of result.metadata.errors) {
|
|
292
|
+
errors.push({
|
|
293
|
+
plugin: extension.id,
|
|
294
|
+
phase: "transform",
|
|
295
|
+
message: err.error.message,
|
|
296
|
+
stack: err.error.stack,
|
|
297
|
+
recoverable: true,
|
|
298
|
+
error: err.error,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (result.metadata.skippedExtensions.includes(extension.id)) {
|
|
303
|
+
skippedPlugins.push(extension.id);
|
|
304
|
+
this.emitSkip(extension.id, "Skipped by processor");
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
appliedPlugins.push(extension.id);
|
|
308
|
+
}
|
|
309
|
+
// Run after hooks
|
|
310
|
+
await this.runAfterHooks(processedDoc, extension.id);
|
|
311
|
+
// Record timing
|
|
312
|
+
timing.set(extension.id, Date.now() - pluginStart);
|
|
313
|
+
// Emit progress
|
|
314
|
+
this.emitProgress({
|
|
315
|
+
total: extensions.length,
|
|
316
|
+
completed: i + 1,
|
|
317
|
+
current: extension.id,
|
|
318
|
+
startTime,
|
|
319
|
+
elapsed: Date.now() - startTime,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
324
|
+
errors.push({
|
|
325
|
+
plugin: extension.id,
|
|
326
|
+
phase: "transform",
|
|
327
|
+
message: err.message,
|
|
328
|
+
stack: err.stack,
|
|
329
|
+
recoverable: false,
|
|
330
|
+
error: err,
|
|
331
|
+
});
|
|
332
|
+
skippedPlugins.push(extension.id);
|
|
333
|
+
this.emitError(err, extension.id);
|
|
334
|
+
this.emitSkip(extension.id, err.message);
|
|
335
|
+
// Re-throw in strict mode
|
|
336
|
+
if (!this.options.lenient) {
|
|
337
|
+
throw err;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const endTime = Date.now();
|
|
342
|
+
return {
|
|
343
|
+
document: processedDoc,
|
|
344
|
+
metadata: {
|
|
345
|
+
appliedPlugins,
|
|
346
|
+
skippedPlugins,
|
|
347
|
+
errors,
|
|
348
|
+
warnings,
|
|
349
|
+
stats: {
|
|
350
|
+
totalTime: endTime - startTime,
|
|
351
|
+
timing,
|
|
352
|
+
nodesProcessed: 0, // Could be calculated by visiting the tree
|
|
353
|
+
startTime,
|
|
354
|
+
endTime,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Process a document synchronously (only if all plugins are sync)
|
|
361
|
+
*
|
|
362
|
+
* @param document - GLOST document to process
|
|
363
|
+
* @returns The processed document
|
|
364
|
+
* @throws {Error} If any plugin is async
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const result = processor.processSync(document);
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
processSync(document) {
|
|
372
|
+
throw new Error("Synchronous processing not yet implemented. Use process() instead.");
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Resolve all plugins to extensions
|
|
376
|
+
*/
|
|
377
|
+
async resolveExtensions() {
|
|
378
|
+
const extensions = [];
|
|
379
|
+
for (const { spec, options } of this.plugins) {
|
|
380
|
+
const extension = await this.resolvePlugin(spec, options);
|
|
381
|
+
if (extension) {
|
|
382
|
+
extensions.push(extension);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return extensions;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Resolve a single plugin to an extension
|
|
389
|
+
*/
|
|
390
|
+
async resolvePlugin(spec, options) {
|
|
391
|
+
// String ID - lookup in registry
|
|
392
|
+
if (typeof spec === "string") {
|
|
393
|
+
const ext = extensionRegistry.get(spec);
|
|
394
|
+
if (!ext) {
|
|
395
|
+
throw new Error(`Plugin "${spec}" not found in registry`);
|
|
396
|
+
}
|
|
397
|
+
return ext;
|
|
398
|
+
}
|
|
399
|
+
// Function - call to get extension
|
|
400
|
+
if (typeof spec === "function") {
|
|
401
|
+
const result = spec(options);
|
|
402
|
+
return result || null;
|
|
403
|
+
}
|
|
404
|
+
// Extension object - use directly
|
|
405
|
+
return spec;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Check if a spec is a preset
|
|
409
|
+
*/
|
|
410
|
+
isPreset(spec) {
|
|
411
|
+
return (spec &&
|
|
412
|
+
typeof spec === "object" &&
|
|
413
|
+
"plugins" in spec &&
|
|
414
|
+
Array.isArray(spec.plugins));
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Run before hooks for a plugin
|
|
418
|
+
*/
|
|
419
|
+
async runBeforeHooks(document, pluginId) {
|
|
420
|
+
const hooks = this.hooks.before.get(pluginId) || [];
|
|
421
|
+
for (const hook of hooks) {
|
|
422
|
+
await hook(document, pluginId);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Run after hooks for a plugin
|
|
427
|
+
*/
|
|
428
|
+
async runAfterHooks(document, pluginId) {
|
|
429
|
+
const hooks = this.hooks.after.get(pluginId) || [];
|
|
430
|
+
for (const hook of hooks) {
|
|
431
|
+
await hook(document, pluginId);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Emit error to error handlers
|
|
436
|
+
*/
|
|
437
|
+
emitError(error, pluginId) {
|
|
438
|
+
for (const hook of this.hooks.onError) {
|
|
439
|
+
try {
|
|
440
|
+
hook(error, pluginId);
|
|
441
|
+
}
|
|
442
|
+
catch (err) {
|
|
443
|
+
console.error("Error in error hook:", err);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Emit skip to skip handlers
|
|
449
|
+
*/
|
|
450
|
+
emitSkip(pluginId, reason) {
|
|
451
|
+
for (const hook of this.hooks.onSkip) {
|
|
452
|
+
try {
|
|
453
|
+
hook(pluginId, reason);
|
|
454
|
+
}
|
|
455
|
+
catch (err) {
|
|
456
|
+
console.error("Error in skip hook:", err);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Emit progress to progress handlers
|
|
462
|
+
*/
|
|
463
|
+
emitProgress(stats) {
|
|
464
|
+
for (const hook of this.hooks.onProgress) {
|
|
465
|
+
try {
|
|
466
|
+
hook(stats);
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
console.error("Error in progress hook:", err);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Assert that the processor is not frozen
|
|
475
|
+
*/
|
|
476
|
+
assertNotFrozen() {
|
|
477
|
+
if (this.frozen) {
|
|
478
|
+
throw new Error("Cannot modify frozen processor");
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
//# sourceMappingURL=processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.js","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAiBtF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAc;IACjB,OAAO,GAA+C,EAAE,CAAC;IACzD,KAAK,GAAmB;QAC9B,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,KAAK,EAAE,IAAI,GAAG,EAAE;QAChB,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;KACf,CAAC;IACM,SAAS,GAAqB,IAAI,GAAG,EAAE,CAAC;IACxC,OAAO,GAAqB,EAAE,CAAC;IAC/B,MAAM,GAAG,KAAK,CAAC;IAEvB;;;;OAIG;IACH,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,IAAyB,EAAE,OAAa;Q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|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processor Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the unified-style GLOST processor.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { GLOSTRoot } from "glost-core";
|
|
9
|
+
import type { GLOSTExtension, ProcessorOptions as ExtensionProcessorOptions } from "glost-extensions";
|
|
10
|
+
/**
|
|
11
|
+
* Plugin function signature
|
|
12
|
+
*
|
|
13
|
+
* A plugin is a function that returns an extension or modifies the processor.
|
|
14
|
+
* Similar to remark/unified plugins.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const myPlugin: Plugin = (options) => {
|
|
19
|
+
* return {
|
|
20
|
+
* id: "my-plugin",
|
|
21
|
+
* name: "My Plugin",
|
|
22
|
+
* transform: (tree) => tree
|
|
23
|
+
* };
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export type Plugin<TOptions = any> = (options?: TOptions) => GLOSTExtension | void;
|
|
28
|
+
/**
|
|
29
|
+
* Plugin specification
|
|
30
|
+
*
|
|
31
|
+
* Can be a plugin function, extension object, or string ID.
|
|
32
|
+
*/
|
|
33
|
+
export type PluginSpec = Plugin | GLOSTExtension | string;
|
|
34
|
+
/**
|
|
35
|
+
* Preset definition
|
|
36
|
+
*
|
|
37
|
+
* A preset is a collection of plugins with their options.
|
|
38
|
+
* Similar to babel presets.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const preset: Preset = {
|
|
43
|
+
* id: "language-learning",
|
|
44
|
+
* name: "Language Learning",
|
|
45
|
+
* description: "Full language learning stack",
|
|
46
|
+
* plugins: [
|
|
47
|
+
* ["transcription", { scheme: "ipa" }],
|
|
48
|
+
* ["translation", { target: "en" }],
|
|
49
|
+
* ["frequency"],
|
|
50
|
+
* ]
|
|
51
|
+
* };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export interface Preset {
|
|
55
|
+
/** Unique preset identifier */
|
|
56
|
+
id: string;
|
|
57
|
+
/** Human-readable name */
|
|
58
|
+
name: string;
|
|
59
|
+
/** Optional description */
|
|
60
|
+
description?: string;
|
|
61
|
+
/** Plugins to apply with their options */
|
|
62
|
+
plugins: Array<PluginSpec | [PluginSpec, any]>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Processing hook types
|
|
66
|
+
*/
|
|
67
|
+
export type BeforeHook = (document: GLOSTRoot, pluginId: string) => void | Promise<void>;
|
|
68
|
+
export type AfterHook = (document: GLOSTRoot, pluginId: string) => void | Promise<void>;
|
|
69
|
+
export type ErrorHook = (error: Error, pluginId: string) => void;
|
|
70
|
+
export type SkipHook = (pluginId: string, reason: string) => void;
|
|
71
|
+
export type ProgressHook = (stats: ProgressStats) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Progress statistics
|
|
74
|
+
*/
|
|
75
|
+
export interface ProgressStats {
|
|
76
|
+
/** Total number of plugins */
|
|
77
|
+
total: number;
|
|
78
|
+
/** Number of plugins completed */
|
|
79
|
+
completed: number;
|
|
80
|
+
/** Current plugin being processed */
|
|
81
|
+
current?: string;
|
|
82
|
+
/** Processing start time */
|
|
83
|
+
startTime: number;
|
|
84
|
+
/** Elapsed time in ms */
|
|
85
|
+
elapsed: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Processing hooks
|
|
89
|
+
*/
|
|
90
|
+
export interface ProcessorHooks {
|
|
91
|
+
before: Map<string, BeforeHook[]>;
|
|
92
|
+
after: Map<string, AfterHook[]>;
|
|
93
|
+
onError: ErrorHook[];
|
|
94
|
+
onSkip: SkipHook[];
|
|
95
|
+
onProgress: ProgressHook[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Processor options
|
|
99
|
+
*/
|
|
100
|
+
export interface ProcessorOptions extends ExtensionProcessorOptions {
|
|
101
|
+
/** Data storage for sharing state between plugins */
|
|
102
|
+
data?: Map<string, any>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Processing result with detailed metadata
|
|
106
|
+
*/
|
|
107
|
+
export interface ProcessingResult {
|
|
108
|
+
/** The processed document */
|
|
109
|
+
document: GLOSTRoot;
|
|
110
|
+
/** Processing metadata */
|
|
111
|
+
metadata: {
|
|
112
|
+
/** Plugins that were applied */
|
|
113
|
+
appliedPlugins: string[];
|
|
114
|
+
/** Plugins that were skipped */
|
|
115
|
+
skippedPlugins: string[];
|
|
116
|
+
/** Processing errors */
|
|
117
|
+
errors: ProcessingError[];
|
|
118
|
+
/** Processing warnings */
|
|
119
|
+
warnings: ProcessingWarning[];
|
|
120
|
+
/** Processing statistics */
|
|
121
|
+
stats: ProcessingStats;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Processing error details
|
|
126
|
+
*/
|
|
127
|
+
export interface ProcessingError {
|
|
128
|
+
/** Plugin that caused the error */
|
|
129
|
+
plugin: string;
|
|
130
|
+
/** Processing phase */
|
|
131
|
+
phase: "transform" | "visit" | "enhance";
|
|
132
|
+
/** Error message */
|
|
133
|
+
message: string;
|
|
134
|
+
/** Error stack trace */
|
|
135
|
+
stack?: string;
|
|
136
|
+
/** Whether the error is recoverable */
|
|
137
|
+
recoverable: boolean;
|
|
138
|
+
/** Original error object */
|
|
139
|
+
error: Error;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Processing warning details
|
|
143
|
+
*/
|
|
144
|
+
export interface ProcessingWarning {
|
|
145
|
+
/** Plugin that issued the warning */
|
|
146
|
+
plugin: string;
|
|
147
|
+
/** Warning message */
|
|
148
|
+
message: string;
|
|
149
|
+
/** Warning severity */
|
|
150
|
+
severity: "low" | "medium" | "high";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Processing statistics
|
|
154
|
+
*/
|
|
155
|
+
export interface ProcessingStats {
|
|
156
|
+
/** Total processing time in ms */
|
|
157
|
+
totalTime: number;
|
|
158
|
+
/** Time per plugin in ms */
|
|
159
|
+
timing: Map<string, number>;
|
|
160
|
+
/** Total nodes processed */
|
|
161
|
+
nodesProcessed: number;
|
|
162
|
+
/** Processing start timestamp */
|
|
163
|
+
startTime: number;
|
|
164
|
+
/** Processing end timestamp */
|
|
165
|
+
endTime: number;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,IAAI,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAEtG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,MAAM,CAAC,QAAQ,GAAG,GAAG,IAAI,CACnC,OAAO,CAAC,EAAE,QAAQ,KACf,cAAc,GAAG,IAAI,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,MAAM;IACrB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IAEb,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,0CAA0C;IAC1C,OAAO,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAA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