mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Yarn 4 Migration (#32253)
Migrates the Overleaf monorepo package manager from npm (v11) to Yarn 4 (v4.9.1) using node-modules linker mode. GitOrigin-RevId: 50d32ab01955c15e29679eff9e9e9cfb897fab2d
This commit is contained in:
committed by
Copybot
parent
ed0fb0110a
commit
0d64a88a46
831
.yarn/patches/@codemirror-autocomplete-npm-6.18.4.patch
Normal file
831
.yarn/patches/@codemirror-autocomplete-npm-6.18.4.patch
Normal file
@@ -0,0 +1,831 @@
|
||||
diff --git a/dist/index.cjs b/dist/index.cjs
|
||||
index 39215ae..b44cb76 100644
|
||||
--- a/dist/index.cjs
|
||||
+++ b/dist/index.cjs
|
||||
@@ -187,16 +187,23 @@ Helper function that returns a transaction spec which inserts a
|
||||
completion's text in the main selection range, and any other
|
||||
selection range that has the same text in front of it.
|
||||
*/
|
||||
-function insertCompletionText(state$1, text, from, to) {
|
||||
+function insertCompletionText(state$1, text, from, to, extend) {
|
||||
let { main } = state$1.selection, fromOff = from - main.from, toOff = to - main.from;
|
||||
return Object.assign(Object.assign({}, state$1.changeByRange(range => {
|
||||
if (range != main && from != to &&
|
||||
state$1.sliceDoc(range.from + fromOff, range.from + toOff) != state$1.sliceDoc(from, to))
|
||||
return { range };
|
||||
- let lines = state$1.toText(text);
|
||||
+ let change = {
|
||||
+ from: range.from + fromOff,
|
||||
+ to: to == main.from ? range.to : range.from + toOff,
|
||||
+ insert: text instanceof state.Text ? text : state$1.toText(text),
|
||||
+ };
|
||||
+ if (extend) {
|
||||
+ extend(state$1, change);
|
||||
+ }
|
||||
return {
|
||||
- changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines },
|
||||
- range: state.EditorSelection.cursor(range.from + fromOff + lines.length)
|
||||
+ changes: change,
|
||||
+ range: state.EditorSelection.cursor(change.from + change.insert.length)
|
||||
};
|
||||
})), { scrollIntoView: true, userEvent: "input.complete" });
|
||||
}
|
||||
@@ -389,7 +396,9 @@ const completionConfig = state.Facet.define({
|
||||
filterStrict: false,
|
||||
compareCompletions: (a, b) => a.label.localeCompare(b.label),
|
||||
interactionDelay: 75,
|
||||
- updateSyncTime: 100
|
||||
+ updateSyncTime: 100,
|
||||
+ // overleaf: default to at top which is default CM6 behaviour
|
||||
+ unfilteredResultsAtEnd: false
|
||||
}, {
|
||||
defaultKeymap: (a, b) => a && b,
|
||||
closeOnBlur: (a, b) => a && b,
|
||||
@@ -744,6 +753,7 @@ function score(option) {
|
||||
(option.type ? 1 : 0);
|
||||
}
|
||||
function sortOptions(active, state) {
|
||||
+ var _a;
|
||||
let options = [];
|
||||
let sections = null;
|
||||
let addOption = (option) => {
|
||||
@@ -763,7 +773,8 @@ function sortOptions(active, state) {
|
||||
let getMatch = a.result.getMatch;
|
||||
if (a.result.filter === false) {
|
||||
for (let option of a.result.options) {
|
||||
- addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length));
|
||||
+ let defaultScore = conf.unfilteredResultsAtEnd ? -1e9 : 1e9;
|
||||
+ addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], defaultScore - options.length));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -790,15 +801,42 @@ function sortOptions(active, state) {
|
||||
}
|
||||
}
|
||||
let result = [], prev = null;
|
||||
+ const priorityIndices = new Map();
|
||||
let compare = conf.compareCompletions;
|
||||
for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
|
||||
+ // overleaf: Deduplicate results with dedup options
|
||||
+ // The goal is to keep only the highest priority option, in the
|
||||
+ // highest scoring position.
|
||||
+ const key = (_a = opt.completion.deduplicate) === null || _a === void 0 ? void 0 : _a.key;
|
||||
+ if (key) {
|
||||
+ // Handle merging specifically for deduplicated items item
|
||||
+ const currentOptionIndex = priorityIndices.get(key);
|
||||
+ if (currentOptionIndex === undefined) {
|
||||
+ priorityIndices.set(key, result.length);
|
||||
+ result.push(opt);
|
||||
+ prev = opt.completion;
|
||||
+ }
|
||||
+ else {
|
||||
+ if (result[currentOptionIndex].completion.deduplicate.priority < opt.completion.deduplicate.priority) {
|
||||
+ result[currentOptionIndex] = opt;
|
||||
+ if (currentOptionIndex === result.length - 1) {
|
||||
+ prev = opt.completion;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ // overleaf: end
|
||||
let cur = opt.completion;
|
||||
- if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
|
||||
- (prev.type != null && cur.type != null && prev.type != cur.type) ||
|
||||
- prev.apply != cur.apply || prev.boost != cur.boost)
|
||||
+ if (!prev || prev.label != cur.label)
|
||||
+ result.push(opt);
|
||||
+ // overleaf: we're already handling deduplication, so skip extra merges
|
||||
+ else if (prev.deduplicate)
|
||||
result.push(opt);
|
||||
else if (score(opt.completion) > score(prev))
|
||||
result[result.length - 1] = opt;
|
||||
+ else if (opt.completion.info)
|
||||
+ result[result.length - 1] = opt;
|
||||
prev = opt.completion;
|
||||
}
|
||||
return result;
|
||||
@@ -817,8 +855,9 @@ class CompletionDialog {
|
||||
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
||||
}
|
||||
static build(active, state, id, prev, conf, didSetActive) {
|
||||
- if (prev && !didSetActive && active.some(s => s.isPending))
|
||||
- return prev.setDisabled();
|
||||
+ // Overleaf: avoid setting the previous completion state to disabled while completion sources are pending
|
||||
+ // if (prev && !didSetActive && active.some(s => s.isPending))
|
||||
+ // return prev.setDisabled()
|
||||
let options = sortOptions(active, state);
|
||||
if (!options.length)
|
||||
return prev && active.some(a => a.isPending) ? prev.setDisabled() : null;
|
||||
@@ -1017,13 +1056,14 @@ const completionState = state.StateField.define({
|
||||
view.EditorView.contentAttributes.from(f, state => state.attrs)
|
||||
]
|
||||
});
|
||||
+const getCompletionTooltip = (state) => { var _a; return (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.tooltip; };
|
||||
function applyCompletion(view, option) {
|
||||
const apply = option.completion.apply || option.completion.label;
|
||||
let result = view.state.field(completionState).active.find(a => a.source == option.source);
|
||||
if (!(result instanceof ActiveResult))
|
||||
return false;
|
||||
if (typeof apply == "string")
|
||||
- view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to)), { annotations: pickedCompletion.of(option.completion) }));
|
||||
+ view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to, option.completion.extend)), { annotations: pickedCompletion.of(option.completion) }));
|
||||
else
|
||||
apply(view, option.completion, result.from, result.to);
|
||||
return true;
|
||||
@@ -1559,20 +1599,42 @@ interpreted as indicating a placeholder.
|
||||
function snippet(template) {
|
||||
let snippet = Snippet.parse(template);
|
||||
return (editor, completion, from, to) => {
|
||||
- let { text, ranges } = snippet.instantiate(editor.state, from);
|
||||
- let { main } = editor.state.selection;
|
||||
- let spec = {
|
||||
- changes: { from, to: to == main.from ? main.to : to, insert: state.Text.of(text) },
|
||||
- scrollIntoView: true,
|
||||
- annotations: completion ? [pickedCompletion.of(completion), state.Transaction.userEvent.of("input.complete")] : undefined
|
||||
- };
|
||||
+ let { main } = editor.state.selection, fromOff = from - main.from, toOff = to - main.from;
|
||||
+ let ranges = [];
|
||||
+ let totalOffset = 0;
|
||||
+ let spec = Object.assign(Object.assign({}, editor.state.changeByRange(range => {
|
||||
+ if (range != main && from != to &&
|
||||
+ editor.state.sliceDoc(range.from + fromOff, range.from + toOff) != editor.state.sliceDoc(from, to))
|
||||
+ return { range };
|
||||
+ let { text, ranges: fieldRanges } = snippet.instantiate(editor.state, range.from + fromOff);
|
||||
+ let change = {
|
||||
+ from: range.from + fromOff,
|
||||
+ to: range.from + toOff,
|
||||
+ insert: state.Text.of(text)
|
||||
+ };
|
||||
+ let originalTo = change.to;
|
||||
+ let offset = change.insert.length + fromOff;
|
||||
+ if (completion.extend) {
|
||||
+ completion.extend(editor.state, change);
|
||||
+ offset += originalTo - change.to;
|
||||
+ }
|
||||
+ for (const fieldRange of fieldRanges) {
|
||||
+ ranges.push(new FieldRange(fieldRange.field, fieldRange.from + totalOffset, fieldRange.to + totalOffset));
|
||||
+ }
|
||||
+ totalOffset += offset;
|
||||
+ return {
|
||||
+ changes: change,
|
||||
+ range: state.EditorSelection.cursor(change.from + change.insert.length)
|
||||
+ };
|
||||
+ })), { scrollIntoView: true, annotations: completion ? [pickedCompletion.of(completion), state.Transaction.userEvent.of("input.complete")] : undefined, effects: [] });
|
||||
if (ranges.length)
|
||||
spec.selection = fieldSelection(ranges, 0);
|
||||
if (ranges.some(r => r.field > 0)) {
|
||||
let active = new ActiveSnippet(ranges, 0);
|
||||
- let effects = spec.effects = [setActive.of(active)];
|
||||
- if (editor.state.field(snippetState, false) === undefined)
|
||||
- effects.push(state.StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
|
||||
+ spec.effects.push(setActive.of(active));
|
||||
+ if (editor.state.field(snippetState, false) === undefined) {
|
||||
+ spec.effects.push(state.StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
|
||||
+ }
|
||||
}
|
||||
editor.dispatch(editor.state.update(spec));
|
||||
};
|
||||
@@ -1746,7 +1808,8 @@ const completeAnyWord = context => {
|
||||
const defaults = {
|
||||
brackets: ["(", "[", "{", "'", '"'],
|
||||
before: ")]}:;>",
|
||||
- stringPrefixes: []
|
||||
+ stringPrefixes: [],
|
||||
+ buildInsert: (state, range, open, close) => open + close,
|
||||
};
|
||||
const closeBracketEffect = state.StateEffect.define({
|
||||
map(value, mapping) {
|
||||
@@ -1854,8 +1917,8 @@ function insertBracket(state$1, bracket) {
|
||||
for (let tok of tokens) {
|
||||
let closed = closing(state.codePointAt(tok, 0));
|
||||
if (bracket == tok)
|
||||
- return closed == tok ? handleSame(state$1, tok, tokens.indexOf(tok + tok + tok) > -1, conf)
|
||||
- : handleOpen(state$1, tok, closed, conf.before || defaults.before);
|
||||
+ return closed == tok ? handleSame(state$1, tok, tokens.indexOf(tok + tok) > -1, tokens.indexOf(tok + tok + tok) > -1, conf)
|
||||
+ : handleOpen(state$1, tok, closed, conf.before || defaults.before, conf);
|
||||
if (bracket == closed && closedBracketAt(state$1, state$1.selection.main.from))
|
||||
return handleClose(state$1, tok, closed);
|
||||
}
|
||||
@@ -1877,17 +1940,21 @@ function prevChar(doc, pos) {
|
||||
let prev = doc.sliceString(pos - 2, pos);
|
||||
return state.codePointSize(state.codePointAt(prev, 0)) == prev.length ? prev : prev.slice(1);
|
||||
}
|
||||
-function handleOpen(state$1, open, close, closeBefore) {
|
||||
+function handleOpen(state$1, open, close, closeBefore, config) {
|
||||
+ let buildInsert = config.buildInsert || defaults.buildInsert;
|
||||
let dont = null, changes = state$1.changeByRange(range => {
|
||||
+ var _a;
|
||||
if (!range.empty)
|
||||
return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }],
|
||||
effects: closeBracketEffect.of(range.to + open.length),
|
||||
range: state.EditorSelection.range(range.anchor + open.length, range.head + open.length) };
|
||||
let next = nextChar(state$1.doc, range.head);
|
||||
- if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1)
|
||||
- return { changes: { insert: open + close, from: range.head },
|
||||
- effects: closeBracketEffect.of(range.head + open.length),
|
||||
+ if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1) {
|
||||
+ const insert = (_a = buildInsert(state$1, range, open, close)) !== null && _a !== void 0 ? _a : open + close;
|
||||
+ return { changes: { insert, from: range.head },
|
||||
+ effects: insert === open ? [] : closeBracketEffect.of(range.head + open.length),
|
||||
range: state.EditorSelection.cursor(range.head + open.length) };
|
||||
+ }
|
||||
return { range: dont = range };
|
||||
});
|
||||
return dont ? null : state$1.update(changes, {
|
||||
@@ -1909,18 +1976,36 @@ function handleClose(state$1, _open, close) {
|
||||
}
|
||||
// Handles cases where the open and close token are the same, and
|
||||
// possibly triple quotes (as in `"""abc"""`-style quoting).
|
||||
-function handleSame(state$1, token, allowTriple, config) {
|
||||
+function handleSame(state$1, token, allowDouble, allowTriple, config) {
|
||||
let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes;
|
||||
+ let buildInsert = config.buildInsert || defaults.buildInsert;
|
||||
let dont = null, changes = state$1.changeByRange(range => {
|
||||
+ var _a, _b, _c;
|
||||
if (!range.empty)
|
||||
return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }],
|
||||
effects: closeBracketEffect.of(range.to + token.length),
|
||||
range: state.EditorSelection.range(range.anchor + token.length, range.head + token.length) };
|
||||
let pos = range.head, next = nextChar(state$1.doc, pos), start;
|
||||
- if (next == token) {
|
||||
+ if (allowTriple && state$1.sliceDoc(pos - 2 * token.length, pos) == token + token &&
|
||||
+ (start = canStartStringAt(state$1, pos - 2 * token.length, stringPrefixes)) > -1 &&
|
||||
+ nodeStart(state$1, start)) {
|
||||
+ return { changes: { insert: token + token + token + token, from: pos },
|
||||
+ effects: closeBracketEffect.of(pos + token.length),
|
||||
+ range: state.EditorSelection.cursor(pos + token.length) };
|
||||
+ }
|
||||
+ else if (allowDouble && state$1.sliceDoc(pos - token.length, pos) == token &&
|
||||
+ (start = canStartStringAt(state$1, pos - token.length, stringPrefixes)) > -1 &&
|
||||
+ nodeStart(state$1, start)) {
|
||||
+ let insert = (_a = buildInsert(state$1, range, token, token)) !== null && _a !== void 0 ? _a : token + token;
|
||||
+ return { changes: { insert, from: pos },
|
||||
+ effects: insert === token ? [] : closeBracketEffect.of(pos + token.length),
|
||||
+ range: state.EditorSelection.cursor(pos + token.length) };
|
||||
+ }
|
||||
+ else if (next == token) {
|
||||
if (nodeStart(state$1, pos)) {
|
||||
- return { changes: { insert: token + token, from: pos },
|
||||
- effects: closeBracketEffect.of(pos + token.length),
|
||||
+ let insert = (_b = buildInsert(state$1, range, token, token)) !== null && _b !== void 0 ? _b : token + token;
|
||||
+ return { changes: { insert, from: pos },
|
||||
+ effects: insert === token ? [] : closeBracketEffect.of(pos + token.length),
|
||||
range: state.EditorSelection.cursor(pos + token.length) };
|
||||
}
|
||||
else if (closedBracketAt(state$1, pos)) {
|
||||
@@ -1930,18 +2015,13 @@ function handleSame(state$1, token, allowTriple, config) {
|
||||
range: state.EditorSelection.cursor(pos + content.length) };
|
||||
}
|
||||
}
|
||||
- else if (allowTriple && state$1.sliceDoc(pos - 2 * token.length, pos) == token + token &&
|
||||
- (start = canStartStringAt(state$1, pos - 2 * token.length, stringPrefixes)) > -1 &&
|
||||
- nodeStart(state$1, start)) {
|
||||
- return { changes: { insert: token + token + token + token, from: pos },
|
||||
- effects: closeBracketEffect.of(pos + token.length),
|
||||
- range: state.EditorSelection.cursor(pos + token.length) };
|
||||
- }
|
||||
else if (state$1.charCategorizer(pos)(next) != state.CharCategory.Word) {
|
||||
- if (canStartStringAt(state$1, pos, stringPrefixes) > -1 && !probablyInString(state$1, pos, token, stringPrefixes))
|
||||
- return { changes: { insert: token + token, from: pos },
|
||||
- effects: closeBracketEffect.of(pos + token.length),
|
||||
+ if (canStartStringAt(state$1, pos, stringPrefixes) > -1 && !probablyInString(state$1, pos, token, stringPrefixes)) {
|
||||
+ const insert = (_c = buildInsert(state$1, range, token, token)) !== null && _c !== void 0 ? _c : token + token;
|
||||
+ return { changes: { insert, from: pos },
|
||||
+ effects: insert === token ? [] : closeBracketEffect.of(pos + token.length),
|
||||
range: state.EditorSelection.cursor(pos + token.length) };
|
||||
+ }
|
||||
}
|
||||
return { range: dont = range };
|
||||
});
|
||||
@@ -2086,6 +2166,7 @@ exports.completionKeymap = completionKeymap;
|
||||
exports.completionStatus = completionStatus;
|
||||
exports.currentCompletions = currentCompletions;
|
||||
exports.deleteBracketPair = deleteBracketPair;
|
||||
+exports.getCompletionTooltip = getCompletionTooltip;
|
||||
exports.hasNextSnippetField = hasNextSnippetField;
|
||||
exports.hasPrevSnippetField = hasPrevSnippetField;
|
||||
exports.ifIn = ifIn;
|
||||
@@ -2093,8 +2174,10 @@ exports.ifNotIn = ifNotIn;
|
||||
exports.insertBracket = insertBracket;
|
||||
exports.insertCompletionText = insertCompletionText;
|
||||
exports.moveCompletionSelection = moveCompletionSelection;
|
||||
+exports.nextChar = nextChar;
|
||||
exports.nextSnippetField = nextSnippetField;
|
||||
exports.pickedCompletion = pickedCompletion;
|
||||
+exports.prevChar = prevChar;
|
||||
exports.prevSnippetField = prevSnippetField;
|
||||
exports.selectedCompletion = selectedCompletion;
|
||||
exports.selectedCompletionIndex = selectedCompletionIndex;
|
||||
diff --git a/dist/index.d.cts b/dist/index.d.cts
|
||||
index b57b8f6..fce47ab 100644
|
||||
--- a/dist/index.d.cts
|
||||
+++ b/dist/index.d.cts
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
-import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state';
|
||||
-import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view';
|
||||
+import { EditorState, Text, ChangeDesc, TransactionSpec, StateCommand, Transaction, Facet, SelectionRange, Extension, StateEffect } from '@codemirror/state';
|
||||
+import { EditorView, Rect, KeyBinding, Tooltip, Command } from '@codemirror/view';
|
||||
import * as _lezer_common from '@lezer/common';
|
||||
|
||||
/**
|
||||
@@ -73,6 +73,19 @@ interface Completion {
|
||||
a `{name}` object.
|
||||
*/
|
||||
section?: string | CompletionSection;
|
||||
+ /**
|
||||
+ Can be used to alter the change created when the completion is applied
|
||||
+ */
|
||||
+ extend?: ExtendCompletion;
|
||||
+ /**
|
||||
+ If multiple sources return the same result, use this field to specifiy a
|
||||
+ deduplication key as well as a priority. For each unique key, only the
|
||||
+ completion with the highest priority will be shown.
|
||||
+ */
|
||||
+ deduplicate?: {
|
||||
+ key: string;
|
||||
+ priority: number;
|
||||
+ };
|
||||
}
|
||||
/**
|
||||
The type returned from
|
||||
@@ -306,12 +319,17 @@ This annotation is added to transactions that are produced by
|
||||
picking a completion.
|
||||
*/
|
||||
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>;
|
||||
+type ExtendCompletion = (state: EditorState, change: {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ insert: string | Text;
|
||||
+}) => void;
|
||||
/**
|
||||
Helper function that returns a transaction spec which inserts a
|
||||
completion's text in the main selection range, and any other
|
||||
selection range that has the same text in front of it.
|
||||
*/
|
||||
-declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec;
|
||||
+declare function insertCompletionText(state: EditorState, text: string | Text, from: number, to: number, extend?: ExtendCompletion): TransactionSpec;
|
||||
|
||||
interface CompletionConfig {
|
||||
/**
|
||||
@@ -441,6 +459,10 @@ interface CompletionConfig {
|
||||
milliseconds.
|
||||
*/
|
||||
updateSyncTime?: number;
|
||||
+ /**
|
||||
+ overleaf: Move unfiltered results after the filtered ones
|
||||
+ */
|
||||
+ unfilteredResultsAtEnd?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,6 +536,8 @@ applies the snippet.
|
||||
*/
|
||||
declare function snippetCompletion(template: string, completion: Completion): Completion;
|
||||
|
||||
+declare const getCompletionTooltip: (state: EditorState) => Tooltip | undefined | null;
|
||||
+
|
||||
/**
|
||||
Returns a command that moves the completion selection forward or
|
||||
backward by the given amount.
|
||||
@@ -562,6 +586,11 @@ interface CloseBracketConfig {
|
||||
these prefixes before the opening quote.
|
||||
*/
|
||||
stringPrefixes?: string[];
|
||||
+ /**
|
||||
+ An optional callback for overriding the content that's inserted
|
||||
+ based on surrounding characters
|
||||
+ */
|
||||
+ buildInsert?: (state: EditorState, range: SelectionRange, open: string, close: string) => string;
|
||||
}
|
||||
/**
|
||||
Extension to enable bracket-closing behavior. When a closeable
|
||||
@@ -593,6 +622,8 @@ to programmatically insert brackets—the
|
||||
take care of running this for user input.)
|
||||
*/
|
||||
declare function insertBracket(state: EditorState, bracket: string): Transaction | null;
|
||||
+declare function nextChar(doc: Text, pos: number): string;
|
||||
+declare function prevChar(doc: Text, pos: number): string;
|
||||
|
||||
/**
|
||||
Returns an extension that enables autocompletion.
|
||||
@@ -636,4 +667,5 @@ the currently selected completion.
|
||||
*/
|
||||
declare function setSelectedCompletion(index: number): StateEffect<unknown>;
|
||||
|
||||
-export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
+export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, getCompletionTooltip, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextChar, nextSnippetField, pickedCompletion, prevChar, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
+export type { CloseBracketConfig, Completion, CompletionInfo, CompletionResult, CompletionSection, CompletionSource };
|
||||
diff --git a/dist/index.d.ts b/dist/index.d.ts
|
||||
index b57b8f6..fce47ab 100644
|
||||
--- a/dist/index.d.ts
|
||||
+++ b/dist/index.d.ts
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
-import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state';
|
||||
-import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view';
|
||||
+import { EditorState, Text, ChangeDesc, TransactionSpec, StateCommand, Transaction, Facet, SelectionRange, Extension, StateEffect } from '@codemirror/state';
|
||||
+import { EditorView, Rect, KeyBinding, Tooltip, Command } from '@codemirror/view';
|
||||
import * as _lezer_common from '@lezer/common';
|
||||
|
||||
/**
|
||||
@@ -73,6 +73,19 @@ interface Completion {
|
||||
a `{name}` object.
|
||||
*/
|
||||
section?: string | CompletionSection;
|
||||
+ /**
|
||||
+ Can be used to alter the change created when the completion is applied
|
||||
+ */
|
||||
+ extend?: ExtendCompletion;
|
||||
+ /**
|
||||
+ If multiple sources return the same result, use this field to specifiy a
|
||||
+ deduplication key as well as a priority. For each unique key, only the
|
||||
+ completion with the highest priority will be shown.
|
||||
+ */
|
||||
+ deduplicate?: {
|
||||
+ key: string;
|
||||
+ priority: number;
|
||||
+ };
|
||||
}
|
||||
/**
|
||||
The type returned from
|
||||
@@ -306,12 +319,17 @@ This annotation is added to transactions that are produced by
|
||||
picking a completion.
|
||||
*/
|
||||
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>;
|
||||
+type ExtendCompletion = (state: EditorState, change: {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ insert: string | Text;
|
||||
+}) => void;
|
||||
/**
|
||||
Helper function that returns a transaction spec which inserts a
|
||||
completion's text in the main selection range, and any other
|
||||
selection range that has the same text in front of it.
|
||||
*/
|
||||
-declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec;
|
||||
+declare function insertCompletionText(state: EditorState, text: string | Text, from: number, to: number, extend?: ExtendCompletion): TransactionSpec;
|
||||
|
||||
interface CompletionConfig {
|
||||
/**
|
||||
@@ -441,6 +459,10 @@ interface CompletionConfig {
|
||||
milliseconds.
|
||||
*/
|
||||
updateSyncTime?: number;
|
||||
+ /**
|
||||
+ overleaf: Move unfiltered results after the filtered ones
|
||||
+ */
|
||||
+ unfilteredResultsAtEnd?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,6 +536,8 @@ applies the snippet.
|
||||
*/
|
||||
declare function snippetCompletion(template: string, completion: Completion): Completion;
|
||||
|
||||
+declare const getCompletionTooltip: (state: EditorState) => Tooltip | undefined | null;
|
||||
+
|
||||
/**
|
||||
Returns a command that moves the completion selection forward or
|
||||
backward by the given amount.
|
||||
@@ -562,6 +586,11 @@ interface CloseBracketConfig {
|
||||
these prefixes before the opening quote.
|
||||
*/
|
||||
stringPrefixes?: string[];
|
||||
+ /**
|
||||
+ An optional callback for overriding the content that's inserted
|
||||
+ based on surrounding characters
|
||||
+ */
|
||||
+ buildInsert?: (state: EditorState, range: SelectionRange, open: string, close: string) => string;
|
||||
}
|
||||
/**
|
||||
Extension to enable bracket-closing behavior. When a closeable
|
||||
@@ -593,6 +622,8 @@ to programmatically insert brackets—the
|
||||
take care of running this for user input.)
|
||||
*/
|
||||
declare function insertBracket(state: EditorState, bracket: string): Transaction | null;
|
||||
+declare function nextChar(doc: Text, pos: number): string;
|
||||
+declare function prevChar(doc: Text, pos: number): string;
|
||||
|
||||
/**
|
||||
Returns an extension that enables autocompletion.
|
||||
@@ -636,4 +667,5 @@ the currently selected completion.
|
||||
*/
|
||||
declare function setSelectedCompletion(index: number): StateEffect<unknown>;
|
||||
|
||||
-export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
+export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, getCompletionTooltip, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextChar, nextSnippetField, pickedCompletion, prevChar, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
+export type { CloseBracketConfig, Completion, CompletionInfo, CompletionResult, CompletionSection, CompletionSource };
|
||||
diff --git a/dist/index.js b/dist/index.js
|
||||
index 4729223..9361a53 100644
|
||||
--- a/dist/index.js
|
||||
+++ b/dist/index.js
|
||||
@@ -1,4 +1,4 @@
|
||||
-import { Annotation, StateEffect, EditorSelection, codePointAt, codePointSize, fromCodePoint, Facet, combineConfig, StateField, Prec, Text, Transaction, MapMode, RangeValue, RangeSet, CharCategory } from '@codemirror/state';
|
||||
+import { Annotation, StateEffect, Text, EditorSelection, codePointAt, codePointSize, fromCodePoint, Facet, combineConfig, StateField, Prec, Transaction, MapMode, RangeValue, RangeSet, CharCategory } from '@codemirror/state';
|
||||
import { Direction, logException, showTooltip, EditorView, ViewPlugin, getTooltip, Decoration, WidgetType, keymap } from '@codemirror/view';
|
||||
import { syntaxTree, indentUnit } from '@codemirror/language';
|
||||
|
||||
@@ -185,16 +185,23 @@ Helper function that returns a transaction spec which inserts a
|
||||
completion's text in the main selection range, and any other
|
||||
selection range that has the same text in front of it.
|
||||
*/
|
||||
-function insertCompletionText(state, text, from, to) {
|
||||
+function insertCompletionText(state, text, from, to, extend) {
|
||||
let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from;
|
||||
return Object.assign(Object.assign({}, state.changeByRange(range => {
|
||||
if (range != main && from != to &&
|
||||
state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to))
|
||||
return { range };
|
||||
- let lines = state.toText(text);
|
||||
+ let change = {
|
||||
+ from: range.from + fromOff,
|
||||
+ to: to == main.from ? range.to : range.from + toOff,
|
||||
+ insert: text instanceof Text ? text : state.toText(text),
|
||||
+ };
|
||||
+ if (extend) {
|
||||
+ extend(state, change);
|
||||
+ }
|
||||
return {
|
||||
- changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines },
|
||||
- range: EditorSelection.cursor(range.from + fromOff + lines.length)
|
||||
+ changes: change,
|
||||
+ range: EditorSelection.cursor(change.from + change.insert.length)
|
||||
};
|
||||
})), { scrollIntoView: true, userEvent: "input.complete" });
|
||||
}
|
||||
@@ -387,7 +394,9 @@ const completionConfig = /*@__PURE__*/Facet.define({
|
||||
filterStrict: false,
|
||||
compareCompletions: (a, b) => a.label.localeCompare(b.label),
|
||||
interactionDelay: 75,
|
||||
- updateSyncTime: 100
|
||||
+ updateSyncTime: 100,
|
||||
+ // overleaf: default to at top which is default CM6 behaviour
|
||||
+ unfilteredResultsAtEnd: false
|
||||
}, {
|
||||
defaultKeymap: (a, b) => a && b,
|
||||
closeOnBlur: (a, b) => a && b,
|
||||
@@ -742,6 +751,7 @@ function score(option) {
|
||||
(option.type ? 1 : 0);
|
||||
}
|
||||
function sortOptions(active, state) {
|
||||
+ var _a;
|
||||
let options = [];
|
||||
let sections = null;
|
||||
let addOption = (option) => {
|
||||
@@ -761,7 +771,8 @@ function sortOptions(active, state) {
|
||||
let getMatch = a.result.getMatch;
|
||||
if (a.result.filter === false) {
|
||||
for (let option of a.result.options) {
|
||||
- addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length));
|
||||
+ let defaultScore = conf.unfilteredResultsAtEnd ? -1e9 : 1e9;
|
||||
+ addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], defaultScore - options.length));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -788,15 +799,42 @@ function sortOptions(active, state) {
|
||||
}
|
||||
}
|
||||
let result = [], prev = null;
|
||||
+ const priorityIndices = new Map();
|
||||
let compare = conf.compareCompletions;
|
||||
for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
|
||||
+ // overleaf: Deduplicate results with dedup options
|
||||
+ // The goal is to keep only the highest priority option, in the
|
||||
+ // highest scoring position.
|
||||
+ const key = (_a = opt.completion.deduplicate) === null || _a === void 0 ? void 0 : _a.key;
|
||||
+ if (key) {
|
||||
+ // Handle merging specifically for deduplicated items item
|
||||
+ const currentOptionIndex = priorityIndices.get(key);
|
||||
+ if (currentOptionIndex === undefined) {
|
||||
+ priorityIndices.set(key, result.length);
|
||||
+ result.push(opt);
|
||||
+ prev = opt.completion;
|
||||
+ }
|
||||
+ else {
|
||||
+ if (result[currentOptionIndex].completion.deduplicate.priority < opt.completion.deduplicate.priority) {
|
||||
+ result[currentOptionIndex] = opt;
|
||||
+ if (currentOptionIndex === result.length - 1) {
|
||||
+ prev = opt.completion;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ // overleaf: end
|
||||
let cur = opt.completion;
|
||||
- if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
|
||||
- (prev.type != null && cur.type != null && prev.type != cur.type) ||
|
||||
- prev.apply != cur.apply || prev.boost != cur.boost)
|
||||
+ if (!prev || prev.label != cur.label)
|
||||
+ result.push(opt);
|
||||
+ // overleaf: we're already handling deduplication, so skip extra merges
|
||||
+ else if (prev.deduplicate)
|
||||
result.push(opt);
|
||||
else if (score(opt.completion) > score(prev))
|
||||
result[result.length - 1] = opt;
|
||||
+ else if (opt.completion.info)
|
||||
+ result[result.length - 1] = opt;
|
||||
prev = opt.completion;
|
||||
}
|
||||
return result;
|
||||
@@ -815,8 +853,9 @@ class CompletionDialog {
|
||||
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
||||
}
|
||||
static build(active, state, id, prev, conf, didSetActive) {
|
||||
- if (prev && !didSetActive && active.some(s => s.isPending))
|
||||
- return prev.setDisabled();
|
||||
+ // Overleaf: avoid setting the previous completion state to disabled while completion sources are pending
|
||||
+ // if (prev && !didSetActive && active.some(s => s.isPending))
|
||||
+ // return prev.setDisabled()
|
||||
let options = sortOptions(active, state);
|
||||
if (!options.length)
|
||||
return prev && active.some(a => a.isPending) ? prev.setDisabled() : null;
|
||||
@@ -1015,13 +1054,14 @@ const completionState = /*@__PURE__*/StateField.define({
|
||||
EditorView.contentAttributes.from(f, state => state.attrs)
|
||||
]
|
||||
});
|
||||
+const getCompletionTooltip = (state) => { var _a; return (_a = state.field(completionState, false)) === null || _a === void 0 ? void 0 : _a.tooltip; };
|
||||
function applyCompletion(view, option) {
|
||||
const apply = option.completion.apply || option.completion.label;
|
||||
let result = view.state.field(completionState).active.find(a => a.source == option.source);
|
||||
if (!(result instanceof ActiveResult))
|
||||
return false;
|
||||
if (typeof apply == "string")
|
||||
- view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to)), { annotations: pickedCompletion.of(option.completion) }));
|
||||
+ view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to, option.completion.extend)), { annotations: pickedCompletion.of(option.completion) }));
|
||||
else
|
||||
apply(view, option.completion, result.from, result.to);
|
||||
return true;
|
||||
@@ -1557,20 +1597,42 @@ interpreted as indicating a placeholder.
|
||||
function snippet(template) {
|
||||
let snippet = Snippet.parse(template);
|
||||
return (editor, completion, from, to) => {
|
||||
- let { text, ranges } = snippet.instantiate(editor.state, from);
|
||||
- let { main } = editor.state.selection;
|
||||
- let spec = {
|
||||
- changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
|
||||
- scrollIntoView: true,
|
||||
- annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
|
||||
- };
|
||||
+ let { main } = editor.state.selection, fromOff = from - main.from, toOff = to - main.from;
|
||||
+ let ranges = [];
|
||||
+ let totalOffset = 0;
|
||||
+ let spec = Object.assign(Object.assign({}, editor.state.changeByRange(range => {
|
||||
+ if (range != main && from != to &&
|
||||
+ editor.state.sliceDoc(range.from + fromOff, range.from + toOff) != editor.state.sliceDoc(from, to))
|
||||
+ return { range };
|
||||
+ let { text, ranges: fieldRanges } = snippet.instantiate(editor.state, range.from + fromOff);
|
||||
+ let change = {
|
||||
+ from: range.from + fromOff,
|
||||
+ to: range.from + toOff,
|
||||
+ insert: Text.of(text)
|
||||
+ };
|
||||
+ let originalTo = change.to;
|
||||
+ let offset = change.insert.length + fromOff;
|
||||
+ if (completion.extend) {
|
||||
+ completion.extend(editor.state, change);
|
||||
+ offset += originalTo - change.to;
|
||||
+ }
|
||||
+ for (const fieldRange of fieldRanges) {
|
||||
+ ranges.push(new FieldRange(fieldRange.field, fieldRange.from + totalOffset, fieldRange.to + totalOffset));
|
||||
+ }
|
||||
+ totalOffset += offset;
|
||||
+ return {
|
||||
+ changes: change,
|
||||
+ range: EditorSelection.cursor(change.from + change.insert.length)
|
||||
+ };
|
||||
+ })), { scrollIntoView: true, annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined, effects: [] });
|
||||
if (ranges.length)
|
||||
spec.selection = fieldSelection(ranges, 0);
|
||||
if (ranges.some(r => r.field > 0)) {
|
||||
let active = new ActiveSnippet(ranges, 0);
|
||||
- let effects = spec.effects = [setActive.of(active)];
|
||||
- if (editor.state.field(snippetState, false) === undefined)
|
||||
- effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
|
||||
+ spec.effects.push(setActive.of(active));
|
||||
+ if (editor.state.field(snippetState, false) === undefined) {
|
||||
+ spec.effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
|
||||
+ }
|
||||
}
|
||||
editor.dispatch(editor.state.update(spec));
|
||||
};
|
||||
@@ -1744,7 +1806,8 @@ const completeAnyWord = context => {
|
||||
const defaults = {
|
||||
brackets: ["(", "[", "{", "'", '"'],
|
||||
before: ")]}:;>",
|
||||
- stringPrefixes: []
|
||||
+ stringPrefixes: [],
|
||||
+ buildInsert: (state, range, open, close) => open + close,
|
||||
};
|
||||
const closeBracketEffect = /*@__PURE__*/StateEffect.define({
|
||||
map(value, mapping) {
|
||||
@@ -1852,8 +1915,8 @@ function insertBracket(state, bracket) {
|
||||
for (let tok of tokens) {
|
||||
let closed = closing(codePointAt(tok, 0));
|
||||
if (bracket == tok)
|
||||
- return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1, conf)
|
||||
- : handleOpen(state, tok, closed, conf.before || defaults.before);
|
||||
+ return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok) > -1, tokens.indexOf(tok + tok + tok) > -1, conf)
|
||||
+ : handleOpen(state, tok, closed, conf.before || defaults.before, conf);
|
||||
if (bracket == closed && closedBracketAt(state, state.selection.main.from))
|
||||
return handleClose(state, tok, closed);
|
||||
}
|
||||
@@ -1875,17 +1938,21 @@ function prevChar(doc, pos) {
|
||||
let prev = doc.sliceString(pos - 2, pos);
|
||||
return codePointSize(codePointAt(prev, 0)) == prev.length ? prev : prev.slice(1);
|
||||
}
|
||||
-function handleOpen(state, open, close, closeBefore) {
|
||||
+function handleOpen(state, open, close, closeBefore, config) {
|
||||
+ let buildInsert = config.buildInsert || defaults.buildInsert;
|
||||
let dont = null, changes = state.changeByRange(range => {
|
||||
+ var _a;
|
||||
if (!range.empty)
|
||||
return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }],
|
||||
effects: closeBracketEffect.of(range.to + open.length),
|
||||
range: EditorSelection.range(range.anchor + open.length, range.head + open.length) };
|
||||
let next = nextChar(state.doc, range.head);
|
||||
- if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1)
|
||||
- return { changes: { insert: open + close, from: range.head },
|
||||
- effects: closeBracketEffect.of(range.head + open.length),
|
||||
+ if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1) {
|
||||
+ const insert = (_a = buildInsert(state, range, open, close)) !== null && _a !== void 0 ? _a : open + close;
|
||||
+ return { changes: { insert, from: range.head },
|
||||
+ effects: insert === open ? [] : closeBracketEffect.of(range.head + open.length),
|
||||
range: EditorSelection.cursor(range.head + open.length) };
|
||||
+ }
|
||||
return { range: dont = range };
|
||||
});
|
||||
return dont ? null : state.update(changes, {
|
||||
@@ -1907,18 +1974,36 @@ function handleClose(state, _open, close) {
|
||||
}
|
||||
// Handles cases where the open and close token are the same, and
|
||||
// possibly triple quotes (as in `"""abc"""`-style quoting).
|
||||
-function handleSame(state, token, allowTriple, config) {
|
||||
+function handleSame(state, token, allowDouble, allowTriple, config) {
|
||||
let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes;
|
||||
+ let buildInsert = config.buildInsert || defaults.buildInsert;
|
||||
let dont = null, changes = state.changeByRange(range => {
|
||||
+ var _a, _b, _c;
|
||||
if (!range.empty)
|
||||
return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }],
|
||||
effects: closeBracketEffect.of(range.to + token.length),
|
||||
range: EditorSelection.range(range.anchor + token.length, range.head + token.length) };
|
||||
let pos = range.head, next = nextChar(state.doc, pos), start;
|
||||
- if (next == token) {
|
||||
+ if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token &&
|
||||
+ (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 &&
|
||||
+ nodeStart(state, start)) {
|
||||
+ return { changes: { insert: token + token + token + token, from: pos },
|
||||
+ effects: closeBracketEffect.of(pos + token.length),
|
||||
+ range: EditorSelection.cursor(pos + token.length) };
|
||||
+ }
|
||||
+ else if (allowDouble && state.sliceDoc(pos - token.length, pos) == token &&
|
||||
+ (start = canStartStringAt(state, pos - token.length, stringPrefixes)) > -1 &&
|
||||
+ nodeStart(state, start)) {
|
||||
+ let insert = (_a = buildInsert(state, range, token, token)) !== null && _a !== void 0 ? _a : token + token;
|
||||
+ return { changes: { insert, from: pos },
|
||||
+ effects: insert === token ? [] : closeBracketEffect.of(pos + token.length),
|
||||
+ range: EditorSelection.cursor(pos + token.length) };
|
||||
+ }
|
||||
+ else if (next == token) {
|
||||
if (nodeStart(state, pos)) {
|
||||
- return { changes: { insert: token + token, from: pos },
|
||||
- effects: closeBracketEffect.of(pos + token.length),
|
||||
+ let insert = (_b = buildInsert(state, range, token, token)) !== null && _b !== void 0 ? _b : token + token;
|
||||
+ return { changes: { insert, from: pos },
|
||||
+ effects: insert === token ? [] : closeBracketEffect.of(pos + token.length),
|
||||
range: EditorSelection.cursor(pos + token.length) };
|
||||
}
|
||||
else if (closedBracketAt(state, pos)) {
|
||||
@@ -1928,18 +2013,13 @@ function handleSame(state, token, allowTriple, config) {
|
||||
range: EditorSelection.cursor(pos + content.length) };
|
||||
}
|
||||
}
|
||||
- else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token &&
|
||||
- (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 &&
|
||||
- nodeStart(state, start)) {
|
||||
- return { changes: { insert: token + token + token + token, from: pos },
|
||||
- effects: closeBracketEffect.of(pos + token.length),
|
||||
- range: EditorSelection.cursor(pos + token.length) };
|
||||
- }
|
||||
else if (state.charCategorizer(pos)(next) != CharCategory.Word) {
|
||||
- if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes))
|
||||
- return { changes: { insert: token + token, from: pos },
|
||||
- effects: closeBracketEffect.of(pos + token.length),
|
||||
+ if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes)) {
|
||||
+ const insert = (_c = buildInsert(state, range, token, token)) !== null && _c !== void 0 ? _c : token + token;
|
||||
+ return { changes: { insert, from: pos },
|
||||
+ effects: insert === token ? [] : closeBracketEffect.of(pos + token.length),
|
||||
range: EditorSelection.cursor(pos + token.length) };
|
||||
+ }
|
||||
}
|
||||
return { range: dont = range };
|
||||
});
|
||||
@@ -2071,4 +2151,4 @@ function setSelectedCompletion(index) {
|
||||
return setSelectedEffect.of(index);
|
||||
}
|
||||
|
||||
-export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
+export { CompletionContext, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, getCompletionTooltip, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextChar, nextSnippetField, pickedCompletion, prevChar, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
381
.yarn/patches/@codemirror-search-npm-6.5.8.patch
Normal file
381
.yarn/patches/@codemirror-search-npm-6.5.8.patch
Normal file
@@ -0,0 +1,381 @@
|
||||
diff --git a/dist/index.cjs b/dist/index.cjs
|
||||
index 46231ae..fb0f9aa 100644
|
||||
--- a/dist/index.cjs
|
||||
+++ b/dist/index.cjs
|
||||
@@ -592,6 +592,7 @@ class SearchQuery {
|
||||
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
||||
this.unquoted = this.unquote(this.search);
|
||||
this.wholeWord = !!config.wholeWord;
|
||||
+ this.scope = config.scope;
|
||||
}
|
||||
/**
|
||||
@internal
|
||||
@@ -606,7 +607,7 @@ class SearchQuery {
|
||||
eq(other) {
|
||||
return this.search == other.search && this.replace == other.replace &&
|
||||
this.caseSensitive == other.caseSensitive && this.regexp == other.regexp &&
|
||||
- this.wholeWord == other.wholeWord;
|
||||
+ this.wholeWord == other.wholeWord && this.scope == other.scope;
|
||||
}
|
||||
/**
|
||||
@internal
|
||||
@@ -631,7 +632,12 @@ class QueryType {
|
||||
}
|
||||
}
|
||||
function stringCursor(spec, state, from, to) {
|
||||
- return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);
|
||||
+ const test = spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined;
|
||||
+ const testWithinScope = (from, to, buffer, bufferPos) => {
|
||||
+ return (!test || test(from, to, buffer, bufferPos))
|
||||
+ && (!spec.scope || spec.scope.some(range => from >= range.from && from <= range.to && to >= range.from && to <= range.to));
|
||||
+ };
|
||||
+ return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), testWithinScope);
|
||||
}
|
||||
function stringWordTest(doc, categorizer) {
|
||||
return (from, to, buf, bufPos) => {
|
||||
@@ -695,9 +701,14 @@ class StringQuery extends QueryType {
|
||||
}
|
||||
}
|
||||
function regexpCursor(spec, state, from, to) {
|
||||
+ const test = spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined;
|
||||
+ const testWithinScope = (from, to, match) => {
|
||||
+ return (!test || test(from, to, match))
|
||||
+ && (!spec.scope || spec.scope.some(range => from >= range.from && from <= range.to && to >= range.from && to <= range.to));
|
||||
+ };
|
||||
return new RegExpCursor(state.doc, spec.search, {
|
||||
ignoreCase: !spec.caseSensitive,
|
||||
- test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined
|
||||
+ test: testWithinScope,
|
||||
}, from, to);
|
||||
}
|
||||
function charBefore(str, index) {
|
||||
@@ -737,10 +748,18 @@ class RegExpQuery extends QueryType {
|
||||
this.prevMatchInRange(state, curTo, state.doc.length);
|
||||
}
|
||||
getReplacement(result) {
|
||||
- return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
||||
- : i == "&" ? result.match[0]
|
||||
- : i != "0" && +i < result.match.length ? result.match[i]
|
||||
- : m);
|
||||
+ return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (m, i) => {
|
||||
+ if (i == "&")
|
||||
+ return result.match[0];
|
||||
+ if (i == "$")
|
||||
+ return "$";
|
||||
+ for (let l = i.length; l > 0; l--) {
|
||||
+ let n = +i.slice(0, l);
|
||||
+ if (n > 0 && n < result.match.length)
|
||||
+ return result.match[n] + i.slice(l);
|
||||
+ }
|
||||
+ return m;
|
||||
+ });
|
||||
}
|
||||
matchAll(state, limit) {
|
||||
let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
||||
@@ -1227,7 +1246,9 @@ const searchExtensions = [
|
||||
exports.RegExpCursor = RegExpCursor;
|
||||
exports.SearchCursor = SearchCursor;
|
||||
exports.SearchQuery = SearchQuery;
|
||||
+exports.StringQuery = StringQuery;
|
||||
exports.closeSearchPanel = closeSearchPanel;
|
||||
+exports.createSearchPanel = createSearchPanel;
|
||||
exports.findNext = findNext;
|
||||
exports.findPrevious = findPrevious;
|
||||
exports.getSearchQuery = getSearchQuery;
|
||||
@@ -1242,4 +1263,6 @@ exports.searchPanelOpen = searchPanelOpen;
|
||||
exports.selectMatches = selectMatches;
|
||||
exports.selectNextOccurrence = selectNextOccurrence;
|
||||
exports.selectSelectionMatches = selectSelectionMatches;
|
||||
+exports.selectWord = selectWord;
|
||||
exports.setSearchQuery = setSearchQuery;
|
||||
+exports.togglePanel = togglePanel;
|
||||
diff --git a/dist/index.d.cts b/dist/index.d.cts
|
||||
index 08f5696..663d192 100644
|
||||
--- a/dist/index.d.cts
|
||||
+++ b/dist/index.d.cts
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Text, Extension, StateCommand, EditorState, SelectionRange, StateEffect } from '@codemirror/state';
|
||||
-import { Command, KeyBinding, EditorView, Panel } from '@codemirror/view';
|
||||
+import { Command, EditorView, Panel, KeyBinding } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
A search cursor provides an iterator over text matches in a
|
||||
@@ -161,6 +161,7 @@ the `"cm-selectionMatch"` class for the highlighting. When
|
||||
itself will be highlighted with `"cm-selectionMatch-main"`.
|
||||
*/
|
||||
declare function highlightSelectionMatches(options?: HighlightOptions): Extension;
|
||||
+declare const selectWord: StateCommand;
|
||||
/**
|
||||
Select next occurrence of the current selection. Expand selection
|
||||
to the surrounding word when the selection is empty.
|
||||
@@ -264,6 +265,13 @@ declare class SearchQuery {
|
||||
*/
|
||||
readonly wholeWord: boolean;
|
||||
/**
|
||||
+ When set, only include search matches within these ranges
|
||||
+ */
|
||||
+ readonly scope?: Readonly<{
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ }[]>;
|
||||
+ /**
|
||||
Create a query object.
|
||||
*/
|
||||
constructor(config: {
|
||||
@@ -293,6 +301,13 @@ declare class SearchQuery {
|
||||
Enable whole-word matching.
|
||||
*/
|
||||
wholeWord?: boolean;
|
||||
+ /**
|
||||
+ The ranges to match within
|
||||
+ */
|
||||
+ scope?: Readonly<{
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ }[]>;
|
||||
});
|
||||
/**
|
||||
Compare this query to another query.
|
||||
@@ -307,6 +322,34 @@ declare class SearchQuery {
|
||||
to: number;
|
||||
}>;
|
||||
}
|
||||
+type SearchResult = typeof SearchCursor.prototype.value;
|
||||
+declare abstract class QueryType<Result extends SearchResult = SearchResult> {
|
||||
+ readonly spec: SearchQuery;
|
||||
+ constructor(spec: SearchQuery);
|
||||
+ abstract nextMatch(state: EditorState, curFrom: number, curTo: number): Result | null;
|
||||
+ abstract prevMatch(state: EditorState, curFrom: number, curTo: number): Result | null;
|
||||
+ abstract getReplacement(result: Result): string;
|
||||
+ abstract matchAll(state: EditorState, limit: number): readonly Result[] | null;
|
||||
+ abstract highlight(state: EditorState, from: number, to: number, add: (from: number, to: number) => void): void;
|
||||
+}
|
||||
+declare class StringQuery extends QueryType<SearchResult> {
|
||||
+ constructor(spec: SearchQuery);
|
||||
+ nextMatch(state: EditorState, curFrom: number, curTo: number): {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ } | null;
|
||||
+ private prevMatchInRange;
|
||||
+ prevMatch(state: EditorState, curFrom: number, curTo: number): {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ } | null;
|
||||
+ getReplacement(_result: SearchResult): string;
|
||||
+ matchAll(state: EditorState, limit: number): {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ }[] | null;
|
||||
+ highlight(state: EditorState, from: number, to: number, add: (from: number, to: number) => void): void;
|
||||
+}
|
||||
/**
|
||||
A state effect that updates the current search query. Note that
|
||||
this only has an effect if the search state has been initialized
|
||||
@@ -315,6 +358,7 @@ by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSea
|
||||
once).
|
||||
*/
|
||||
declare const setSearchQuery: _codemirror_state.StateEffectType<SearchQuery>;
|
||||
+declare const togglePanel: _codemirror_state.StateEffectType<boolean>;
|
||||
/**
|
||||
Get the current search query from an editor state.
|
||||
*/
|
||||
@@ -353,6 +397,7 @@ Replace all instances of the search query with the given
|
||||
replacement.
|
||||
*/
|
||||
declare const replaceAll: Command;
|
||||
+declare function createSearchPanel(view: EditorView): Panel;
|
||||
/**
|
||||
Make sure the search panel is open and focused.
|
||||
*/
|
||||
@@ -372,4 +417,4 @@ Default search-related key bindings.
|
||||
*/
|
||||
declare const searchKeymap: readonly KeyBinding[];
|
||||
|
||||
-export { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };
|
||||
+export { RegExpCursor, SearchCursor, SearchQuery, StringQuery, closeSearchPanel, createSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, selectWord, setSearchQuery, togglePanel };
|
||||
diff --git a/dist/index.d.ts b/dist/index.d.ts
|
||||
index 08f5696..663d192 100644
|
||||
--- a/dist/index.d.ts
|
||||
+++ b/dist/index.d.ts
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Text, Extension, StateCommand, EditorState, SelectionRange, StateEffect } from '@codemirror/state';
|
||||
-import { Command, KeyBinding, EditorView, Panel } from '@codemirror/view';
|
||||
+import { Command, EditorView, Panel, KeyBinding } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
A search cursor provides an iterator over text matches in a
|
||||
@@ -161,6 +161,7 @@ the `"cm-selectionMatch"` class for the highlighting. When
|
||||
itself will be highlighted with `"cm-selectionMatch-main"`.
|
||||
*/
|
||||
declare function highlightSelectionMatches(options?: HighlightOptions): Extension;
|
||||
+declare const selectWord: StateCommand;
|
||||
/**
|
||||
Select next occurrence of the current selection. Expand selection
|
||||
to the surrounding word when the selection is empty.
|
||||
@@ -264,6 +265,13 @@ declare class SearchQuery {
|
||||
*/
|
||||
readonly wholeWord: boolean;
|
||||
/**
|
||||
+ When set, only include search matches within these ranges
|
||||
+ */
|
||||
+ readonly scope?: Readonly<{
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ }[]>;
|
||||
+ /**
|
||||
Create a query object.
|
||||
*/
|
||||
constructor(config: {
|
||||
@@ -293,6 +301,13 @@ declare class SearchQuery {
|
||||
Enable whole-word matching.
|
||||
*/
|
||||
wholeWord?: boolean;
|
||||
+ /**
|
||||
+ The ranges to match within
|
||||
+ */
|
||||
+ scope?: Readonly<{
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ }[]>;
|
||||
});
|
||||
/**
|
||||
Compare this query to another query.
|
||||
@@ -307,6 +322,34 @@ declare class SearchQuery {
|
||||
to: number;
|
||||
}>;
|
||||
}
|
||||
+type SearchResult = typeof SearchCursor.prototype.value;
|
||||
+declare abstract class QueryType<Result extends SearchResult = SearchResult> {
|
||||
+ readonly spec: SearchQuery;
|
||||
+ constructor(spec: SearchQuery);
|
||||
+ abstract nextMatch(state: EditorState, curFrom: number, curTo: number): Result | null;
|
||||
+ abstract prevMatch(state: EditorState, curFrom: number, curTo: number): Result | null;
|
||||
+ abstract getReplacement(result: Result): string;
|
||||
+ abstract matchAll(state: EditorState, limit: number): readonly Result[] | null;
|
||||
+ abstract highlight(state: EditorState, from: number, to: number, add: (from: number, to: number) => void): void;
|
||||
+}
|
||||
+declare class StringQuery extends QueryType<SearchResult> {
|
||||
+ constructor(spec: SearchQuery);
|
||||
+ nextMatch(state: EditorState, curFrom: number, curTo: number): {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ } | null;
|
||||
+ private prevMatchInRange;
|
||||
+ prevMatch(state: EditorState, curFrom: number, curTo: number): {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ } | null;
|
||||
+ getReplacement(_result: SearchResult): string;
|
||||
+ matchAll(state: EditorState, limit: number): {
|
||||
+ from: number;
|
||||
+ to: number;
|
||||
+ }[] | null;
|
||||
+ highlight(state: EditorState, from: number, to: number, add: (from: number, to: number) => void): void;
|
||||
+}
|
||||
/**
|
||||
A state effect that updates the current search query. Note that
|
||||
this only has an effect if the search state has been initialized
|
||||
@@ -315,6 +358,7 @@ by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSea
|
||||
once).
|
||||
*/
|
||||
declare const setSearchQuery: _codemirror_state.StateEffectType<SearchQuery>;
|
||||
+declare const togglePanel: _codemirror_state.StateEffectType<boolean>;
|
||||
/**
|
||||
Get the current search query from an editor state.
|
||||
*/
|
||||
@@ -353,6 +397,7 @@ Replace all instances of the search query with the given
|
||||
replacement.
|
||||
*/
|
||||
declare const replaceAll: Command;
|
||||
+declare function createSearchPanel(view: EditorView): Panel;
|
||||
/**
|
||||
Make sure the search panel is open and focused.
|
||||
*/
|
||||
@@ -372,4 +417,4 @@ Default search-related key bindings.
|
||||
*/
|
||||
declare const searchKeymap: readonly KeyBinding[];
|
||||
|
||||
-export { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };
|
||||
+export { RegExpCursor, SearchCursor, SearchQuery, StringQuery, closeSearchPanel, createSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, selectWord, setSearchQuery, togglePanel };
|
||||
diff --git a/dist/index.js b/dist/index.js
|
||||
index 22172ef..08a9974 100644
|
||||
--- a/dist/index.js
|
||||
+++ b/dist/index.js
|
||||
@@ -590,6 +590,7 @@ class SearchQuery {
|
||||
this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
|
||||
this.unquoted = this.unquote(this.search);
|
||||
this.wholeWord = !!config.wholeWord;
|
||||
+ this.scope = config.scope;
|
||||
}
|
||||
/**
|
||||
@internal
|
||||
@@ -604,7 +605,7 @@ class SearchQuery {
|
||||
eq(other) {
|
||||
return this.search == other.search && this.replace == other.replace &&
|
||||
this.caseSensitive == other.caseSensitive && this.regexp == other.regexp &&
|
||||
- this.wholeWord == other.wholeWord;
|
||||
+ this.wholeWord == other.wholeWord && this.scope == other.scope;
|
||||
}
|
||||
/**
|
||||
@internal
|
||||
@@ -629,7 +630,12 @@ class QueryType {
|
||||
}
|
||||
}
|
||||
function stringCursor(spec, state, from, to) {
|
||||
- return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);
|
||||
+ const test = spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined;
|
||||
+ const testWithinScope = (from, to, buffer, bufferPos) => {
|
||||
+ return (!test || test(from, to, buffer, bufferPos))
|
||||
+ && (!spec.scope || spec.scope.some(range => from >= range.from && from <= range.to && to >= range.from && to <= range.to));
|
||||
+ };
|
||||
+ return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), testWithinScope);
|
||||
}
|
||||
function stringWordTest(doc, categorizer) {
|
||||
return (from, to, buf, bufPos) => {
|
||||
@@ -693,9 +699,14 @@ class StringQuery extends QueryType {
|
||||
}
|
||||
}
|
||||
function regexpCursor(spec, state, from, to) {
|
||||
+ const test = spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined;
|
||||
+ const testWithinScope = (from, to, match) => {
|
||||
+ return (!test || test(from, to, match))
|
||||
+ && (!spec.scope || spec.scope.some(range => from >= range.from && from <= range.to && to >= range.from && to <= range.to));
|
||||
+ };
|
||||
return new RegExpCursor(state.doc, spec.search, {
|
||||
ignoreCase: !spec.caseSensitive,
|
||||
- test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined
|
||||
+ test: testWithinScope,
|
||||
}, from, to);
|
||||
}
|
||||
function charBefore(str, index) {
|
||||
@@ -735,10 +746,18 @@ class RegExpQuery extends QueryType {
|
||||
this.prevMatchInRange(state, curTo, state.doc.length);
|
||||
}
|
||||
getReplacement(result) {
|
||||
- return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
|
||||
- : i == "&" ? result.match[0]
|
||||
- : i != "0" && +i < result.match.length ? result.match[i]
|
||||
- : m);
|
||||
+ return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (m, i) => {
|
||||
+ if (i == "&")
|
||||
+ return result.match[0];
|
||||
+ if (i == "$")
|
||||
+ return "$";
|
||||
+ for (let l = i.length; l > 0; l--) {
|
||||
+ let n = +i.slice(0, l);
|
||||
+ if (n > 0 && n < result.match.length)
|
||||
+ return result.match[n] + i.slice(l);
|
||||
+ }
|
||||
+ return m;
|
||||
+ });
|
||||
}
|
||||
matchAll(state, limit) {
|
||||
let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];
|
||||
@@ -1222,4 +1241,4 @@ const searchExtensions = [
|
||||
baseTheme
|
||||
];
|
||||
|
||||
-export { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };
|
||||
+export { RegExpCursor, SearchCursor, SearchQuery, StringQuery, closeSearchPanel, createSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, selectWord, setSearchQuery, togglePanel };
|
||||
44
.yarn/patches/body-parser-npm-1.20.4.patch
Normal file
44
.yarn/patches/body-parser-npm-1.20.4.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
diff --git a/lib/read.js b/lib/read.js
|
||||
index fce6283..6131c31 100644
|
||||
--- a/lib/read.js
|
||||
+++ b/lib/read.js
|
||||
@@ -18,7 +18,7 @@ var iconv = require('iconv-lite')
|
||||
var onFinished = require('on-finished')
|
||||
var unpipe = require('unpipe')
|
||||
var zlib = require('zlib')
|
||||
-
|
||||
+var Stream = require('stream')
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
@@ -166,25 +166,25 @@ function contentstream (req, debug, inflate) {
|
||||
case 'deflate':
|
||||
stream = zlib.createInflate()
|
||||
debug('inflate body')
|
||||
- req.pipe(stream)
|
||||
+ // req.pipe(stream)
|
||||
break
|
||||
case 'gzip':
|
||||
stream = zlib.createGunzip()
|
||||
debug('gunzip body')
|
||||
- req.pipe(stream)
|
||||
+ // req.pipe(stream)
|
||||
break
|
||||
case 'identity':
|
||||
stream = req
|
||||
stream.length = length
|
||||
- break
|
||||
+ return req
|
||||
default:
|
||||
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
|
||||
encoding: encoding,
|
||||
type: 'encoding.unsupported'
|
||||
})
|
||||
}
|
||||
-
|
||||
- return stream
|
||||
+ var pass = new Stream.PassThrough(); Stream.pipeline(req, stream, pass, () => {})
|
||||
+ return pass
|
||||
}
|
||||
|
||||
/**
|
||||
13
.yarn/patches/cypress-multi-reporters-npm-2.0.5.patch
Normal file
13
.yarn/patches/cypress-multi-reporters-npm-2.0.5.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/lib/MultiReporters.js b/lib/MultiReporters.js
|
||||
index 98dc4ef..b2a97bf 100644
|
||||
--- a/lib/MultiReporters.js
|
||||
+++ b/lib/MultiReporters.js
|
||||
@@ -160,7 +160,7 @@ MultiReporters.prototype.getCustomOptions = function (options) {
|
||||
debug('options file (custom)', customOptionsFile);
|
||||
|
||||
try {
|
||||
- if ('.js' === path.extname(customOptionsFile)) {
|
||||
+ if (['.js', '.cjs'].includes(path.extname(customOptionsFile))) {
|
||||
customOptions = require(customOptionsFile);
|
||||
}
|
||||
else {
|
||||
13
.yarn/patches/forwarded-npm-0.2.0.patch
Normal file
13
.yarn/patches/forwarded-npm-0.2.0.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index b2b6bdd..75e6254 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -46,7 +46,7 @@ function forwarded (req) {
|
||||
function getSocketAddr (req) {
|
||||
return req.socket
|
||||
? req.socket.remoteAddress
|
||||
- : req.connection.remoteAddress
|
||||
+ : req.connection && req.connection.remoteAddress
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/lib/MultiReporters.js b/lib/MultiReporters.js
|
||||
index d61e019711d5ac7f82c0fb90548bb0eb41ebbb85..e7a9515e05287621301b831191884a84d72ad0a1 100644
|
||||
--- a/lib/MultiReporters.js
|
||||
+++ b/lib/MultiReporters.js
|
||||
@@ -153,7 +153,7 @@ MultiReporters.prototype.getCustomOptions = function (options) {
|
||||
debug('options file (custom)', customOptionsFile);
|
||||
|
||||
try {
|
||||
- if ('.js' === path.extname(customOptionsFile)) {
|
||||
+ if (['.js', '.cjs'].includes(path.extname(customOptionsFile))) {
|
||||
customOptions = require(customOptionsFile);
|
||||
}
|
||||
else {
|
||||
13
.yarn/patches/multer-npm-2.1.1.patch
Normal file
13
.yarn/patches/multer-npm-2.1.1.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/lib/make-middleware.js b/lib/make-middleware.js
|
||||
index ee50988..de77364 100644
|
||||
--- a/lib/make-middleware.js
|
||||
+++ b/lib/make-middleware.js
|
||||
@@ -164,7 +164,7 @@ function makeMiddleware (setup) {
|
||||
if (fieldname == null) return abortWithCode('MISSING_FIELD_NAME')
|
||||
|
||||
// don't attach to the files object, if there is no file
|
||||
- if (!filename) return fileStream.resume()
|
||||
+ if (!filename) filename = 'undefined'
|
||||
|
||||
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
|
||||
if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNameSize')) {
|
||||
76
.yarn/patches/node-fetch-npm-2.7.0.patch
Normal file
76
.yarn/patches/node-fetch-npm-2.7.0.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
diff --git a/lib/index.js b/lib/index.js
|
||||
index 567ff5d..8eb45f7 100644
|
||||
--- a/lib/index.js
|
||||
+++ b/lib/index.js
|
||||
@@ -545,8 +545,8 @@ function clone(instance) {
|
||||
// tee instance body
|
||||
p1 = new PassThrough();
|
||||
p2 = new PassThrough();
|
||||
- body.pipe(p1);
|
||||
- body.pipe(p2);
|
||||
+ Stream.pipeline(body, p1, () => {});
|
||||
+ Stream.pipeline(body, p2, () => {});
|
||||
// set instance body to teed body and return the other teed body
|
||||
instance[INTERNALS].body = p1;
|
||||
body = p2;
|
||||
@@ -648,14 +648,14 @@ function writeToStream(dest, instance) {
|
||||
// body is null
|
||||
dest.end();
|
||||
} else if (isBlob(body)) {
|
||||
- body.stream().pipe(dest);
|
||||
+ Stream.pipeline(body.stream(), dest, () => {});
|
||||
} else if (Buffer.isBuffer(body)) {
|
||||
// body is buffer
|
||||
dest.write(body);
|
||||
dest.end();
|
||||
} else {
|
||||
// body is stream
|
||||
- body.pipe(dest);
|
||||
+ Stream.pipeline(body, dest, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1638,7 +1638,7 @@ function fetch(url, opts) {
|
||||
res.once('end', function () {
|
||||
if (signal) signal.removeEventListener('abort', abortAndFinalize);
|
||||
});
|
||||
- let body = res.pipe(new PassThrough$1());
|
||||
+ let body = Stream.pipeline(res, new PassThrough(), error => { if (error) reject(error); });
|
||||
|
||||
const response_options = {
|
||||
url: request.url,
|
||||
@@ -1679,7 +1679,7 @@ function fetch(url, opts) {
|
||||
|
||||
// for gzip
|
||||
if (codings == 'gzip' || codings == 'x-gzip') {
|
||||
- body = body.pipe(zlib.createGunzip(zlibOptions));
|
||||
+ body = Stream.pipeline(body, zlib.createGunzip(zlibOptions), error => { if (error) reject(error); });
|
||||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
return;
|
||||
@@ -1689,13 +1689,13 @@ function fetch(url, opts) {
|
||||
if (codings == 'deflate' || codings == 'x-deflate') {
|
||||
// handle the infamous raw deflate response from old servers
|
||||
// a hack for old IIS and Apache servers
|
||||
- const raw = res.pipe(new PassThrough$1());
|
||||
+ const raw = Stream.pipeline(res, new PassThrough(), error => { if (error) reject(error); });
|
||||
raw.once('data', function (chunk) {
|
||||
// see http://stackoverflow.com/questions/37519828
|
||||
if ((chunk[0] & 0x0F) === 0x08) {
|
||||
- body = body.pipe(zlib.createInflate());
|
||||
+ body = Stream.pipeline(body, zlib.createInflate(), error => { if (error) reject(error); });
|
||||
} else {
|
||||
- body = body.pipe(zlib.createInflateRaw());
|
||||
+ body = Stream.pipeline(body, zlib.createInflateRaw(), error => { if (error) reject(error); });
|
||||
}
|
||||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
@@ -1712,7 +1712,7 @@ function fetch(url, opts) {
|
||||
|
||||
// for br
|
||||
if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {
|
||||
- body = body.pipe(zlib.createBrotliDecompress());
|
||||
+ body = Stream.pipeline(body, zlib.createBrotliDecompress(), error => { if (error) reject(error); });
|
||||
response = new Response(body, response_options);
|
||||
resolve(response);
|
||||
return;
|
||||
13
.yarn/patches/passport-oauth2-npm-1.6.1.patch
Normal file
13
.yarn/patches/passport-oauth2-npm-1.6.1.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/lib/utils.js b/lib/utils.js
|
||||
index 486f9e1..4584507 100644
|
||||
--- a/lib/utils.js
|
||||
+++ b/lib/utils.js
|
||||
@@ -24,7 +24,7 @@ exports.originalURL = function(req, options) {
|
||||
var trustProxy = options.proxy;
|
||||
|
||||
var proto = (req.headers['x-forwarded-proto'] || '').toLowerCase()
|
||||
- , tls = req.connection.encrypted || (trustProxy && 'https' == proto.split(/\s*,\s*/)[0])
|
||||
+ , tls = (req.connection && req.connection.encrypted) || (trustProxy && 'https' == proto.split(/\s*,\s*/)[0])
|
||||
, host = (trustProxy && req.headers['x-forwarded-host']) || req.headers.host
|
||||
, protocol = tls ? 'https' : 'http'
|
||||
, path = req.url || '';
|
||||
22
.yarn/patches/pdfjs-dist-npm-5.1.91.patch
Normal file
22
.yarn/patches/pdfjs-dist-npm-5.1.91.patch
Normal file
@@ -0,0 +1,22 @@
|
||||
diff --git a/build/pdf.worker.mjs b/build/pdf.worker.mjs
|
||||
index 6c5c6f1..bb6b7d1 100644
|
||||
--- a/build/pdf.worker.mjs
|
||||
+++ b/build/pdf.worker.mjs
|
||||
@@ -1830,7 +1830,7 @@ async function __wbg_init(module_or_path) {
|
||||
}
|
||||
}
|
||||
if (typeof module_or_path === 'undefined') {
|
||||
- module_or_path = new URL('qcms_bg.wasm', import.meta.url);
|
||||
+ module_or_path = new URL(/* webpackIgnore: true */ 'qcms_bg.wasm', import.meta.url);
|
||||
}
|
||||
const imports = __wbg_get_imports();
|
||||
if (typeof module_or_path === 'string' || typeof Request === 'function' && module_or_path instanceof Request || typeof URL === 'function' && module_or_path instanceof URL) {
|
||||
@@ -5358,7 +5358,7 @@ var OpenJPEG = (() => {
|
||||
if (Module["locateFile"]) {
|
||||
return locateFile("openjpeg.wasm");
|
||||
}
|
||||
- return new URL("openjpeg.wasm", import.meta.url).href;
|
||||
+ return new URL(/* webpackIgnore: true */ "openjpeg.wasm", import.meta.url).href;
|
||||
}
|
||||
function getBinarySync(file) {
|
||||
if (file == wasmBinaryFile && wasmBinary) {
|
||||
1583
.yarn/patches/referer-parser-npm-0.0.3.patch
Normal file
1583
.yarn/patches/referer-parser-npm-0.0.3.patch
Normal file
File diff suppressed because it is too large
Load Diff
30
.yarn/patches/retry-request-npm-7.0.2-a41087680c.patch
Normal file
30
.yarn/patches/retry-request-npm-7.0.2-a41087680c.patch
Normal file
@@ -0,0 +1,30 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 2fae107d03b30aff9320d135ec79c049c51f298a..32ec707ddbf8937e3e130c3deac1060c308bf439 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
-const {PassThrough} = require('stream');
|
||||
+const {PassThrough, pipeline} = require('stream');
|
||||
const extend = require('extend');
|
||||
|
||||
let debug = () => {};
|
||||
@@ -185,7 +185,7 @@ function retryRequest(requestOpts, opts, callback) {
|
||||
.on('complete', (...params) => handleFinish(params))
|
||||
.on('finish', (...params) => handleFinish(params));
|
||||
|
||||
- requestStream.pipe(delayStream);
|
||||
+ pipeline(requestStream, delayStream, () => {});
|
||||
} else {
|
||||
activeRequest = opts.request(requestOpts, onResponse);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ function retryRequest(requestOpts, opts, callback) {
|
||||
// No more attempts need to be made, just continue on.
|
||||
if (streamMode) {
|
||||
retryStream.emit('response', response);
|
||||
- delayStream.pipe(retryStream);
|
||||
+ pipeline(delayStream, retryStream, () => {});
|
||||
requestStream.on('error', err => {
|
||||
retryStream.destroy(err);
|
||||
});
|
||||
30
.yarn/patches/retry-request-npm-8.0.2-448ad084c8.patch
Normal file
30
.yarn/patches/retry-request-npm-8.0.2-448ad084c8.patch
Normal file
@@ -0,0 +1,30 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 298a351097d70a7fb005b6961f4d58247e391d8f..6a809ace0349d40cb2b6732ad66fd8ad208698ca 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
-const {PassThrough} = require('stream');
|
||||
+const {PassThrough, pipeline} = require('stream');
|
||||
const extend = require('extend');
|
||||
|
||||
let debug = () => {};
|
||||
@@ -185,7 +185,7 @@ function retryRequest(requestOpts, opts, callback) {
|
||||
.on('complete', (...params) => handleFinish(params))
|
||||
.on('finish', (...params) => handleFinish(params));
|
||||
|
||||
- requestStream.pipe(delayStream);
|
||||
+ pipeline(requestStream, delayStream, () => {});
|
||||
} else {
|
||||
activeRequest = opts.request(requestOpts, onResponse);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ function retryRequest(requestOpts, opts, callback) {
|
||||
// No more attempts need to be made, just continue on.
|
||||
if (streamMode) {
|
||||
retryStream.emit('response', response);
|
||||
- delayStream.pipe(retryStream);
|
||||
+ pipeline(delayStream, retryStream, () => {});
|
||||
requestStream.on('error', err => {
|
||||
retryStream.destroy(err);
|
||||
});
|
||||
13
.yarn/patches/sandboxed-module-npm-2.0.4-f8b45aacc9.patch
Normal file
13
.yarn/patches/sandboxed-module-npm-2.0.4-f8b45aacc9.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/lib/sandboxed_module.js b/lib/sandboxed_module.js
|
||||
index 1cd6743fe221cbe91ea92fea3707ed07a8a2ded3..46889217d96d5534a206549ae7bd97100e41c3e4 100644
|
||||
--- a/lib/sandboxed_module.js
|
||||
+++ b/lib/sandboxed_module.js
|
||||
@@ -4,7 +4,7 @@ var Module = require('module');
|
||||
var fs = require('fs');
|
||||
var vm = require('vm');
|
||||
var path = require('path');
|
||||
-var builtinModules = require('./builtin_modules.json');
|
||||
+var builtinModules = Module.builtinModules || require('./builtin_modules.json');
|
||||
var parent = module.parent;
|
||||
var globalOptions = {};
|
||||
var registeredBuiltInSourceTransformers = ['coffee'];
|
||||
57
.yarn/patches/send-npm-0.19.0.patch
Normal file
57
.yarn/patches/send-npm-0.19.0.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 768f8ca..a882f4d 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -788,29 +788,29 @@ SendStream.prototype.stream = function stream (path, options) {
|
||||
// pipe
|
||||
var stream = fs.createReadStream(path, options)
|
||||
this.emit('stream', stream)
|
||||
- stream.pipe(res)
|
||||
-
|
||||
- // cleanup
|
||||
- function cleanup () {
|
||||
- destroy(stream, true)
|
||||
- }
|
||||
-
|
||||
- // response finished, cleanup
|
||||
- onFinished(res, cleanup)
|
||||
-
|
||||
- // error handling
|
||||
- stream.on('error', function onerror (err) {
|
||||
- // clean up stream early
|
||||
- cleanup()
|
||||
-
|
||||
- // error
|
||||
- self.onStatError(err)
|
||||
- })
|
||||
-
|
||||
- // end
|
||||
- stream.on('end', function onend () {
|
||||
- self.emit('end')
|
||||
- })
|
||||
+ Stream.pipeline(stream, res, err => { if (err) { self.onStatError(err) } else { self.emit('end') } })
|
||||
+
|
||||
+ // // cleanup
|
||||
+ // function cleanup () {
|
||||
+ // destroy(stream, true)
|
||||
+ // }
|
||||
+ //
|
||||
+ // // response finished, cleanup
|
||||
+ // onFinished(res, cleanup)
|
||||
+ //
|
||||
+ // // error handling
|
||||
+ // stream.on('error', function onerror (err) {
|
||||
+ // // clean up stream early
|
||||
+ // cleanup()
|
||||
+ //
|
||||
+ // // error
|
||||
+ // self.onStatError(err)
|
||||
+ // })
|
||||
+ //
|
||||
+ // // end
|
||||
+ // stream.on('end', function onend () {
|
||||
+ // self.emit('end')
|
||||
+ // })
|
||||
}
|
||||
|
||||
/**
|
||||
57
.yarn/patches/teeny-request-npm-10.1.0.patch
Normal file
57
.yarn/patches/teeny-request-npm-10.1.0.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
diff --git a/build/src/index.js b/build/src/index.js
|
||||
index a101736..a87f6b9 100644
|
||||
--- a/build/src/index.js
|
||||
+++ b/build/src/index.js
|
||||
@@ -130,6 +130,9 @@ function createMultipartStream(boundary, multipart) {
|
||||
}
|
||||
else {
|
||||
part.body.pipe(stream, { end: false });
|
||||
+ part.body.on('error', (err) => {
|
||||
+ stream.destroy(err);
|
||||
+ });
|
||||
part.body.on('end', () => {
|
||||
stream.write('\r\n');
|
||||
stream.write(finale);
|
||||
@@ -184,25 +187,25 @@ function teenyRequest(reqOpts, callback) {
|
||||
// Stream mode
|
||||
const requestStream = streamEvents(new stream_1.PassThrough());
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
- let responseStream;
|
||||
- requestStream.once('reading', () => {
|
||||
- if (responseStream) {
|
||||
- (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
- }
|
||||
- else {
|
||||
- requestStream.once('response', () => {
|
||||
- (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
- });
|
||||
- }
|
||||
- });
|
||||
+ // let responseStream;
|
||||
+ // requestStream.once('reading', () => {
|
||||
+ // if (responseStream) {
|
||||
+ // (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
+ // }
|
||||
+ // else {
|
||||
+ // requestStream.once('response', () => {
|
||||
+ // (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
+ // });
|
||||
+ // }
|
||||
+ // });
|
||||
options.compress = false;
|
||||
teenyRequest.stats.requestStarting();
|
||||
- fetch(uri, options).then(res => {
|
||||
+ (0, node_fetch_1.default)(uri, options).then(res => {
|
||||
- teenyRequest.stats.requestFinished();
|
||||
- responseStream = res.body;
|
||||
- responseStream.on('error', (err) => {
|
||||
- requestStream.emit('error', err);
|
||||
- });
|
||||
+ teenyRequest.stats.requestFinished(); (0, stream_1.pipeline)(res.body, requestStream, () => {});
|
||||
+ // responseStream = res.body;
|
||||
+ // responseStream.on('error', (err) => {
|
||||
+ // requestStream.emit('error', err);
|
||||
+ // });
|
||||
const response = fetchToRequestResponse(options, res);
|
||||
requestStream.emit('response', response);
|
||||
}, err => {
|
||||
58
.yarn/patches/teeny-request-npm-9.0.0-4d571e3c55.patch
Normal file
58
.yarn/patches/teeny-request-npm-9.0.0-4d571e3c55.patch
Normal file
@@ -0,0 +1,58 @@
|
||||
diff --git a/build/src/index.js b/build/src/index.js
|
||||
index af5d15e260e2a47588c7c536447fe84bd3f86136..2b63d0c0b1eb6595c7a0bb314c1df792454c1a72 100644
|
||||
--- a/build/src/index.js
|
||||
+++ b/build/src/index.js
|
||||
@@ -115,6 +115,9 @@ function createMultipartStream(boundary, multipart) {
|
||||
}
|
||||
else {
|
||||
part.body.pipe(stream, { end: false });
|
||||
+ part.body.on('error', (err) => {
|
||||
+ stream.destroy(err);
|
||||
+ });
|
||||
part.body.on('end', () => {
|
||||
stream.write('\r\n');
|
||||
stream.write(finale);
|
||||
@@ -168,25 +171,27 @@ function teenyRequest(reqOpts, callback) {
|
||||
// Stream mode
|
||||
const requestStream = streamEvents(new stream_1.PassThrough());
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
- let responseStream;
|
||||
- requestStream.once('reading', () => {
|
||||
- if (responseStream) {
|
||||
- (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
- }
|
||||
- else {
|
||||
- requestStream.once('response', () => {
|
||||
- (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
- });
|
||||
- }
|
||||
- });
|
||||
+ // let responseStream;
|
||||
+ // requestStream.once('reading', () => {
|
||||
+ // if (responseStream) {
|
||||
+ // (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
+ // }
|
||||
+ // else {
|
||||
+ // requestStream.once('response', () => {
|
||||
+ // (0, stream_1.pipeline)(responseStream, requestStream, () => { });
|
||||
+ // });
|
||||
+ // }
|
||||
+ // });
|
||||
+
|
||||
+
|
||||
options.compress = false;
|
||||
teenyRequest.stats.requestStarting();
|
||||
(0, node_fetch_1.default)(uri, options).then(res => {
|
||||
- teenyRequest.stats.requestFinished();
|
||||
- responseStream = res.body;
|
||||
- responseStream.on('error', (err) => {
|
||||
- requestStream.emit('error', err);
|
||||
- });
|
||||
+ teenyRequest.stats.requestFinished(); stream_1.pipeline(res.body, requestStream, () => {});
|
||||
+ // responseStream = res.body;
|
||||
+ // responseStream.on('error', (err) => {
|
||||
+ // requestStream.emit('error', err);
|
||||
+ // });
|
||||
const response = fetchToRequestResponse(options, res);
|
||||
requestStream.emit('response', response);
|
||||
}, err => {
|
||||
81
.yarn/patches/thread-loader-npm-4.0.2-dab5735f54.patch
Normal file
81
.yarn/patches/thread-loader-npm-4.0.2-dab5735f54.patch
Normal file
@@ -0,0 +1,81 @@
|
||||
diff --git a/dist/WorkerPool.js b/dist/WorkerPool.js
|
||||
index 4145779f08eefafd0c18394806b6409c595ac5bb..aa16dd6a0f463804455164493a1e75e80cdf656a 100644
|
||||
--- a/dist/WorkerPool.js
|
||||
+++ b/dist/WorkerPool.js
|
||||
@@ -258,6 +258,19 @@ class PoolWorker {
|
||||
finalCallback();
|
||||
break;
|
||||
}
|
||||
+ case 'logMessage':
|
||||
+ {
|
||||
+ const {
|
||||
+ data: { loggerName, methodName, args }
|
||||
+ } = message;
|
||||
+ const {
|
||||
+ data: jobData
|
||||
+ } = this.jobs[id];
|
||||
+ const logger = jobData.getLogger(loggerName);
|
||||
+ logger[methodName].apply(logger, args);
|
||||
+ finalCallback();
|
||||
+ break;
|
||||
+ }
|
||||
case 'emitWarning':
|
||||
{
|
||||
const {
|
||||
diff --git a/dist/index.js b/dist/index.js
|
||||
index 75cd30fb63dc864057c1afc866f43fc7cc0a8020..d834af6ce1e2cd4473c4ae1b325d63eb1190c17e 100644
|
||||
--- a/dist/index.js
|
||||
+++ b/dist/index.js
|
||||
@@ -43,6 +43,7 @@ function pitch() {
|
||||
sourceMap: this.sourceMap,
|
||||
emitError: this.emitError,
|
||||
emitWarning: this.emitWarning,
|
||||
+ getLogger: this.getLogger,
|
||||
loadModule: this.loadModule,
|
||||
resolve: this.resolve,
|
||||
getResolve: this.getResolve,
|
||||
diff --git a/dist/worker.js b/dist/worker.js
|
||||
index 8e67959e4b7c9fd0db116509b1459636ba13a097..aca94f1442906baf179ada8e6a56501bbf71c480 100644
|
||||
--- a/dist/worker.js
|
||||
+++ b/dist/worker.js
|
||||
@@ -90,6 +90,22 @@ function writeJson(data) {
|
||||
writePipeWrite(lengthBuffer);
|
||||
writePipeWrite(messageBuffer);
|
||||
}
|
||||
+const LOGGER_METHODS = ['error', 'warn', 'info', 'log', 'debug', 'trace', 'group', 'groupEnd', 'groupCollapsed', 'status', 'clear', 'profile', 'profileEnd'];
|
||||
+class Logger {
|
||||
+ constructor(id, loggerName) {
|
||||
+ this.id = id
|
||||
+ this.loggerName = loggerName
|
||||
+ for (const methodName of LOGGER_METHODS) {
|
||||
+ this[methodName] = (...args) => {
|
||||
+ writeJson({
|
||||
+ type: 'logMessage',
|
||||
+ id: this.id,
|
||||
+ data: { loggerName, methodName, args }
|
||||
+ })
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
const queue = (0, _queue.default)(({
|
||||
id,
|
||||
data
|
||||
@@ -190,6 +206,7 @@ const queue = (0, _queue.default)(({
|
||||
}
|
||||
return options;
|
||||
},
|
||||
+ getLogger: (name) => new Logger(id, name),
|
||||
emitWarning: warning => {
|
||||
writeJson({
|
||||
type: 'emitWarning',
|
||||
@@ -211,6 +228,9 @@ const queue = (0, _queue.default)(({
|
||||
module._compile(code, filename); // eslint-disable-line no-underscore-dangle
|
||||
return module.exports;
|
||||
},
|
||||
+ addDependency: filename => {
|
||||
+ buildDependencies.push(filename);
|
||||
+ },
|
||||
addBuildDependency: filename => {
|
||||
buildDependencies.push(filename);
|
||||
},
|
||||
Reference in New Issue
Block a user