glost-processor 0.7.0 → 1.0.2
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 -21
- package/README.md +262 -262
- package/package.json +4 -4
- package/src/__benchmarks__/stream-processor.bench.d.ts +8 -0
- package/src/__benchmarks__/stream-processor.bench.d.ts.map +1 -0
- package/src/__benchmarks__/stream-processor.bench.js +202 -0
- package/src/__benchmarks__/stream-processor.bench.js.map +1 -0
- package/src/index.d.ts +59 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +57 -0
- package/src/index.js.map +1 -0
- package/src/processor.d.ts +256 -0
- package/src/processor.d.ts.map +1 -0
- package/src/processor.js +482 -0
- package/src/processor.js.map +1 -0
- package/src/stream-processor.d.ts +145 -0
- package/src/stream-processor.d.ts.map +1 -0
- package/src/stream-processor.js +245 -0
- package/src/stream-processor.js.map +1 -0
- package/src/types.d.ts +167 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +9 -0
- package/src/types.js.map +1 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 GLOST Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GLOST Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
# glost-processor
|
|
2
|
-
|
|
3
|
-
Unified-style processor API for GLOST documents with fluent plugin composition.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
`glost-processor` provides a fluent API for processing GLOST documents through plugin pipelines, similar to the [unified](https://unifiedjs.com/) ecosystem (remark, rehype, etc.).
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install glost-processor
|
|
13
|
-
# or
|
|
14
|
-
pnpm add glost-processor
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Basic Processing
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { glost } from "glost-processor";
|
|
23
|
-
import { transcription } from "glost-transcription";
|
|
24
|
-
import { translation } from "glost-translation";
|
|
25
|
-
import { frequency } from "glost-frequency";
|
|
26
|
-
|
|
27
|
-
const processor = glost()
|
|
28
|
-
.use(transcription, { scheme: "ipa" })
|
|
29
|
-
.use(translation, { target: "en" })
|
|
30
|
-
.use(frequency);
|
|
31
|
-
|
|
32
|
-
const result = await processor.process(document);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Freezing for Reuse
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
const frozen = glost()
|
|
39
|
-
.use(transcription)
|
|
40
|
-
.use(translation)
|
|
41
|
-
.freeze();
|
|
42
|
-
|
|
43
|
-
// Reuse across multiple documents
|
|
44
|
-
const result1 = await frozen.process(doc1);
|
|
45
|
-
const result2 = await frozen.process(doc2);
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Using Presets
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import { languageLearningPreset } from "glost-presets";
|
|
52
|
-
|
|
53
|
-
const processor = glost()
|
|
54
|
-
.use(languageLearningPreset);
|
|
55
|
-
|
|
56
|
-
const result = await processor.process(document);
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Hooks and Middleware
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
const processor = glost()
|
|
63
|
-
.use(transcription)
|
|
64
|
-
.use(translation)
|
|
65
|
-
.before("translation", (doc) => {
|
|
66
|
-
console.log("About to translate");
|
|
67
|
-
})
|
|
68
|
-
.after("translation", (doc) => {
|
|
69
|
-
console.log("Translation complete");
|
|
70
|
-
})
|
|
71
|
-
.onError((error, plugin) => {
|
|
72
|
-
console.error(`Plugin ${plugin} failed:`, error);
|
|
73
|
-
})
|
|
74
|
-
.onProgress((stats) => {
|
|
75
|
-
console.log(`Progress: ${stats.completed}/${stats.total}`);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const result = await processor.process(document);
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Data Storage
|
|
82
|
-
|
|
83
|
-
Share data between plugins:
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
const processor = glost()
|
|
87
|
-
.data("config", { theme: "dark" })
|
|
88
|
-
.use(plugin1)
|
|
89
|
-
.use(plugin2);
|
|
90
|
-
|
|
91
|
-
// Access in plugins
|
|
92
|
-
const config = processor.data("config");
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Processing with Metadata
|
|
96
|
-
|
|
97
|
-
Get detailed processing information:
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
const result = await processor.processWithMeta(document);
|
|
101
|
-
|
|
102
|
-
console.log(result.document); // Processed document
|
|
103
|
-
console.log(result.metadata.appliedPlugins); // Which plugins ran
|
|
104
|
-
console.log(result.metadata.stats.totalTime); // Total time
|
|
105
|
-
console.log(result.metadata.errors); // Any errors
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## API
|
|
109
|
-
|
|
110
|
-
### `glost(options?)`
|
|
111
|
-
|
|
112
|
-
Create a new processor instance.
|
|
113
|
-
|
|
114
|
-
**Options:**
|
|
115
|
-
- `lenient?: boolean` - If true, continue processing on errors (default: false)
|
|
116
|
-
- `conflictStrategy?: "error" | "warn" | "lastWins"` - How to handle metadata conflicts
|
|
117
|
-
- `debug?: boolean` - Enable debug logging
|
|
118
|
-
- `data?: Map<string, any>` - Initial data store
|
|
119
|
-
|
|
120
|
-
### `processor.use(plugin, options?)`
|
|
121
|
-
|
|
122
|
-
Add a plugin to the pipeline.
|
|
123
|
-
|
|
124
|
-
**Parameters:**
|
|
125
|
-
- `plugin` - Plugin function, extension object, preset, or plugin ID string
|
|
126
|
-
- `options` - Plugin-specific options
|
|
127
|
-
|
|
128
|
-
**Returns:** The processor for chaining
|
|
129
|
-
|
|
130
|
-
### `processor.freeze()`
|
|
131
|
-
|
|
132
|
-
Freeze the processor configuration for reuse.
|
|
133
|
-
|
|
134
|
-
**Returns:** A frozen processor that can only process documents
|
|
135
|
-
|
|
136
|
-
### `processor.process(document)`
|
|
137
|
-
|
|
138
|
-
Process a document through the pipeline.
|
|
139
|
-
|
|
140
|
-
**Parameters:**
|
|
141
|
-
- `document` - GLOST document to process
|
|
142
|
-
|
|
143
|
-
**Returns:** Promise resolving to the processed document
|
|
144
|
-
|
|
145
|
-
### `processor.processWithMeta(document)`
|
|
146
|
-
|
|
147
|
-
Process a document and get detailed metadata.
|
|
148
|
-
|
|
149
|
-
**Parameters:**
|
|
150
|
-
- `document` - GLOST document to process
|
|
151
|
-
|
|
152
|
-
**Returns:** Promise resolving to processing result with metadata
|
|
153
|
-
|
|
154
|
-
### `processor.before(pluginId, hook)`
|
|
155
|
-
|
|
156
|
-
Register a hook to run before a plugin.
|
|
157
|
-
|
|
158
|
-
**Parameters:**
|
|
159
|
-
- `pluginId` - Plugin ID to hook into
|
|
160
|
-
- `hook` - Function to run before the plugin
|
|
161
|
-
|
|
162
|
-
**Returns:** The processor for chaining
|
|
163
|
-
|
|
164
|
-
### `processor.after(pluginId, hook)`
|
|
165
|
-
|
|
166
|
-
Register a hook to run after a plugin.
|
|
167
|
-
|
|
168
|
-
**Parameters:**
|
|
169
|
-
- `pluginId` - Plugin ID to hook into
|
|
170
|
-
- `hook` - Function to run after the plugin
|
|
171
|
-
|
|
172
|
-
**Returns:** The processor for chaining
|
|
173
|
-
|
|
174
|
-
### `processor.onError(hook)`
|
|
175
|
-
|
|
176
|
-
Register an error handler.
|
|
177
|
-
|
|
178
|
-
**Parameters:**
|
|
179
|
-
- `hook` - Function to handle errors
|
|
180
|
-
|
|
181
|
-
**Returns:** The processor for chaining
|
|
182
|
-
|
|
183
|
-
### `processor.onSkip(hook)`
|
|
184
|
-
|
|
185
|
-
Register a skip handler.
|
|
186
|
-
|
|
187
|
-
**Parameters:**
|
|
188
|
-
- `hook` - Function to handle skipped plugins
|
|
189
|
-
|
|
190
|
-
**Returns:** The processor for chaining
|
|
191
|
-
|
|
192
|
-
### `processor.onProgress(hook)`
|
|
193
|
-
|
|
194
|
-
Register a progress handler.
|
|
195
|
-
|
|
196
|
-
**Parameters:**
|
|
197
|
-
- `hook` - Function to handle progress updates
|
|
198
|
-
|
|
199
|
-
**Returns:** The processor for chaining
|
|
200
|
-
|
|
201
|
-
### `processor.data(key, value?)`
|
|
202
|
-
|
|
203
|
-
Get or set data in the processor data store.
|
|
204
|
-
|
|
205
|
-
**Parameters:**
|
|
206
|
-
- `key` - Data key
|
|
207
|
-
- `value` - Data value (omit to get)
|
|
208
|
-
|
|
209
|
-
**Returns:** Value if getting, processor if setting
|
|
210
|
-
|
|
211
|
-
## Plugin Format
|
|
212
|
-
|
|
213
|
-
Plugins can be:
|
|
214
|
-
|
|
215
|
-
1. **Plugin functions** (returns an extension)
|
|
216
|
-
```typescript
|
|
217
|
-
const myPlugin = (options) => {
|
|
218
|
-
return {
|
|
219
|
-
id: "my-plugin",
|
|
220
|
-
name: "My Plugin",
|
|
221
|
-
transform: (tree) => tree
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
2. **Extension objects** (used directly)
|
|
227
|
-
```typescript
|
|
228
|
-
const myExtension = {
|
|
229
|
-
id: "my-extension",
|
|
230
|
-
name: "My Extension",
|
|
231
|
-
transform: (tree) => tree
|
|
232
|
-
};
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
3. **Plugin ID strings** (looked up in registry)
|
|
236
|
-
```typescript
|
|
237
|
-
processor.use("transcription");
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## Comparison with Old API
|
|
241
|
-
|
|
242
|
-
**Old API:**
|
|
243
|
-
```typescript
|
|
244
|
-
import { processGLOSTWithExtensions } from "glost-
|
|
245
|
-
|
|
246
|
-
const result = processGLOSTWithExtensions(doc, [ext1, ext2, ext3]);
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
**New API:**
|
|
250
|
-
```typescript
|
|
251
|
-
import { glost } from "glost-processor";
|
|
252
|
-
|
|
253
|
-
const result = await glost()
|
|
254
|
-
.use(ext1)
|
|
255
|
-
.use(ext2)
|
|
256
|
-
.use(ext3)
|
|
257
|
-
.process(doc);
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## License
|
|
261
|
-
|
|
262
|
-
MIT
|
|
1
|
+
# glost-processor
|
|
2
|
+
|
|
3
|
+
Unified-style processor API for GLOST documents with fluent plugin composition.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`glost-processor` provides a fluent API for processing GLOST documents through plugin pipelines, similar to the [unified](https://unifiedjs.com/) ecosystem (remark, rehype, etc.).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install glost-processor
|
|
13
|
+
# or
|
|
14
|
+
pnpm add glost-processor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Basic Processing
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { glost } from "glost-processor";
|
|
23
|
+
import { transcription } from "glost-transcription";
|
|
24
|
+
import { translation } from "glost-translation";
|
|
25
|
+
import { frequency } from "glost-frequency";
|
|
26
|
+
|
|
27
|
+
const processor = glost()
|
|
28
|
+
.use(transcription, { scheme: "ipa" })
|
|
29
|
+
.use(translation, { target: "en" })
|
|
30
|
+
.use(frequency);
|
|
31
|
+
|
|
32
|
+
const result = await processor.process(document);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Freezing for Reuse
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const frozen = glost()
|
|
39
|
+
.use(transcription)
|
|
40
|
+
.use(translation)
|
|
41
|
+
.freeze();
|
|
42
|
+
|
|
43
|
+
// Reuse across multiple documents
|
|
44
|
+
const result1 = await frozen.process(doc1);
|
|
45
|
+
const result2 = await frozen.process(doc2);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Using Presets
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { languageLearningPreset } from "glost-presets";
|
|
52
|
+
|
|
53
|
+
const processor = glost()
|
|
54
|
+
.use(languageLearningPreset);
|
|
55
|
+
|
|
56
|
+
const result = await processor.process(document);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Hooks and Middleware
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const processor = glost()
|
|
63
|
+
.use(transcription)
|
|
64
|
+
.use(translation)
|
|
65
|
+
.before("translation", (doc) => {
|
|
66
|
+
console.log("About to translate");
|
|
67
|
+
})
|
|
68
|
+
.after("translation", (doc) => {
|
|
69
|
+
console.log("Translation complete");
|
|
70
|
+
})
|
|
71
|
+
.onError((error, plugin) => {
|
|
72
|
+
console.error(`Plugin ${plugin} failed:`, error);
|
|
73
|
+
})
|
|
74
|
+
.onProgress((stats) => {
|
|
75
|
+
console.log(`Progress: ${stats.completed}/${stats.total}`);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const result = await processor.process(document);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Data Storage
|
|
82
|
+
|
|
83
|
+
Share data between plugins:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const processor = glost()
|
|
87
|
+
.data("config", { theme: "dark" })
|
|
88
|
+
.use(plugin1)
|
|
89
|
+
.use(plugin2);
|
|
90
|
+
|
|
91
|
+
// Access in plugins
|
|
92
|
+
const config = processor.data("config");
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Processing with Metadata
|
|
96
|
+
|
|
97
|
+
Get detailed processing information:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const result = await processor.processWithMeta(document);
|
|
101
|
+
|
|
102
|
+
console.log(result.document); // Processed document
|
|
103
|
+
console.log(result.metadata.appliedPlugins); // Which plugins ran
|
|
104
|
+
console.log(result.metadata.stats.totalTime); // Total time
|
|
105
|
+
console.log(result.metadata.errors); // Any errors
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## API
|
|
109
|
+
|
|
110
|
+
### `glost(options?)`
|
|
111
|
+
|
|
112
|
+
Create a new processor instance.
|
|
113
|
+
|
|
114
|
+
**Options:**
|
|
115
|
+
- `lenient?: boolean` - If true, continue processing on errors (default: false)
|
|
116
|
+
- `conflictStrategy?: "error" | "warn" | "lastWins"` - How to handle metadata conflicts
|
|
117
|
+
- `debug?: boolean` - Enable debug logging
|
|
118
|
+
- `data?: Map<string, any>` - Initial data store
|
|
119
|
+
|
|
120
|
+
### `processor.use(plugin, options?)`
|
|
121
|
+
|
|
122
|
+
Add a plugin to the pipeline.
|
|
123
|
+
|
|
124
|
+
**Parameters:**
|
|
125
|
+
- `plugin` - Plugin function, extension object, preset, or plugin ID string
|
|
126
|
+
- `options` - Plugin-specific options
|
|
127
|
+
|
|
128
|
+
**Returns:** The processor for chaining
|
|
129
|
+
|
|
130
|
+
### `processor.freeze()`
|
|
131
|
+
|
|
132
|
+
Freeze the processor configuration for reuse.
|
|
133
|
+
|
|
134
|
+
**Returns:** A frozen processor that can only process documents
|
|
135
|
+
|
|
136
|
+
### `processor.process(document)`
|
|
137
|
+
|
|
138
|
+
Process a document through the pipeline.
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
- `document` - GLOST document to process
|
|
142
|
+
|
|
143
|
+
**Returns:** Promise resolving to the processed document
|
|
144
|
+
|
|
145
|
+
### `processor.processWithMeta(document)`
|
|
146
|
+
|
|
147
|
+
Process a document and get detailed metadata.
|
|
148
|
+
|
|
149
|
+
**Parameters:**
|
|
150
|
+
- `document` - GLOST document to process
|
|
151
|
+
|
|
152
|
+
**Returns:** Promise resolving to processing result with metadata
|
|
153
|
+
|
|
154
|
+
### `processor.before(pluginId, hook)`
|
|
155
|
+
|
|
156
|
+
Register a hook to run before a plugin.
|
|
157
|
+
|
|
158
|
+
**Parameters:**
|
|
159
|
+
- `pluginId` - Plugin ID to hook into
|
|
160
|
+
- `hook` - Function to run before the plugin
|
|
161
|
+
|
|
162
|
+
**Returns:** The processor for chaining
|
|
163
|
+
|
|
164
|
+
### `processor.after(pluginId, hook)`
|
|
165
|
+
|
|
166
|
+
Register a hook to run after a plugin.
|
|
167
|
+
|
|
168
|
+
**Parameters:**
|
|
169
|
+
- `pluginId` - Plugin ID to hook into
|
|
170
|
+
- `hook` - Function to run after the plugin
|
|
171
|
+
|
|
172
|
+
**Returns:** The processor for chaining
|
|
173
|
+
|
|
174
|
+
### `processor.onError(hook)`
|
|
175
|
+
|
|
176
|
+
Register an error handler.
|
|
177
|
+
|
|
178
|
+
**Parameters:**
|
|
179
|
+
- `hook` - Function to handle errors
|
|
180
|
+
|
|
181
|
+
**Returns:** The processor for chaining
|
|
182
|
+
|
|
183
|
+
### `processor.onSkip(hook)`
|
|
184
|
+
|
|
185
|
+
Register a skip handler.
|
|
186
|
+
|
|
187
|
+
**Parameters:**
|
|
188
|
+
- `hook` - Function to handle skipped plugins
|
|
189
|
+
|
|
190
|
+
**Returns:** The processor for chaining
|
|
191
|
+
|
|
192
|
+
### `processor.onProgress(hook)`
|
|
193
|
+
|
|
194
|
+
Register a progress handler.
|
|
195
|
+
|
|
196
|
+
**Parameters:**
|
|
197
|
+
- `hook` - Function to handle progress updates
|
|
198
|
+
|
|
199
|
+
**Returns:** The processor for chaining
|
|
200
|
+
|
|
201
|
+
### `processor.data(key, value?)`
|
|
202
|
+
|
|
203
|
+
Get or set data in the processor data store.
|
|
204
|
+
|
|
205
|
+
**Parameters:**
|
|
206
|
+
- `key` - Data key
|
|
207
|
+
- `value` - Data value (omit to get)
|
|
208
|
+
|
|
209
|
+
**Returns:** Value if getting, processor if setting
|
|
210
|
+
|
|
211
|
+
## Plugin Format
|
|
212
|
+
|
|
213
|
+
Plugins can be:
|
|
214
|
+
|
|
215
|
+
1. **Plugin functions** (returns an extension)
|
|
216
|
+
```typescript
|
|
217
|
+
const myPlugin = (options) => {
|
|
218
|
+
return {
|
|
219
|
+
id: "my-plugin",
|
|
220
|
+
name: "My Plugin",
|
|
221
|
+
transform: (tree) => tree
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
2. **Extension objects** (used directly)
|
|
227
|
+
```typescript
|
|
228
|
+
const myExtension = {
|
|
229
|
+
id: "my-extension",
|
|
230
|
+
name: "My Extension",
|
|
231
|
+
transform: (tree) => tree
|
|
232
|
+
};
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
3. **Plugin ID strings** (looked up in registry)
|
|
236
|
+
```typescript
|
|
237
|
+
processor.use("transcription");
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Comparison with Old API
|
|
241
|
+
|
|
242
|
+
**Old API:**
|
|
243
|
+
```typescript
|
|
244
|
+
import { processGLOSTWithExtensions } from "glost-plugins";
|
|
245
|
+
|
|
246
|
+
const result = processGLOSTWithExtensions(doc, [ext1, ext2, ext3]);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**New API:**
|
|
250
|
+
```typescript
|
|
251
|
+
import { glost } from "glost-processor";
|
|
252
|
+
|
|
253
|
+
const result = await glost()
|
|
254
|
+
.use(ext1)
|
|
255
|
+
.use(ext2)
|
|
256
|
+
.use(ext3)
|
|
257
|
+
.process(doc);
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glost-processor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Unified-style processor API for GLOST documents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"author": "",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"glost-core": "0.
|
|
30
|
-
"glost-extensions": "0.
|
|
29
|
+
"glost-core": "0.6.2",
|
|
30
|
+
"glost-extensions": "0.6.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^20.0.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"vitest": "^1.6.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"glost-core": "^0.
|
|
38
|
+
"glost-core": "^0.6.2"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-processor.bench.d.ts","sourceRoot":"","sources":["stream-processor.bench.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|