svelte-highlight 7.22.0 → 7.23.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/AnsiOutput.svelte +6 -30
- package/FileTabs.svelte +3 -1
- package/HighlightEditable.svelte +115 -143
- package/HighlightStream.svelte +44 -48
- package/HighlightStyle.svelte +9 -21
- package/HighlightVirtual.svelte +82 -4
- package/HighlightVirtual.svelte.d.ts +19 -2
- package/MarkdownStream.svelte +16 -9
- package/README.md +27 -7
- package/ansi-color.js +109 -22
- package/ansi-output.js +93 -0
- package/ansi.d.ts +18 -0
- package/ansi.js +85 -24
- package/css-walk.js +9 -12
- package/editable-css-paint.js +118 -0
- package/editable-dom-paint.js +217 -146
- package/editable-line-dom.js +241 -0
- package/engine.d.ts +28 -6
- package/engine.js +707 -144
- package/fence.d.ts +5 -5
- package/fence.js +196 -56
- package/highlight-theme.js +10 -4
- package/incremental-tokenize.js +95 -17
- package/package.json +1 -1
- package/preprocessor.js +16 -2
- package/scoped.js +15 -13
- package/search.d.ts +6 -4
- package/search.js +427 -85
- package/stream-final-highlight.js +52 -0
- package/stream-highlighted.js +17 -0
- package/stream-preview.js +7 -2
- package/stream-regenerate.js +262 -0
- package/style-registry.js +60 -0
- package/text-diff.js +66 -18
- package/tokenized-document.d.ts +8 -0
- package/tokenized-document.js +60 -15
- package/worker.js +14 -2
package/engine.d.ts
CHANGED
|
@@ -152,7 +152,8 @@ export interface HighlightResult {
|
|
|
152
152
|
* versions: a snapshot produced by an older or newer version of this
|
|
153
153
|
* package may be rejected on resume. Callers that persist snapshots across
|
|
154
154
|
* deploys (windowing, long-lived streaming sessions) should pin the engine
|
|
155
|
-
* version or be prepared to discard stale snapshots.
|
|
155
|
+
* version or be prepared to discard stale snapshots. Treat a snapshot as
|
|
156
|
+
* read-only: it may share state with the tokenizer that produced it.
|
|
156
157
|
*/
|
|
157
158
|
export interface Snapshot {
|
|
158
159
|
pos: number;
|
|
@@ -184,15 +185,33 @@ export interface StreamSession {
|
|
|
184
185
|
/** Tokenizes text loaded via `createSession`'s `from.code` up to (not
|
|
185
186
|
* including) the first lexeme starting at or past `stopAt`. */
|
|
186
187
|
advance(stopAt: number): void;
|
|
188
|
+
/** Same as `append(text.slice(fedLength))`, where `text` is everything
|
|
189
|
+
* fed so far plus more, ideally a slice of one larger string. Avoids
|
|
190
|
+
* re-flattening a concatenated string on every call. */
|
|
191
|
+
feed(text: string): void;
|
|
187
192
|
/** Replaces `[from, to)` in the session's fed text with `text`, reusing
|
|
188
193
|
* unaffected tokenized regions where state reconverges (see
|
|
189
194
|
* `incremental-tokenize.js`). The resulting `events()` are always
|
|
190
195
|
* identical to a fresh session fed the resulting text from scratch,
|
|
191
|
-
* computed cheaper. Does not support replacing across a language change.
|
|
192
|
-
|
|
196
|
+
* computed cheaper. Does not support replacing across a language change.
|
|
197
|
+
* Returns how many leading `events()` entries are the same objects as
|
|
198
|
+
* before the call (0 on the first call, which re-parses). */
|
|
199
|
+
replace(from: number, to: number, text: string): number;
|
|
200
|
+
/** The last of the last `replace()`'s checkpoints (none before the first)
|
|
201
|
+
* within both limits: `events()[0, eventCount)` covers the text before
|
|
202
|
+
* `textPos` and leaves `scopes` open, so rendering can resume there. */
|
|
203
|
+
checkpointBefore(limits: {
|
|
204
|
+
eventCount?: number;
|
|
205
|
+
textPos?: number;
|
|
206
|
+
}): { textPos: number; eventCount: number; scopes: string[] } | undefined;
|
|
193
207
|
finish(options?: { canonicalize?: boolean }): HighlightResult;
|
|
194
208
|
snapshot(): Snapshot;
|
|
195
209
|
events(): ScopeEvent[];
|
|
210
|
+
/** Returns the events produced since the last call and forgets them, so a
|
|
211
|
+
* long session doesn't retain every event. Afterward `events()`,
|
|
212
|
+
* `finish()`, and snapshot `eventCount`s only cover later events; don't
|
|
213
|
+
* mix with `replace()`. */
|
|
214
|
+
takeEvents(): ScopeEvent[];
|
|
196
215
|
}
|
|
197
216
|
|
|
198
217
|
/** The compiled program `Registry#get` returns; opaque other than its source IR's identity. */
|
|
@@ -213,8 +232,9 @@ export class UnknownLanguageError extends Error {
|
|
|
213
232
|
}
|
|
214
233
|
|
|
215
234
|
/**
|
|
216
|
-
* Thrown by the tokenizer once a parse exceeds 500,000 iterations
|
|
217
|
-
*
|
|
235
|
+
* Thrown by the tokenizer once a parse exceeds both 500,000 iterations
|
|
236
|
+
* and three iterations per character consumed, guarding against a grammar
|
|
237
|
+
* bug that never advances position.
|
|
218
238
|
*/
|
|
219
239
|
export class TokenizerLoopError extends Error {
|
|
220
240
|
constructor(grammarName: string, iterations: number);
|
|
@@ -244,7 +264,9 @@ export interface Registry {
|
|
|
244
264
|
tokenizeRanges(code: string, options: { language: string }): TokenRange[];
|
|
245
265
|
createSession(
|
|
246
266
|
language: string,
|
|
247
|
-
options?: {
|
|
267
|
+
options?: {
|
|
268
|
+
from?: { code: string; snapshot?: Snapshot; windowed?: boolean };
|
|
269
|
+
},
|
|
248
270
|
): StreamSession;
|
|
249
271
|
resume(
|
|
250
272
|
code: string,
|