Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
12
node_modules/micromark-util-subtokenize/dev/index.d.ts
generated
vendored
Normal file
12
node_modules/micromark-util-subtokenize/dev/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Tokenize subcontent.
|
||||
*
|
||||
* @param {Array<Event>} eventsArray
|
||||
* List of events.
|
||||
* @returns {boolean}
|
||||
* Whether subtokens were found.
|
||||
*/
|
||||
export function subtokenize(eventsArray: Array<Event>): boolean;
|
||||
export { SpliceBuffer } from "./lib/splice-buffer.js";
|
||||
import type { Event } from 'micromark-util-types';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/micromark-util-subtokenize/dev/index.d.ts.map
generated
vendored
Normal file
1
node_modules/micromark-util-subtokenize/dev/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AAEH,yCANW,KAAK,CAAC,KAAK,CAAC,GAEV,OAAO,CAuHnB;;2BAvIqC,sBAAsB"}
|
284
node_modules/micromark-util-subtokenize/dev/index.js
generated
vendored
Normal file
284
node_modules/micromark-util-subtokenize/dev/index.js
generated
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
/**
|
||||
* @import {Chunk, Event, Token} from 'micromark-util-types'
|
||||
*/
|
||||
|
||||
import {ok as assert} from 'devlop'
|
||||
import {splice} from 'micromark-util-chunked'
|
||||
import {codes, types} from 'micromark-util-symbol'
|
||||
import {SpliceBuffer} from './lib/splice-buffer.js'
|
||||
|
||||
// Hidden API exposed for testing.
|
||||
export {SpliceBuffer} from './lib/splice-buffer.js'
|
||||
|
||||
/**
|
||||
* Tokenize subcontent.
|
||||
*
|
||||
* @param {Array<Event>} eventsArray
|
||||
* List of events.
|
||||
* @returns {boolean}
|
||||
* Whether subtokens were found.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export function subtokenize(eventsArray) {
|
||||
/** @type {Record<string, number>} */
|
||||
const jumps = {}
|
||||
let index = -1
|
||||
/** @type {Event} */
|
||||
let event
|
||||
/** @type {number | undefined} */
|
||||
let lineIndex
|
||||
/** @type {number} */
|
||||
let otherIndex
|
||||
/** @type {Event} */
|
||||
let otherEvent
|
||||
/** @type {Array<Event>} */
|
||||
let parameters
|
||||
/** @type {Array<Event>} */
|
||||
let subevents
|
||||
/** @type {boolean | undefined} */
|
||||
let more
|
||||
const events = new SpliceBuffer(eventsArray)
|
||||
|
||||
while (++index < events.length) {
|
||||
while (index in jumps) {
|
||||
index = jumps[index]
|
||||
}
|
||||
|
||||
event = events.get(index)
|
||||
|
||||
// Add a hook for the GFM tasklist extension, which needs to know if text
|
||||
// is in the first content of a list item.
|
||||
if (
|
||||
index &&
|
||||
event[1].type === types.chunkFlow &&
|
||||
events.get(index - 1)[1].type === types.listItemPrefix
|
||||
) {
|
||||
assert(event[1]._tokenizer, 'expected `_tokenizer` on subtokens')
|
||||
subevents = event[1]._tokenizer.events
|
||||
otherIndex = 0
|
||||
|
||||
if (
|
||||
otherIndex < subevents.length &&
|
||||
subevents[otherIndex][1].type === types.lineEndingBlank
|
||||
) {
|
||||
otherIndex += 2
|
||||
}
|
||||
|
||||
if (
|
||||
otherIndex < subevents.length &&
|
||||
subevents[otherIndex][1].type === types.content
|
||||
) {
|
||||
while (++otherIndex < subevents.length) {
|
||||
if (subevents[otherIndex][1].type === types.content) {
|
||||
break
|
||||
}
|
||||
|
||||
if (subevents[otherIndex][1].type === types.chunkText) {
|
||||
subevents[otherIndex][1]._isInFirstContentOfListItem = true
|
||||
otherIndex++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enter.
|
||||
if (event[0] === 'enter') {
|
||||
if (event[1].contentType) {
|
||||
Object.assign(jumps, subcontent(events, index))
|
||||
index = jumps[index]
|
||||
more = true
|
||||
}
|
||||
}
|
||||
// Exit.
|
||||
else if (event[1]._container) {
|
||||
otherIndex = index
|
||||
lineIndex = undefined
|
||||
|
||||
while (otherIndex--) {
|
||||
otherEvent = events.get(otherIndex)
|
||||
|
||||
if (
|
||||
otherEvent[1].type === types.lineEnding ||
|
||||
otherEvent[1].type === types.lineEndingBlank
|
||||
) {
|
||||
if (otherEvent[0] === 'enter') {
|
||||
if (lineIndex) {
|
||||
events.get(lineIndex)[1].type = types.lineEndingBlank
|
||||
}
|
||||
|
||||
otherEvent[1].type = types.lineEnding
|
||||
lineIndex = otherIndex
|
||||
}
|
||||
} else if (
|
||||
otherEvent[1].type === types.linePrefix ||
|
||||
otherEvent[1].type === types.listItemIndent
|
||||
) {
|
||||
// Move past.
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (lineIndex) {
|
||||
// Fix position.
|
||||
event[1].end = {...events.get(lineIndex)[1].start}
|
||||
|
||||
// Switch container exit w/ line endings.
|
||||
parameters = events.slice(lineIndex, index)
|
||||
parameters.unshift(event)
|
||||
events.splice(lineIndex, index - lineIndex + 1, parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The changes to the `events` buffer must be copied back into the eventsArray
|
||||
splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0))
|
||||
return !more
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize embedded tokens.
|
||||
*
|
||||
* @param {SpliceBuffer<Event>} events
|
||||
* Events.
|
||||
* @param {number} eventIndex
|
||||
* Index.
|
||||
* @returns {Record<string, number>}
|
||||
* Gaps.
|
||||
*/
|
||||
function subcontent(events, eventIndex) {
|
||||
const token = events.get(eventIndex)[1]
|
||||
const context = events.get(eventIndex)[2]
|
||||
let startPosition = eventIndex - 1
|
||||
/** @type {Array<number>} */
|
||||
const startPositions = []
|
||||
assert(token.contentType, 'expected `contentType` on subtokens')
|
||||
|
||||
let tokenizer = token._tokenizer
|
||||
|
||||
if (!tokenizer) {
|
||||
tokenizer = context.parser[token.contentType](token.start)
|
||||
|
||||
if (token._contentTypeTextTrailing) {
|
||||
tokenizer._contentTypeTextTrailing = true
|
||||
}
|
||||
}
|
||||
|
||||
const childEvents = tokenizer.events
|
||||
/** @type {Array<[number, number]>} */
|
||||
const jumps = []
|
||||
/** @type {Record<string, number>} */
|
||||
const gaps = {}
|
||||
/** @type {Array<Chunk>} */
|
||||
let stream
|
||||
/** @type {Token | undefined} */
|
||||
let previous
|
||||
let index = -1
|
||||
/** @type {Token | undefined} */
|
||||
let current = token
|
||||
let adjust = 0
|
||||
let start = 0
|
||||
const breaks = [start]
|
||||
|
||||
// Loop forward through the linked tokens to pass them in order to the
|
||||
// subtokenizer.
|
||||
while (current) {
|
||||
// Find the position of the event for this token.
|
||||
while (events.get(++startPosition)[1] !== current) {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
assert(
|
||||
!previous || current.previous === previous,
|
||||
'expected previous to match'
|
||||
)
|
||||
assert(!previous || previous.next === current, 'expected next to match')
|
||||
|
||||
startPositions.push(startPosition)
|
||||
|
||||
if (!current._tokenizer) {
|
||||
stream = context.sliceStream(current)
|
||||
|
||||
if (!current.next) {
|
||||
stream.push(codes.eof)
|
||||
}
|
||||
|
||||
if (previous) {
|
||||
tokenizer.defineSkip(current.start)
|
||||
}
|
||||
|
||||
if (current._isInFirstContentOfListItem) {
|
||||
tokenizer._gfmTasklistFirstContentOfListItem = true
|
||||
}
|
||||
|
||||
tokenizer.write(stream)
|
||||
|
||||
if (current._isInFirstContentOfListItem) {
|
||||
tokenizer._gfmTasklistFirstContentOfListItem = undefined
|
||||
}
|
||||
}
|
||||
|
||||
// Unravel the next token.
|
||||
previous = current
|
||||
current = current.next
|
||||
}
|
||||
|
||||
// Now, loop back through all events (and linked tokens), to figure out which
|
||||
// parts belong where.
|
||||
current = token
|
||||
|
||||
while (++index < childEvents.length) {
|
||||
if (
|
||||
// Find a void token that includes a break.
|
||||
childEvents[index][0] === 'exit' &&
|
||||
childEvents[index - 1][0] === 'enter' &&
|
||||
childEvents[index][1].type === childEvents[index - 1][1].type &&
|
||||
childEvents[index][1].start.line !== childEvents[index][1].end.line
|
||||
) {
|
||||
assert(current, 'expected a current token')
|
||||
start = index + 1
|
||||
breaks.push(start)
|
||||
// Help GC.
|
||||
current._tokenizer = undefined
|
||||
current.previous = undefined
|
||||
current = current.next
|
||||
}
|
||||
}
|
||||
|
||||
// Help GC.
|
||||
tokenizer.events = []
|
||||
|
||||
// If there’s one more token (which is the cases for lines that end in an
|
||||
// EOF), that’s perfect: the last point we found starts it.
|
||||
// If there isn’t then make sure any remaining content is added to it.
|
||||
if (current) {
|
||||
// Help GC.
|
||||
current._tokenizer = undefined
|
||||
current.previous = undefined
|
||||
assert(!current.next, 'expected no next token')
|
||||
} else {
|
||||
breaks.pop()
|
||||
}
|
||||
|
||||
// Now splice the events from the subtokenizer into the current events,
|
||||
// moving back to front so that splice indices aren’t affected.
|
||||
index = breaks.length
|
||||
|
||||
while (index--) {
|
||||
const slice = childEvents.slice(breaks[index], breaks[index + 1])
|
||||
const start = startPositions.pop()
|
||||
assert(start !== undefined, 'expected a start position when splicing')
|
||||
jumps.push([start, start + slice.length - 1])
|
||||
events.splice(start, 2, slice)
|
||||
}
|
||||
|
||||
jumps.reverse()
|
||||
index = -1
|
||||
|
||||
while (++index < jumps.length) {
|
||||
gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]
|
||||
adjust += jumps[index][1] - jumps[index][0] - 1
|
||||
}
|
||||
|
||||
return gaps
|
||||
}
|
161
node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.d.ts
generated
vendored
Normal file
161
node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* Some of the internal operations of micromark do lots of editing
|
||||
* operations on very large arrays. This runs into problems with two
|
||||
* properties of most circa-2020 JavaScript interpreters:
|
||||
*
|
||||
* - Array-length modifications at the high end of an array (push/pop) are
|
||||
* expected to be common and are implemented in (amortized) time
|
||||
* proportional to the number of elements added or removed, whereas
|
||||
* other operations (shift/unshift and splice) are much less efficient.
|
||||
* - Function arguments are passed on the stack, so adding tens of thousands
|
||||
* of elements to an array with `arr.push(...newElements)` will frequently
|
||||
* cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)
|
||||
*
|
||||
* SpliceBuffers are an implementation of gap buffers, which are a
|
||||
* generalization of the "queue made of two stacks" idea. The splice buffer
|
||||
* maintains a cursor, and moving the cursor has cost proportional to the
|
||||
* distance the cursor moves, but inserting, deleting, or splicing in
|
||||
* new information at the cursor is as efficient as the push/pop operation.
|
||||
* This allows for an efficient sequence of splices (or pushes, pops, shifts,
|
||||
* or unshifts) as long such edits happen at the same part of the array or
|
||||
* generally sweep through the array from the beginning to the end.
|
||||
*
|
||||
* The interface for splice buffers also supports large numbers of inputs by
|
||||
* passing a single array argument rather passing multiple arguments on the
|
||||
* function call stack.
|
||||
*
|
||||
* @template T
|
||||
* Item type.
|
||||
*/
|
||||
export class SpliceBuffer<T> {
|
||||
/**
|
||||
* @param {ReadonlyArray<T> | null | undefined} [initial]
|
||||
* Initial items (optional).
|
||||
* @returns
|
||||
* Splice buffer.
|
||||
*/
|
||||
constructor(initial?: ReadonlyArray<T> | null | undefined);
|
||||
/** @type {Array<T>} */
|
||||
left: Array<T>;
|
||||
/** @type {Array<T>} */
|
||||
right: Array<T>;
|
||||
/**
|
||||
* Array access;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} index
|
||||
* Index.
|
||||
* @return {T}
|
||||
* Item.
|
||||
*/
|
||||
get(index: number): T;
|
||||
/**
|
||||
* The length of the splice buffer, one greater than the largest index in the
|
||||
* array.
|
||||
*/
|
||||
get length(): number;
|
||||
/**
|
||||
* Remove and return `list[0]`;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
shift(): T | undefined;
|
||||
/**
|
||||
* Slice the buffer to get an array;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start.
|
||||
* @param {number | null | undefined} [end]
|
||||
* End (optional).
|
||||
* @returns {Array<T>}
|
||||
* Array of items.
|
||||
*/
|
||||
slice(start: number, end?: number | null | undefined): Array<T>;
|
||||
/**
|
||||
* Mimics the behavior of Array.prototype.splice() except for the change of
|
||||
* interface necessary to avoid segfaults when patching in very large arrays.
|
||||
*
|
||||
* This operation moves cursor is moved to `start` and results in the cursor
|
||||
* placed after any inserted items.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start;
|
||||
* zero-based index at which to start changing the array;
|
||||
* negative numbers count backwards from the end of the array and values
|
||||
* that are out-of bounds are clamped to the appropriate end of the array.
|
||||
* @param {number | null | undefined} [deleteCount=0]
|
||||
* Delete count (default: `0`);
|
||||
* maximum number of elements to delete, starting from start.
|
||||
* @param {Array<T> | null | undefined} [items=[]]
|
||||
* Items to include in place of the deleted items (default: `[]`).
|
||||
* @return {Array<T>}
|
||||
* Any removed items.
|
||||
*/
|
||||
splice(start: number, deleteCount?: number | null | undefined, items?: Array<T> | null | undefined): Array<T>;
|
||||
/**
|
||||
* Remove and return the highest-numbered item in the array, so
|
||||
* `list[list.length - 1]`;
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* Inserts a single item to the high-numbered side of the array;
|
||||
* moves the cursor to `length`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
push(item: T): undefined;
|
||||
/**
|
||||
* Inserts many items to the high-numbered side of the array.
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
pushMany(items: Array<T>): undefined;
|
||||
/**
|
||||
* Inserts a single item to the low-numbered side of the array;
|
||||
* Moves the cursor to `0`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshift(item: T): undefined;
|
||||
/**
|
||||
* Inserts many items to the low-numbered side of the array;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshiftMany(items: Array<T>): undefined;
|
||||
/**
|
||||
* Move the cursor to a specific position in the array. Requires
|
||||
* time proportional to the distance moved.
|
||||
*
|
||||
* If `n < 0`, the cursor will end up at the beginning.
|
||||
* If `n > length`, the cursor will end up at the end.
|
||||
*
|
||||
* @param {number} n
|
||||
* Position.
|
||||
* @return {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
setCursor(n: number): undefined;
|
||||
}
|
||||
//# sourceMappingURL=splice-buffer.d.ts.map
|
1
node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.d.ts.map
generated
vendored
Normal file
1
node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"splice-buffer.d.ts","sourceRoot":"","sources":["splice-buffer.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,0BAHa,CAAC;IAIZ;;;;;OAKG;IACH,sBALW,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAU7C;IAJC,uBAAuB;IACvB,MADW,KAAK,CAAC,CAAC,CAAC,CACoB;IACvC,uBAAuB;IACvB,OADW,KAAK,CAAC,CAAC,CAAC,CACJ;IAGjB;;;;;;;;OAQG;IACH,WALW,MAAM,GAEL,CAAC,CAgBZ;IAED;;;OAGG;IACH,qBAEC;IAED;;;;;;OAMG;IACH,SAHa,CAAC,GAAG,SAAS,CAMzB;IAED;;;;;;;;;;OAUG;IACH,aAPW,MAAM,QAEN,MAAM,GAAG,IAAI,GAAG,SAAS,GAEvB,KAAK,CAAC,CAAC,CAAC,CA0BpB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAbW,MAAM,gBAKN,MAAM,GAAG,IAAI,GAAG,SAAS,UAGzB,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAE1B,KAAK,CAAC,CAAC,CAAC,CAcnB;IAED;;;;;;;OAOG;IACH,OAHa,CAAC,GAAG,SAAS,CAMzB;IAED;;;;;;;;OAQG;IACH,WALW,CAAC,GAEC,SAAS,CAMrB;IAED;;;;;;;;OAQG;IACH,gBALW,KAAK,CAAC,CAAC,CAAC,GAEN,SAAS,CAMrB;IAED;;;;;;;;OAQG;IACH,cALW,CAAC,GAEC,SAAS,CAMrB;IAED;;;;;;;;OAQG;IACH,mBALW,KAAK,CAAC,CAAC,CAAC,GAEN,SAAS,CAMrB;IAED;;;;;;;;;;;OAWG;IACH,aALW,MAAM,GAEL,SAAS,CAsBpB;CACF"}
|
288
node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.js
generated
vendored
Normal file
288
node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.js
generated
vendored
Normal file
@@ -0,0 +1,288 @@
|
||||
import {constants} from 'micromark-util-symbol'
|
||||
|
||||
/**
|
||||
* Some of the internal operations of micromark do lots of editing
|
||||
* operations on very large arrays. This runs into problems with two
|
||||
* properties of most circa-2020 JavaScript interpreters:
|
||||
*
|
||||
* - Array-length modifications at the high end of an array (push/pop) are
|
||||
* expected to be common and are implemented in (amortized) time
|
||||
* proportional to the number of elements added or removed, whereas
|
||||
* other operations (shift/unshift and splice) are much less efficient.
|
||||
* - Function arguments are passed on the stack, so adding tens of thousands
|
||||
* of elements to an array with `arr.push(...newElements)` will frequently
|
||||
* cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)
|
||||
*
|
||||
* SpliceBuffers are an implementation of gap buffers, which are a
|
||||
* generalization of the "queue made of two stacks" idea. The splice buffer
|
||||
* maintains a cursor, and moving the cursor has cost proportional to the
|
||||
* distance the cursor moves, but inserting, deleting, or splicing in
|
||||
* new information at the cursor is as efficient as the push/pop operation.
|
||||
* This allows for an efficient sequence of splices (or pushes, pops, shifts,
|
||||
* or unshifts) as long such edits happen at the same part of the array or
|
||||
* generally sweep through the array from the beginning to the end.
|
||||
*
|
||||
* The interface for splice buffers also supports large numbers of inputs by
|
||||
* passing a single array argument rather passing multiple arguments on the
|
||||
* function call stack.
|
||||
*
|
||||
* @template T
|
||||
* Item type.
|
||||
*/
|
||||
export class SpliceBuffer {
|
||||
/**
|
||||
* @param {ReadonlyArray<T> | null | undefined} [initial]
|
||||
* Initial items (optional).
|
||||
* @returns
|
||||
* Splice buffer.
|
||||
*/
|
||||
constructor(initial) {
|
||||
/** @type {Array<T>} */
|
||||
this.left = initial ? [...initial] : []
|
||||
/** @type {Array<T>} */
|
||||
this.right = []
|
||||
}
|
||||
|
||||
/**
|
||||
* Array access;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} index
|
||||
* Index.
|
||||
* @return {T}
|
||||
* Item.
|
||||
*/
|
||||
get(index) {
|
||||
if (index < 0 || index >= this.left.length + this.right.length) {
|
||||
throw new RangeError(
|
||||
'Cannot access index `' +
|
||||
index +
|
||||
'` in a splice buffer of size `' +
|
||||
(this.left.length + this.right.length) +
|
||||
'`'
|
||||
)
|
||||
}
|
||||
|
||||
if (index < this.left.length) return this.left[index]
|
||||
return this.right[this.right.length - index + this.left.length - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* The length of the splice buffer, one greater than the largest index in the
|
||||
* array.
|
||||
*/
|
||||
get length() {
|
||||
return this.left.length + this.right.length
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and return `list[0]`;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
shift() {
|
||||
this.setCursor(0)
|
||||
return this.right.pop()
|
||||
}
|
||||
|
||||
/**
|
||||
* Slice the buffer to get an array;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start.
|
||||
* @param {number | null | undefined} [end]
|
||||
* End (optional).
|
||||
* @returns {Array<T>}
|
||||
* Array of items.
|
||||
*/
|
||||
slice(start, end) {
|
||||
/** @type {number} */
|
||||
const stop =
|
||||
end === null || end === undefined ? Number.POSITIVE_INFINITY : end
|
||||
|
||||
if (stop < this.left.length) {
|
||||
return this.left.slice(start, stop)
|
||||
}
|
||||
|
||||
if (start > this.left.length) {
|
||||
return this.right
|
||||
.slice(
|
||||
this.right.length - stop + this.left.length,
|
||||
this.right.length - start + this.left.length
|
||||
)
|
||||
.reverse()
|
||||
}
|
||||
|
||||
return this.left
|
||||
.slice(start)
|
||||
.concat(
|
||||
this.right.slice(this.right.length - stop + this.left.length).reverse()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mimics the behavior of Array.prototype.splice() except for the change of
|
||||
* interface necessary to avoid segfaults when patching in very large arrays.
|
||||
*
|
||||
* This operation moves cursor is moved to `start` and results in the cursor
|
||||
* placed after any inserted items.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start;
|
||||
* zero-based index at which to start changing the array;
|
||||
* negative numbers count backwards from the end of the array and values
|
||||
* that are out-of bounds are clamped to the appropriate end of the array.
|
||||
* @param {number | null | undefined} [deleteCount=0]
|
||||
* Delete count (default: `0`);
|
||||
* maximum number of elements to delete, starting from start.
|
||||
* @param {Array<T> | null | undefined} [items=[]]
|
||||
* Items to include in place of the deleted items (default: `[]`).
|
||||
* @return {Array<T>}
|
||||
* Any removed items.
|
||||
*/
|
||||
splice(start, deleteCount, items) {
|
||||
/** @type {number} */
|
||||
const count = deleteCount || 0
|
||||
|
||||
this.setCursor(Math.trunc(start))
|
||||
const removed = this.right.splice(
|
||||
this.right.length - count,
|
||||
Number.POSITIVE_INFINITY
|
||||
)
|
||||
if (items) chunkedPush(this.left, items)
|
||||
return removed.reverse()
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and return the highest-numbered item in the array, so
|
||||
* `list[list.length - 1]`;
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
pop() {
|
||||
this.setCursor(Number.POSITIVE_INFINITY)
|
||||
return this.left.pop()
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a single item to the high-numbered side of the array;
|
||||
* moves the cursor to `length`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
push(item) {
|
||||
this.setCursor(Number.POSITIVE_INFINITY)
|
||||
this.left.push(item)
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts many items to the high-numbered side of the array.
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
pushMany(items) {
|
||||
this.setCursor(Number.POSITIVE_INFINITY)
|
||||
chunkedPush(this.left, items)
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a single item to the low-numbered side of the array;
|
||||
* Moves the cursor to `0`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshift(item) {
|
||||
this.setCursor(0)
|
||||
this.right.push(item)
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts many items to the low-numbered side of the array;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshiftMany(items) {
|
||||
this.setCursor(0)
|
||||
chunkedPush(this.right, items.reverse())
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to a specific position in the array. Requires
|
||||
* time proportional to the distance moved.
|
||||
*
|
||||
* If `n < 0`, the cursor will end up at the beginning.
|
||||
* If `n > length`, the cursor will end up at the end.
|
||||
*
|
||||
* @param {number} n
|
||||
* Position.
|
||||
* @return {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
setCursor(n) {
|
||||
if (
|
||||
n === this.left.length ||
|
||||
(n > this.left.length && this.right.length === 0) ||
|
||||
(n < 0 && this.left.length === 0)
|
||||
)
|
||||
return
|
||||
if (n < this.left.length) {
|
||||
// Move cursor to the this.left
|
||||
const removed = this.left.splice(n, Number.POSITIVE_INFINITY)
|
||||
chunkedPush(this.right, removed.reverse())
|
||||
} else {
|
||||
// Move cursor to the this.right
|
||||
const removed = this.right.splice(
|
||||
this.left.length + this.right.length - n,
|
||||
Number.POSITIVE_INFINITY
|
||||
)
|
||||
chunkedPush(this.left, removed.reverse())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Avoid stack overflow by pushing items onto the stack in segments
|
||||
*
|
||||
* @template T
|
||||
* Item type.
|
||||
* @param {Array<T>} list
|
||||
* List to inject into.
|
||||
* @param {ReadonlyArray<T>} right
|
||||
* Items to inject.
|
||||
* @return {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
function chunkedPush(list, right) {
|
||||
/** @type {number} */
|
||||
let chunkStart = 0
|
||||
|
||||
if (right.length < constants.v8MaxSafeChunkSize) {
|
||||
list.push(...right)
|
||||
} else {
|
||||
while (chunkStart < right.length) {
|
||||
list.push(
|
||||
...right.slice(chunkStart, chunkStart + constants.v8MaxSafeChunkSize)
|
||||
)
|
||||
chunkStart += constants.v8MaxSafeChunkSize
|
||||
}
|
||||
}
|
||||
}
|
12
node_modules/micromark-util-subtokenize/index.d.ts
generated
vendored
Normal file
12
node_modules/micromark-util-subtokenize/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Tokenize subcontent.
|
||||
*
|
||||
* @param {Array<Event>} eventsArray
|
||||
* List of events.
|
||||
* @returns {boolean}
|
||||
* Whether subtokens were found.
|
||||
*/
|
||||
export function subtokenize(eventsArray: Array<Event>): boolean;
|
||||
export { SpliceBuffer } from "./lib/splice-buffer.js";
|
||||
import type { Event } from 'micromark-util-types';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/micromark-util-subtokenize/index.d.ts.map
generated
vendored
Normal file
1
node_modules/micromark-util-subtokenize/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AAEH,yCANW,KAAK,CAAC,KAAK,CAAC,GAEV,OAAO,CAuHnB;;2BAvIqC,sBAAsB"}
|
228
node_modules/micromark-util-subtokenize/index.js
generated
vendored
Normal file
228
node_modules/micromark-util-subtokenize/index.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
/**
|
||||
* @import {Chunk, Event, Token} from 'micromark-util-types'
|
||||
*/
|
||||
|
||||
import { splice } from 'micromark-util-chunked';
|
||||
import { SpliceBuffer } from './lib/splice-buffer.js';
|
||||
|
||||
// Hidden API exposed for testing.
|
||||
export { SpliceBuffer } from './lib/splice-buffer.js';
|
||||
|
||||
/**
|
||||
* Tokenize subcontent.
|
||||
*
|
||||
* @param {Array<Event>} eventsArray
|
||||
* List of events.
|
||||
* @returns {boolean}
|
||||
* Whether subtokens were found.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export function subtokenize(eventsArray) {
|
||||
/** @type {Record<string, number>} */
|
||||
const jumps = {};
|
||||
let index = -1;
|
||||
/** @type {Event} */
|
||||
let event;
|
||||
/** @type {number | undefined} */
|
||||
let lineIndex;
|
||||
/** @type {number} */
|
||||
let otherIndex;
|
||||
/** @type {Event} */
|
||||
let otherEvent;
|
||||
/** @type {Array<Event>} */
|
||||
let parameters;
|
||||
/** @type {Array<Event>} */
|
||||
let subevents;
|
||||
/** @type {boolean | undefined} */
|
||||
let more;
|
||||
const events = new SpliceBuffer(eventsArray);
|
||||
while (++index < events.length) {
|
||||
while (index in jumps) {
|
||||
index = jumps[index];
|
||||
}
|
||||
event = events.get(index);
|
||||
|
||||
// Add a hook for the GFM tasklist extension, which needs to know if text
|
||||
// is in the first content of a list item.
|
||||
if (index && event[1].type === "chunkFlow" && events.get(index - 1)[1].type === "listItemPrefix") {
|
||||
subevents = event[1]._tokenizer.events;
|
||||
otherIndex = 0;
|
||||
if (otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank") {
|
||||
otherIndex += 2;
|
||||
}
|
||||
if (otherIndex < subevents.length && subevents[otherIndex][1].type === "content") {
|
||||
while (++otherIndex < subevents.length) {
|
||||
if (subevents[otherIndex][1].type === "content") {
|
||||
break;
|
||||
}
|
||||
if (subevents[otherIndex][1].type === "chunkText") {
|
||||
subevents[otherIndex][1]._isInFirstContentOfListItem = true;
|
||||
otherIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enter.
|
||||
if (event[0] === 'enter') {
|
||||
if (event[1].contentType) {
|
||||
Object.assign(jumps, subcontent(events, index));
|
||||
index = jumps[index];
|
||||
more = true;
|
||||
}
|
||||
}
|
||||
// Exit.
|
||||
else if (event[1]._container) {
|
||||
otherIndex = index;
|
||||
lineIndex = undefined;
|
||||
while (otherIndex--) {
|
||||
otherEvent = events.get(otherIndex);
|
||||
if (otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank") {
|
||||
if (otherEvent[0] === 'enter') {
|
||||
if (lineIndex) {
|
||||
events.get(lineIndex)[1].type = "lineEndingBlank";
|
||||
}
|
||||
otherEvent[1].type = "lineEnding";
|
||||
lineIndex = otherIndex;
|
||||
}
|
||||
} else if (otherEvent[1].type === "linePrefix" || otherEvent[1].type === "listItemIndent") {
|
||||
// Move past.
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lineIndex) {
|
||||
// Fix position.
|
||||
event[1].end = {
|
||||
...events.get(lineIndex)[1].start
|
||||
};
|
||||
|
||||
// Switch container exit w/ line endings.
|
||||
parameters = events.slice(lineIndex, index);
|
||||
parameters.unshift(event);
|
||||
events.splice(lineIndex, index - lineIndex + 1, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The changes to the `events` buffer must be copied back into the eventsArray
|
||||
splice(eventsArray, 0, Number.POSITIVE_INFINITY, events.slice(0));
|
||||
return !more;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize embedded tokens.
|
||||
*
|
||||
* @param {SpliceBuffer<Event>} events
|
||||
* Events.
|
||||
* @param {number} eventIndex
|
||||
* Index.
|
||||
* @returns {Record<string, number>}
|
||||
* Gaps.
|
||||
*/
|
||||
function subcontent(events, eventIndex) {
|
||||
const token = events.get(eventIndex)[1];
|
||||
const context = events.get(eventIndex)[2];
|
||||
let startPosition = eventIndex - 1;
|
||||
/** @type {Array<number>} */
|
||||
const startPositions = [];
|
||||
let tokenizer = token._tokenizer;
|
||||
if (!tokenizer) {
|
||||
tokenizer = context.parser[token.contentType](token.start);
|
||||
if (token._contentTypeTextTrailing) {
|
||||
tokenizer._contentTypeTextTrailing = true;
|
||||
}
|
||||
}
|
||||
const childEvents = tokenizer.events;
|
||||
/** @type {Array<[number, number]>} */
|
||||
const jumps = [];
|
||||
/** @type {Record<string, number>} */
|
||||
const gaps = {};
|
||||
/** @type {Array<Chunk>} */
|
||||
let stream;
|
||||
/** @type {Token | undefined} */
|
||||
let previous;
|
||||
let index = -1;
|
||||
/** @type {Token | undefined} */
|
||||
let current = token;
|
||||
let adjust = 0;
|
||||
let start = 0;
|
||||
const breaks = [start];
|
||||
|
||||
// Loop forward through the linked tokens to pass them in order to the
|
||||
// subtokenizer.
|
||||
while (current) {
|
||||
// Find the position of the event for this token.
|
||||
while (events.get(++startPosition)[1] !== current) {
|
||||
// Empty.
|
||||
}
|
||||
startPositions.push(startPosition);
|
||||
if (!current._tokenizer) {
|
||||
stream = context.sliceStream(current);
|
||||
if (!current.next) {
|
||||
stream.push(null);
|
||||
}
|
||||
if (previous) {
|
||||
tokenizer.defineSkip(current.start);
|
||||
}
|
||||
if (current._isInFirstContentOfListItem) {
|
||||
tokenizer._gfmTasklistFirstContentOfListItem = true;
|
||||
}
|
||||
tokenizer.write(stream);
|
||||
if (current._isInFirstContentOfListItem) {
|
||||
tokenizer._gfmTasklistFirstContentOfListItem = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Unravel the next token.
|
||||
previous = current;
|
||||
current = current.next;
|
||||
}
|
||||
|
||||
// Now, loop back through all events (and linked tokens), to figure out which
|
||||
// parts belong where.
|
||||
current = token;
|
||||
while (++index < childEvents.length) {
|
||||
if (
|
||||
// Find a void token that includes a break.
|
||||
childEvents[index][0] === 'exit' && childEvents[index - 1][0] === 'enter' && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) {
|
||||
start = index + 1;
|
||||
breaks.push(start);
|
||||
// Help GC.
|
||||
current._tokenizer = undefined;
|
||||
current.previous = undefined;
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
|
||||
// Help GC.
|
||||
tokenizer.events = [];
|
||||
|
||||
// If there’s one more token (which is the cases for lines that end in an
|
||||
// EOF), that’s perfect: the last point we found starts it.
|
||||
// If there isn’t then make sure any remaining content is added to it.
|
||||
if (current) {
|
||||
// Help GC.
|
||||
current._tokenizer = undefined;
|
||||
current.previous = undefined;
|
||||
} else {
|
||||
breaks.pop();
|
||||
}
|
||||
|
||||
// Now splice the events from the subtokenizer into the current events,
|
||||
// moving back to front so that splice indices aren’t affected.
|
||||
index = breaks.length;
|
||||
while (index--) {
|
||||
const slice = childEvents.slice(breaks[index], breaks[index + 1]);
|
||||
const start = startPositions.pop();
|
||||
jumps.push([start, start + slice.length - 1]);
|
||||
events.splice(start, 2, slice);
|
||||
}
|
||||
jumps.reverse();
|
||||
index = -1;
|
||||
while (++index < jumps.length) {
|
||||
gaps[adjust + jumps[index][0]] = adjust + jumps[index][1];
|
||||
adjust += jumps[index][1] - jumps[index][0] - 1;
|
||||
}
|
||||
return gaps;
|
||||
}
|
161
node_modules/micromark-util-subtokenize/lib/splice-buffer.d.ts
generated
vendored
Normal file
161
node_modules/micromark-util-subtokenize/lib/splice-buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* Some of the internal operations of micromark do lots of editing
|
||||
* operations on very large arrays. This runs into problems with two
|
||||
* properties of most circa-2020 JavaScript interpreters:
|
||||
*
|
||||
* - Array-length modifications at the high end of an array (push/pop) are
|
||||
* expected to be common and are implemented in (amortized) time
|
||||
* proportional to the number of elements added or removed, whereas
|
||||
* other operations (shift/unshift and splice) are much less efficient.
|
||||
* - Function arguments are passed on the stack, so adding tens of thousands
|
||||
* of elements to an array with `arr.push(...newElements)` will frequently
|
||||
* cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)
|
||||
*
|
||||
* SpliceBuffers are an implementation of gap buffers, which are a
|
||||
* generalization of the "queue made of two stacks" idea. The splice buffer
|
||||
* maintains a cursor, and moving the cursor has cost proportional to the
|
||||
* distance the cursor moves, but inserting, deleting, or splicing in
|
||||
* new information at the cursor is as efficient as the push/pop operation.
|
||||
* This allows for an efficient sequence of splices (or pushes, pops, shifts,
|
||||
* or unshifts) as long such edits happen at the same part of the array or
|
||||
* generally sweep through the array from the beginning to the end.
|
||||
*
|
||||
* The interface for splice buffers also supports large numbers of inputs by
|
||||
* passing a single array argument rather passing multiple arguments on the
|
||||
* function call stack.
|
||||
*
|
||||
* @template T
|
||||
* Item type.
|
||||
*/
|
||||
export class SpliceBuffer<T> {
|
||||
/**
|
||||
* @param {ReadonlyArray<T> | null | undefined} [initial]
|
||||
* Initial items (optional).
|
||||
* @returns
|
||||
* Splice buffer.
|
||||
*/
|
||||
constructor(initial?: ReadonlyArray<T> | null | undefined);
|
||||
/** @type {Array<T>} */
|
||||
left: Array<T>;
|
||||
/** @type {Array<T>} */
|
||||
right: Array<T>;
|
||||
/**
|
||||
* Array access;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} index
|
||||
* Index.
|
||||
* @return {T}
|
||||
* Item.
|
||||
*/
|
||||
get(index: number): T;
|
||||
/**
|
||||
* The length of the splice buffer, one greater than the largest index in the
|
||||
* array.
|
||||
*/
|
||||
get length(): number;
|
||||
/**
|
||||
* Remove and return `list[0]`;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
shift(): T | undefined;
|
||||
/**
|
||||
* Slice the buffer to get an array;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start.
|
||||
* @param {number | null | undefined} [end]
|
||||
* End (optional).
|
||||
* @returns {Array<T>}
|
||||
* Array of items.
|
||||
*/
|
||||
slice(start: number, end?: number | null | undefined): Array<T>;
|
||||
/**
|
||||
* Mimics the behavior of Array.prototype.splice() except for the change of
|
||||
* interface necessary to avoid segfaults when patching in very large arrays.
|
||||
*
|
||||
* This operation moves cursor is moved to `start` and results in the cursor
|
||||
* placed after any inserted items.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start;
|
||||
* zero-based index at which to start changing the array;
|
||||
* negative numbers count backwards from the end of the array and values
|
||||
* that are out-of bounds are clamped to the appropriate end of the array.
|
||||
* @param {number | null | undefined} [deleteCount=0]
|
||||
* Delete count (default: `0`);
|
||||
* maximum number of elements to delete, starting from start.
|
||||
* @param {Array<T> | null | undefined} [items=[]]
|
||||
* Items to include in place of the deleted items (default: `[]`).
|
||||
* @return {Array<T>}
|
||||
* Any removed items.
|
||||
*/
|
||||
splice(start: number, deleteCount?: number | null | undefined, items?: Array<T> | null | undefined): Array<T>;
|
||||
/**
|
||||
* Remove and return the highest-numbered item in the array, so
|
||||
* `list[list.length - 1]`;
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
/**
|
||||
* Inserts a single item to the high-numbered side of the array;
|
||||
* moves the cursor to `length`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
push(item: T): undefined;
|
||||
/**
|
||||
* Inserts many items to the high-numbered side of the array.
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
pushMany(items: Array<T>): undefined;
|
||||
/**
|
||||
* Inserts a single item to the low-numbered side of the array;
|
||||
* Moves the cursor to `0`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshift(item: T): undefined;
|
||||
/**
|
||||
* Inserts many items to the low-numbered side of the array;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshiftMany(items: Array<T>): undefined;
|
||||
/**
|
||||
* Move the cursor to a specific position in the array. Requires
|
||||
* time proportional to the distance moved.
|
||||
*
|
||||
* If `n < 0`, the cursor will end up at the beginning.
|
||||
* If `n > length`, the cursor will end up at the end.
|
||||
*
|
||||
* @param {number} n
|
||||
* Position.
|
||||
* @return {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
setCursor(n: number): undefined;
|
||||
}
|
||||
//# sourceMappingURL=splice-buffer.d.ts.map
|
1
node_modules/micromark-util-subtokenize/lib/splice-buffer.d.ts.map
generated
vendored
Normal file
1
node_modules/micromark-util-subtokenize/lib/splice-buffer.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"splice-buffer.d.ts","sourceRoot":"","sources":["splice-buffer.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,0BAHa,CAAC;IAIZ;;;;;OAKG;IACH,sBALW,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAU7C;IAJC,uBAAuB;IACvB,MADW,KAAK,CAAC,CAAC,CAAC,CACoB;IACvC,uBAAuB;IACvB,OADW,KAAK,CAAC,CAAC,CAAC,CACJ;IAGjB;;;;;;;;OAQG;IACH,WALW,MAAM,GAEL,CAAC,CAgBZ;IAED;;;OAGG;IACH,qBAEC;IAED;;;;;;OAMG;IACH,SAHa,CAAC,GAAG,SAAS,CAMzB;IAED;;;;;;;;;;OAUG;IACH,aAPW,MAAM,QAEN,MAAM,GAAG,IAAI,GAAG,SAAS,GAEvB,KAAK,CAAC,CAAC,CAAC,CA0BpB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAbW,MAAM,gBAKN,MAAM,GAAG,IAAI,GAAG,SAAS,UAGzB,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAE1B,KAAK,CAAC,CAAC,CAAC,CAcnB;IAED;;;;;;;OAOG;IACH,OAHa,CAAC,GAAG,SAAS,CAMzB;IAED;;;;;;;;OAQG;IACH,WALW,CAAC,GAEC,SAAS,CAMrB;IAED;;;;;;;;OAQG;IACH,gBALW,KAAK,CAAC,CAAC,CAAC,GAEN,SAAS,CAMrB;IAED;;;;;;;;OAQG;IACH,cALW,CAAC,GAEC,SAAS,CAMrB;IAED;;;;;;;;OAQG;IACH,mBALW,KAAK,CAAC,CAAC,CAAC,GAEN,SAAS,CAMrB;IAED;;;;;;;;;;;OAWG;IACH,aALW,MAAM,GAEL,SAAS,CAsBpB;CACF"}
|
251
node_modules/micromark-util-subtokenize/lib/splice-buffer.js
generated
vendored
Normal file
251
node_modules/micromark-util-subtokenize/lib/splice-buffer.js
generated
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
/**
|
||||
* Some of the internal operations of micromark do lots of editing
|
||||
* operations on very large arrays. This runs into problems with two
|
||||
* properties of most circa-2020 JavaScript interpreters:
|
||||
*
|
||||
* - Array-length modifications at the high end of an array (push/pop) are
|
||||
* expected to be common and are implemented in (amortized) time
|
||||
* proportional to the number of elements added or removed, whereas
|
||||
* other operations (shift/unshift and splice) are much less efficient.
|
||||
* - Function arguments are passed on the stack, so adding tens of thousands
|
||||
* of elements to an array with `arr.push(...newElements)` will frequently
|
||||
* cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)
|
||||
*
|
||||
* SpliceBuffers are an implementation of gap buffers, which are a
|
||||
* generalization of the "queue made of two stacks" idea. The splice buffer
|
||||
* maintains a cursor, and moving the cursor has cost proportional to the
|
||||
* distance the cursor moves, but inserting, deleting, or splicing in
|
||||
* new information at the cursor is as efficient as the push/pop operation.
|
||||
* This allows for an efficient sequence of splices (or pushes, pops, shifts,
|
||||
* or unshifts) as long such edits happen at the same part of the array or
|
||||
* generally sweep through the array from the beginning to the end.
|
||||
*
|
||||
* The interface for splice buffers also supports large numbers of inputs by
|
||||
* passing a single array argument rather passing multiple arguments on the
|
||||
* function call stack.
|
||||
*
|
||||
* @template T
|
||||
* Item type.
|
||||
*/
|
||||
export class SpliceBuffer {
|
||||
/**
|
||||
* @param {ReadonlyArray<T> | null | undefined} [initial]
|
||||
* Initial items (optional).
|
||||
* @returns
|
||||
* Splice buffer.
|
||||
*/
|
||||
constructor(initial) {
|
||||
/** @type {Array<T>} */
|
||||
this.left = initial ? [...initial] : [];
|
||||
/** @type {Array<T>} */
|
||||
this.right = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Array access;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} index
|
||||
* Index.
|
||||
* @return {T}
|
||||
* Item.
|
||||
*/
|
||||
get(index) {
|
||||
if (index < 0 || index >= this.left.length + this.right.length) {
|
||||
throw new RangeError('Cannot access index `' + index + '` in a splice buffer of size `' + (this.left.length + this.right.length) + '`');
|
||||
}
|
||||
if (index < this.left.length) return this.left[index];
|
||||
return this.right[this.right.length - index + this.left.length - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* The length of the splice buffer, one greater than the largest index in the
|
||||
* array.
|
||||
*/
|
||||
get length() {
|
||||
return this.left.length + this.right.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and return `list[0]`;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
shift() {
|
||||
this.setCursor(0);
|
||||
return this.right.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Slice the buffer to get an array;
|
||||
* does not move the cursor.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start.
|
||||
* @param {number | null | undefined} [end]
|
||||
* End (optional).
|
||||
* @returns {Array<T>}
|
||||
* Array of items.
|
||||
*/
|
||||
slice(start, end) {
|
||||
/** @type {number} */
|
||||
const stop = end === null || end === undefined ? Number.POSITIVE_INFINITY : end;
|
||||
if (stop < this.left.length) {
|
||||
return this.left.slice(start, stop);
|
||||
}
|
||||
if (start > this.left.length) {
|
||||
return this.right.slice(this.right.length - stop + this.left.length, this.right.length - start + this.left.length).reverse();
|
||||
}
|
||||
return this.left.slice(start).concat(this.right.slice(this.right.length - stop + this.left.length).reverse());
|
||||
}
|
||||
|
||||
/**
|
||||
* Mimics the behavior of Array.prototype.splice() except for the change of
|
||||
* interface necessary to avoid segfaults when patching in very large arrays.
|
||||
*
|
||||
* This operation moves cursor is moved to `start` and results in the cursor
|
||||
* placed after any inserted items.
|
||||
*
|
||||
* @param {number} start
|
||||
* Start;
|
||||
* zero-based index at which to start changing the array;
|
||||
* negative numbers count backwards from the end of the array and values
|
||||
* that are out-of bounds are clamped to the appropriate end of the array.
|
||||
* @param {number | null | undefined} [deleteCount=0]
|
||||
* Delete count (default: `0`);
|
||||
* maximum number of elements to delete, starting from start.
|
||||
* @param {Array<T> | null | undefined} [items=[]]
|
||||
* Items to include in place of the deleted items (default: `[]`).
|
||||
* @return {Array<T>}
|
||||
* Any removed items.
|
||||
*/
|
||||
splice(start, deleteCount, items) {
|
||||
/** @type {number} */
|
||||
const count = deleteCount || 0;
|
||||
this.setCursor(Math.trunc(start));
|
||||
const removed = this.right.splice(this.right.length - count, Number.POSITIVE_INFINITY);
|
||||
if (items) chunkedPush(this.left, items);
|
||||
return removed.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and return the highest-numbered item in the array, so
|
||||
* `list[list.length - 1]`;
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @returns {T | undefined}
|
||||
* Item, optional.
|
||||
*/
|
||||
pop() {
|
||||
this.setCursor(Number.POSITIVE_INFINITY);
|
||||
return this.left.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a single item to the high-numbered side of the array;
|
||||
* moves the cursor to `length`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
push(item) {
|
||||
this.setCursor(Number.POSITIVE_INFINITY);
|
||||
this.left.push(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts many items to the high-numbered side of the array.
|
||||
* Moves the cursor to `length`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
pushMany(items) {
|
||||
this.setCursor(Number.POSITIVE_INFINITY);
|
||||
chunkedPush(this.left, items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a single item to the low-numbered side of the array;
|
||||
* Moves the cursor to `0`.
|
||||
*
|
||||
* @param {T} item
|
||||
* Item.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshift(item) {
|
||||
this.setCursor(0);
|
||||
this.right.push(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts many items to the low-numbered side of the array;
|
||||
* moves the cursor to `0`.
|
||||
*
|
||||
* @param {Array<T>} items
|
||||
* Items.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
unshiftMany(items) {
|
||||
this.setCursor(0);
|
||||
chunkedPush(this.right, items.reverse());
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to a specific position in the array. Requires
|
||||
* time proportional to the distance moved.
|
||||
*
|
||||
* If `n < 0`, the cursor will end up at the beginning.
|
||||
* If `n > length`, the cursor will end up at the end.
|
||||
*
|
||||
* @param {number} n
|
||||
* Position.
|
||||
* @return {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
setCursor(n) {
|
||||
if (n === this.left.length || n > this.left.length && this.right.length === 0 || n < 0 && this.left.length === 0) return;
|
||||
if (n < this.left.length) {
|
||||
// Move cursor to the this.left
|
||||
const removed = this.left.splice(n, Number.POSITIVE_INFINITY);
|
||||
chunkedPush(this.right, removed.reverse());
|
||||
} else {
|
||||
// Move cursor to the this.right
|
||||
const removed = this.right.splice(this.left.length + this.right.length - n, Number.POSITIVE_INFINITY);
|
||||
chunkedPush(this.left, removed.reverse());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Avoid stack overflow by pushing items onto the stack in segments
|
||||
*
|
||||
* @template T
|
||||
* Item type.
|
||||
* @param {Array<T>} list
|
||||
* List to inject into.
|
||||
* @param {ReadonlyArray<T>} right
|
||||
* Items to inject.
|
||||
* @return {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
function chunkedPush(list, right) {
|
||||
/** @type {number} */
|
||||
let chunkStart = 0;
|
||||
if (right.length < 10000) {
|
||||
list.push(...right);
|
||||
} else {
|
||||
while (chunkStart < right.length) {
|
||||
list.push(...right.slice(chunkStart, chunkStart + 10000));
|
||||
chunkStart += 10000;
|
||||
}
|
||||
}
|
||||
}
|
22
node_modules/micromark-util-subtokenize/license
generated
vendored
Normal file
22
node_modules/micromark-util-subtokenize/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
60
node_modules/micromark-util-subtokenize/package.json
generated
vendored
Normal file
60
node_modules/micromark-util-subtokenize/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "micromark-util-subtokenize",
|
||||
"version": "2.1.0",
|
||||
"description": "micromark utility to tokenize subtokens",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"micromark",
|
||||
"util",
|
||||
"utility",
|
||||
"tokenize"
|
||||
],
|
||||
"repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-util-subtokenize",
|
||||
"bugs": "https://github.com/micromark/micromark/issues",
|
||||
"funding": [
|
||||
{
|
||||
"type": "GitHub Sponsors",
|
||||
"url": "https://github.com/sponsors/unifiedjs"
|
||||
},
|
||||
{
|
||||
"type": "OpenCollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
],
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dev/",
|
||||
"lib/",
|
||||
"index.d.ts.map",
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"exports": {
|
||||
"development": "./dev/index.js",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"devlop": "^1.0.0",
|
||||
"micromark-util-chunked": "^2.0.0",
|
||||
"micromark-util-symbol": "^2.0.0",
|
||||
"micromark-util-types": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "micromark-build"
|
||||
},
|
||||
"xo": {
|
||||
"envs": [
|
||||
"shared-node-browser"
|
||||
],
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"max-depth": "off",
|
||||
"unicorn/prefer-code-point": "off"
|
||||
}
|
||||
}
|
||||
}
|
181
node_modules/micromark-util-subtokenize/readme.md
generated
vendored
Normal file
181
node_modules/micromark-util-subtokenize/readme.md
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
# micromark-util-subtokenize
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][bundle-size-badge]][bundle-size]
|
||||
[![Sponsors][sponsors-badge]][opencollective]
|
||||
[![Backers][backers-badge]][opencollective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[micromark][] utility to tokenize subtokens.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`subtokenize(events)`](#subtokenizeevents)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Security](#security)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package exposes a micromark internal that you probably don’t need.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
This package might be useful when you are making your own micromark extensions.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install micromark-util-subtokenize
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {subtokenize} from 'https://esm.sh/micromark-util-subtokenize@1'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {subtokenize} from 'https://esm.sh/micromark-util-subtokenize@1?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
import {subtokenize} from 'micromark-util-subtokenize'
|
||||
|
||||
/**
|
||||
* Content is transparent: it’s parsed right now. That way, definitions are also
|
||||
* parsed right now: before text in paragraphs (specifically, media) are parsed.
|
||||
*
|
||||
* @type {Resolver}
|
||||
*/
|
||||
function resolveContent(events) {
|
||||
subtokenize(events)
|
||||
return events
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This module exports the identifiers [`subtokenize`][api-subtokenize].
|
||||
There is no default export.
|
||||
|
||||
### `subtokenize(events)`
|
||||
|
||||
Tokenize subcontent.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `events` (`Array<Event>`)
|
||||
— list of events
|
||||
|
||||
###### Returns
|
||||
|
||||
Whether subtokens were found (`boolean`).
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
It exports no additional types.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
|
||||
When we cut a new major release, we drop support for unmaintained versions of
|
||||
Node.
|
||||
This means we try to keep the current release line,
|
||||
`micromark-util-subtokenize@2`, compatible with Node.js 16.
|
||||
This package works with `micromark@3`.
|
||||
|
||||
## Security
|
||||
|
||||
This package is safe.
|
||||
See [`security.md`][securitymd] in [`micromark/.github`][health] for how to
|
||||
submit a security report.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`micromark/.github`][health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[api-subtokenize]: #subtokenizeevents
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[build]: https://github.com/micromark/micromark/actions
|
||||
|
||||
[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg
|
||||
|
||||
[bundle-size]: https://bundlejs.com/?q=micromark-util-subtokenize
|
||||
|
||||
[bundle-size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-util-subtokenize
|
||||
|
||||
[chat]: https://github.com/micromark/micromark/discussions
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[contributing]: https://github.com/micromark/.github/blob/main/contributing.md
|
||||
|
||||
[coverage]: https://codecov.io/github/micromark/micromark
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/micromark-util-subtokenize
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-subtokenize.svg
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[health]: https://github.com/micromark/.github
|
||||
|
||||
[license]: https://github.com/micromark/micromark/blob/main/license
|
||||
|
||||
[micromark]: https://github.com/micromark/micromark
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[opencollective]: https://opencollective.com/unified
|
||||
|
||||
[securitymd]: https://github.com/micromark/.github/blob/main/security.md
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[support]: https://github.com/micromark/.github/blob/main/support.md
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
Reference in New Issue
Block a user