WritingSpace/.obsidian/plugins/harper/main.js

2728 lines
2.3 MiB
JavaScript
Raw Normal View History

2025-02-02 10:51:46 +00:00
'use strict';
var obsidian = require('obsidian');
var view = require('@codemirror/view');
var state = require('@codemirror/state');
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
var logoSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 695 411\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:space=\"preserve\" xmlns:serif=\"http://www.serif.com/\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;\" fill=\"#ffffff\" stroke=\"currentColor\">\n <g transform=\"matrix(1,0,0,1,-5,-1720)\">\n <g id=\"Artboard1\" transform=\"matrix(0.824576,0,0,0.749254,0.365685,430.856)\">\n <rect x=\"5.62\" y=\"1720.57\" width=\"842.425\" height=\"547.24\" style=\"fill:none;\"/>\n <g transform=\"matrix(1.21274,0,0,1.33466,-2183.71,393.157)\">\n <g transform=\"matrix(1,0,0,1,-22.3927,1.08043)\">\n <path d=\"M1930.93,1121.75C1930.93,1121.75 1974.66,1080.73 2041.34,1094.1C2086.61,1103.18 2122.83,1145.4 2122.83,1145.4\" style=\"fill:none;stroke-width:22.92px;\"/>\n </g>\n <g transform=\"matrix(1,0,0,1,-47.3485,12.3935)\">\n <path d=\"M2250.3,1107.1C2250.3,1107.1 2261.8,1065.58 2311.59,1047.05C2361.62,1028.44 2422.42,1051.13 2422.42,1051.13\" style=\"fill:none;stroke-width:22.92px;\"/>\n </g>\n <g transform=\"matrix(1.10085,0,0,1.10085,-212.096,-122.054)\">\n <g transform=\"matrix(1,0,0,1,14.3186,-0.853887)\">\n <ellipse cx=\"1981.62\" cy=\"1247.49\" rx=\"87.401\" ry=\"87.881\" style=\"fill:none;stroke-width:20.82px;\"/>\n </g>\n <rect x=\"2083.34\" y=\"1231.11\" width=\"66.702\" height=\"15.521\" style=\"fill:none;stroke-width:20.82px;\"/>\n <rect x=\"1892.23\" y=\"1208.69\" width=\"16.306\" height=\"30.182\" style=\"fill:none;stroke-width:20.82px;\"/>\n <g transform=\"matrix(-1,0,0,1,4281.79,-0.853887)\">\n <ellipse cx=\"1981.62\" cy=\"1247.49\" rx=\"87.401\" ry=\"87.881\" style=\"fill:none;stroke-width:20.82px;\"/>\n </g>\n <g transform=\"matrix(-1,0,0,1,4296.11,0)\">\n <rect x=\"2083.34\" y=\"1231.11\" width=\"66.702\" height=\"15.521\" style=\"fill:none;stroke-width:20.82px;\"/>\n </g>\n <g transform=\"matrix(-1,0,0,1,4296.11,0)\">\n <rect x=\"1892.23\" y=\"1208.69\" width=\"16.306\" height=\"30.182\" style=\"fill:none;stroke-width:20.82px;\"/>\n </g>\n </g>\n </g>\n </g>\n </g>\n</svg>\n";
var $ = Object.defineProperty;
var AA = (Q, A, C) => A in Q ? $(Q, A, { enumerable: !0, configurable: !0, writable: !0, value: C }) : Q[A] = C;
var i = (Q, A, C) => AA(Q, typeof A != "symbol" ? A + "" : A, C);
let I;
const Y = new Array(128).fill(void 0);
Y.push(void 0, null, !0, !1);
function R(Q) {
return Y[Q];
}
let b = 0, y = null;
function k() {
return (y === null || y.byteLength === 0) && (y = new Uint8Array(I.memory.buffer)), y;
}
const J = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => {
throw Error("TextEncoder not available");
} }, CA = typeof J.encodeInto == "function" ? function(Q, A) {
return J.encodeInto(Q, A);
} : function(Q, A) {
const C = J.encode(Q);
return A.set(C), {
read: Q.length,
written: C.length
};
};
function p(Q, A, C) {
if (C === void 0) {
const F = J.encode(Q), U = A(F.length, 1) >>> 0;
return k().subarray(U, U + F.length).set(F), b = F.length, U;
}
let B = Q.length, g = A(B, 1) >>> 0;
const E = k();
let G = 0;
for (; G < B; G++) {
const F = Q.charCodeAt(G);
if (F > 127) break;
E[g + G] = F;
}
if (G !== B) {
G !== 0 && (Q = Q.slice(G)), g = C(g, B, B = G + Q.length * 3, 1) >>> 0;
const F = k().subarray(g + G, g + B), U = CA(Q, F);
G += U.written, g = C(g, B, G, 1) >>> 0;
}
return b = G, g;
}
let M = null;
function N() {
return (M === null || M.buffer.detached === !0 || M.buffer.detached === void 0 && M.buffer !== I.memory.buffer) && (M = new DataView(I.memory.buffer)), M;
}
let K = Y.length;
function V(Q) {
K === Y.length && Y.push(Y.length + 1);
const A = K;
return K = Y[A], Y[A] = Q, A;
}
const n = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }) : { decode: () => {
throw Error("TextDecoder not available");
} };
typeof TextDecoder < "u" && n.decode();
function c(Q, A) {
return Q = Q >>> 0, n.decode(k().subarray(Q, Q + A));
}
function QA(Q, A) {
try {
return Q.apply(this, A);
} catch (C) {
I.__wbindgen_export_3(V(C));
}
}
function IA(Q) {
Q < 132 || (Y[Q] = K, K = Q);
}
function w(Q) {
const A = R(Q);
return IA(Q), A;
}
function z(Q) {
const A = typeof Q;
if (A == "number" || A == "boolean" || Q == null)
return `${Q}`;
if (A == "string")
return `"${Q}"`;
if (A == "symbol") {
const g = Q.description;
return g == null ? "Symbol" : `Symbol(${g})`;
}
if (A == "function") {
const g = Q.name;
return typeof g == "string" && g.length > 0 ? `Function(${g})` : "Function";
}
if (Array.isArray(Q)) {
const g = Q.length;
let E = "[";
g > 0 && (E += z(Q[0]));
for (let G = 1; G < g; G++)
E += ", " + z(Q[G]);
return E += "]", E;
}
const C = /\[object ([^\]]+)\]/.exec(toString.call(Q));
let B;
if (C && C.length > 1)
B = C[1];
else
return toString.call(Q);
if (B == "Object")
try {
return "Object(" + JSON.stringify(Q) + ")";
} catch {
return "Object";
}
return Q instanceof Error ? `${Q.name}: ${Q.message}
${Q.stack}` : B;
}
function v(Q) {
return Q == null;
}
function BA() {
I.setup();
}
function o(Q, A) {
if (!(Q instanceof A))
throw new Error(`expected instance of ${A.name}`);
}
function u(Q, A) {
Q = Q >>> 0;
const C = N(), B = [];
for (let g = Q; g < Q + 4 * A; g += 4)
B.push(w(C.getUint32(g, !0)));
return B;
}
function gA(Q) {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16), G = p(Q, I.__wbindgen_export_0, I.__wbindgen_export_1), F = b;
I.to_title_case(E, G, F);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
function EA(Q, A, C) {
let B, g;
try {
const h = I.__wbindgen_add_to_stack_pointer(-16), P = p(Q, I.__wbindgen_export_0, I.__wbindgen_export_1), _ = b;
o(A, Z);
var E = A.__destroy_into_raw();
o(C, D), I.apply_suggestion(h, P, _, E, C.__wbg_ptr);
var G = N().getInt32(h + 4 * 0, !0), F = N().getInt32(h + 4 * 1, !0), U = N().getInt32(h + 4 * 2, !0), a = N().getInt32(h + 4 * 3, !0), W = G, d = F;
if (a)
throw W = 0, d = 0, w(U);
return B = W, g = d, c(W, d);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(B, g, 1);
}
}
function NA() {
let Q, A;
try {
const g = I.__wbindgen_add_to_stack_pointer(-16);
I.get_default_lint_config_as_json(g);
var C = N().getInt32(g + 4 * 0, !0), B = N().getInt32(g + 4 * 1, !0);
return Q = C, A = B, c(C, B);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(Q, A, 1);
}
}
function GA() {
const Q = I.get_default_lint_config();
return w(Q);
}
const L = Object.freeze({
Plain: 0,
0: "Plain",
Markdown: 1,
1: "Markdown"
}), FA = Object.freeze({
/**
* Replace the problematic text.
*/
Replace: 0,
0: "Replace",
/**
* Remove the problematic text.
*/
Remove: 1,
1: "Remove",
/**
* Insert additional text after the error.
*/
InsertAfter: 2,
2: "InsertAfter"
}), s = typeof FinalizationRegistry > "u" ? { register: () => {
}, unregister: () => {
} } : new FinalizationRegistry((Q) => I.__wbg_lint_free(Q >>> 0, 1));
class m {
static __wrap(A) {
A = A >>> 0;
const C = Object.create(m.prototype);
return C.__wbg_ptr = A, s.register(C, C.__wbg_ptr, C), C;
}
__destroy_into_raw() {
const A = this.__wbg_ptr;
return this.__wbg_ptr = 0, s.unregister(this), A;
}
free() {
const A = this.__destroy_into_raw();
I.__wbg_lint_free(A, 0);
}
/**
* @returns {string}
*/
to_json() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.lint_to_json(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* @param {string} json
* @returns {Lint}
*/
static from_json(A) {
try {
const E = I.__wbindgen_add_to_stack_pointer(-16), G = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), F = b;
I.lint_from_json(E, G, F);
var C = N().getInt32(E + 4 * 0, !0), B = N().getInt32(E + 4 * 1, !0), g = N().getInt32(E + 4 * 2, !0);
if (g)
throw w(B);
return m.__wrap(C);
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the content of the source material pointed to by [`Self::span`]
* @returns {string}
*/
get_problem_text() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.lint_get_problem_text(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* Get a string representing the general category of the lint.
* @returns {string}
*/
lint_kind() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.lint_lint_kind(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* Get a string representing the general category of the lint.
* @returns {string}
*/
lint_kind_pretty() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.lint_lint_kind_pretty(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* Equivalent to calling `.length` on the result of `suggestions()`.
* @returns {number}
*/
suggestion_count() {
return I.lint_suggestion_count(this.__wbg_ptr) >>> 0;
}
/**
* Get an array of any suggestions that may resolve the issue.
* @returns {Suggestion[]}
*/
suggestions() {
try {
const g = I.__wbindgen_add_to_stack_pointer(-16);
I.lint_suggestions(g, this.__wbg_ptr);
var A = N().getInt32(g + 4 * 0, !0), C = N().getInt32(g + 4 * 1, !0), B = u(A, C).slice();
return I.__wbindgen_export_2(A, C * 4, 4), B;
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the location of the problematic text.
* @returns {Span}
*/
span() {
const A = I.lint_span(this.__wbg_ptr);
return Z.__wrap(A);
}
/**
* Get a description of the error.
* @returns {string}
*/
message() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.lint_message(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
}
const S = typeof FinalizationRegistry > "u" ? { register: () => {
}, unregister: () => {
} } : new FinalizationRegistry((Q) => I.__wbg_linter_free(Q >>> 0, 1));
class T {
static __wrap(A) {
A = A >>> 0;
const C = Object.create(T.prototype);
return C.__wbg_ptr = A, S.register(C, C.__wbg_ptr, C), C;
}
__destroy_into_raw() {
const A = this.__wbg_ptr;
return this.__wbg_ptr = 0, S.unregister(this), A;
}
free() {
const A = this.__destroy_into_raw();
I.__wbg_linter_free(A, 0);
}
/**
* Construct a new `Linter`.
* Note that this can mean constructing the curated dictionary, which is the most expensive operation
* in Harper.
* @returns {Linter}
*/
static new() {
const A = I.linter_new();
return T.__wrap(A);
}
/**
* Helper method to quickly check if a plain string is likely intended to be English
* @param {string} text
* @returns {boolean}
*/
is_likely_english(A) {
const C = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), B = b;
return I.linter_is_likely_english(this.__wbg_ptr, C, B) !== 0;
}
/**
* Helper method to remove non-English text from a plain English document.
* @param {string} text
* @returns {string}
*/
isolate_english(A) {
let C, B;
try {
const G = I.__wbindgen_add_to_stack_pointer(-16), F = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), U = b;
I.linter_isolate_english(G, this.__wbg_ptr, F, U);
var g = N().getInt32(G + 4 * 0, !0), E = N().getInt32(G + 4 * 1, !0);
return C = g, B = E, c(g, E);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(C, B, 1);
}
}
/**
* Get a JSON map containing the descriptions of all the linting rules.
* @returns {string}
*/
get_lint_descriptions_as_json() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.linter_get_lint_descriptions_as_json(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* @returns {string}
*/
get_lint_config_as_json() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.linter_get_lint_config_as_json(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* @param {string} json
*/
set_lint_config_from_json(A) {
try {
const g = I.__wbindgen_add_to_stack_pointer(-16), E = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), G = b;
I.linter_set_lint_config_from_json(g, this.__wbg_ptr, E, G);
var C = N().getInt32(g + 4 * 0, !0), B = N().getInt32(g + 4 * 1, !0);
if (B)
throw w(C);
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get a Record containing the descriptions of all the linting rules.
* @returns {any}
*/
get_lint_descriptions_as_object() {
const A = I.linter_get_lint_descriptions_as_object(this.__wbg_ptr);
return w(A);
}
/**
* @returns {any}
*/
get_lint_config_as_object() {
const A = I.linter_get_lint_config_as_object(this.__wbg_ptr);
return w(A);
}
/**
* @param {any} object
*/
set_lint_config_from_object(A) {
try {
const g = I.__wbindgen_add_to_stack_pointer(-16);
I.linter_set_lint_config_from_object(g, this.__wbg_ptr, V(A));
var C = N().getInt32(g + 4 * 0, !0), B = N().getInt32(g + 4 * 1, !0);
if (B)
throw w(C);
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @param {Lint} lint
*/
ignore_lint(A) {
o(A, m);
var C = A.__destroy_into_raw();
I.linter_ignore_lint(this.__wbg_ptr, C);
}
/**
* Perform the configured linting on the provided text.
* @param {string} text
* @param {Language} language
* @returns {Lint[]}
*/
lint(A, C) {
try {
const G = I.__wbindgen_add_to_stack_pointer(-16), F = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), U = b;
I.linter_lint(G, this.__wbg_ptr, F, U, C);
var B = N().getInt32(G + 4 * 0, !0), g = N().getInt32(G + 4 * 1, !0), E = u(B, g).slice();
return I.__wbindgen_export_2(B, g * 4, 4), E;
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Export the linter's ignored lints as a privacy-respecting JSON list of hashes.
* @returns {string}
*/
export_ignored_lints() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.linter_export_ignored_lints(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* Import into the linter's ignored lints from a privacy-respecting JSON list of hashes.
* @param {string} json
*/
import_ignored_lints(A) {
try {
const g = I.__wbindgen_add_to_stack_pointer(-16), E = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), G = b;
I.linter_import_ignored_lints(g, this.__wbg_ptr, E, G);
var C = N().getInt32(g + 4 * 0, !0), B = N().getInt32(g + 4 * 1, !0);
if (B)
throw w(C);
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
clear_ignored_lints() {
I.linter_clear_ignored_lints(this.__wbg_ptr);
}
}
const x = typeof FinalizationRegistry > "u" ? { register: () => {
}, unregister: () => {
} } : new FinalizationRegistry((Q) => I.__wbg_span_free(Q >>> 0, 1));
class Z {
static __wrap(A) {
A = A >>> 0;
const C = Object.create(Z.prototype);
return C.__wbg_ptr = A, x.register(C, C.__wbg_ptr, C), C;
}
__destroy_into_raw() {
const A = this.__wbg_ptr;
return this.__wbg_ptr = 0, x.unregister(this), A;
}
free() {
const A = this.__destroy_into_raw();
I.__wbg_span_free(A, 0);
}
/**
* @returns {string}
*/
to_json() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.span_to_json(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* @param {string} json
* @returns {Span}
*/
static from_json(A) {
try {
const E = I.__wbindgen_add_to_stack_pointer(-16), G = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), F = b;
I.span_from_json(E, G, F);
var C = N().getInt32(E + 4 * 0, !0), B = N().getInt32(E + 4 * 1, !0), g = N().getInt32(E + 4 * 2, !0);
if (g)
throw w(B);
return Z.__wrap(C);
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {number}
*/
get start() {
return I.__wbg_get_span_start(this.__wbg_ptr) >>> 0;
}
/**
* @param {number} arg0
*/
set start(A) {
I.__wbg_set_span_start(this.__wbg_ptr, A);
}
/**
* @returns {number}
*/
get end() {
return I.__wbg_get_span_end(this.__wbg_ptr) >>> 0;
}
/**
* @param {number} arg0
*/
set end(A) {
I.__wbg_set_span_end(this.__wbg_ptr, A);
}
/**
* @param {number} start
* @param {number} end
* @returns {Span}
*/
static new(A, C) {
const B = I.span_new(A, C);
return Z.__wrap(B);
}
/**
* @returns {boolean}
*/
is_empty() {
return I.span_is_empty(this.__wbg_ptr) !== 0;
}
/**
* @returns {number}
*/
len() {
return I.span_len(this.__wbg_ptr) >>> 0;
}
}
const X = typeof FinalizationRegistry > "u" ? { register: () => {
}, unregister: () => {
} } : new FinalizationRegistry((Q) => I.__wbg_suggestion_free(Q >>> 0, 1));
class D {
static __wrap(A) {
A = A >>> 0;
const C = Object.create(D.prototype);
return C.__wbg_ptr = A, X.register(C, C.__wbg_ptr, C), C;
}
__destroy_into_raw() {
const A = this.__wbg_ptr;
return this.__wbg_ptr = 0, X.unregister(this), A;
}
free() {
const A = this.__destroy_into_raw();
I.__wbg_suggestion_free(A, 0);
}
/**
* @returns {string}
*/
to_json() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.suggestion_to_json(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* @param {string} json
* @returns {Suggestion}
*/
static from_json(A) {
try {
const E = I.__wbindgen_add_to_stack_pointer(-16), G = p(A, I.__wbindgen_export_0, I.__wbindgen_export_1), F = b;
I.suggestion_from_json(E, G, F);
var C = N().getInt32(E + 4 * 0, !0), B = N().getInt32(E + 4 * 1, !0), g = N().getInt32(E + 4 * 2, !0);
if (g)
throw w(B);
return D.__wrap(C);
} finally {
I.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Get the text that is going to replace the problematic section.
* If [`Self::kind`] is `SuggestionKind::Remove`, this will return an empty
* string.
* @returns {string}
*/
get_replacement_text() {
let A, C;
try {
const E = I.__wbindgen_add_to_stack_pointer(-16);
I.suggestion_get_replacement_text(E, this.__wbg_ptr);
var B = N().getInt32(E + 4 * 0, !0), g = N().getInt32(E + 4 * 1, !0);
return A = B, C = g, c(B, g);
} finally {
I.__wbindgen_add_to_stack_pointer(16), I.__wbindgen_export_2(A, C, 1);
}
}
/**
* @returns {SuggestionKind}
*/
kind() {
return I.suggestion_kind(this.__wbg_ptr);
}
}
async function cA(Q, A) {
if (typeof Response == "function" && Q instanceof Response) {
if (typeof WebAssembly.instantiateStreaming == "function")
try {
return await WebAssembly.instantiateStreaming(Q, A);
} catch (B) {
if (Q.headers.get("Content-Type") != "application/wasm")
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", B);
else
throw B;
}
const C = await Q.arrayBuffer();
return await WebAssembly.instantiate(C, A);
} else {
const C = await WebAssembly.instantiate(Q, A);
return C instanceof WebAssembly.Instance ? { instance: C, module: Q } : C;
}
}
function q() {
const Q = {};
return Q.wbg = {}, Q.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(A, C) {
const B = String(R(C)), g = p(B, I.__wbindgen_export_0, I.__wbindgen_export_1), E = b;
N().setInt32(A + 4 * 1, E, !0), N().setInt32(A + 4 * 0, g, !0);
}, Q.wbg.__wbg_buffer_609cc3eee51ed158 = function(A) {
const C = R(A).buffer;
return V(C);
}, Q.wbg.__wbg_error_7534b8e9a36f1ab4 = function(A, C) {
let B, g;
try {
B = A, g = C, console.error(c(A, C));
} finally {
I.__wbindgen_export_2(B, g, 1);
}
}, Q.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(A, C) {
const B = R(A)[R(C)];
return V(B);
}, Q.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(A) {
let C;
try {
C = R(A) instanceof ArrayBuffer;
} catch {
C = !1;
}
return C;
}, Q.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(A) {
let C;
try {
C = R(A) instanceof Uint8Array;
} catch {
C = !1;
}
return C;
}, Q.wbg.__wbg_length_a446193dc22c12f8 = function(A) {
return R(A).length;
}, Q.wbg.__wbg_lint_new = function(A) {
const C = m.__wrap(A);
return V(C);
}, Q.wbg.__wbg_log_0cc1b7768397bcfe = function(A, C, B, g, E, G, F, U) {
let a, W;
try {
a = A, W = C, console.log(c(A, C), c(B, g), c(E, G), c(F, U));
} finally {
I.__wbindgen_export_2(a, W, 1);
}
}, Q.wbg.__wbg_log_cb9e190acc5753fb = function(A, C) {
let B, g;
try {
B = A, g = C, console.log(c(A, C));
} finally {
I.__wbindgen_export_2(B, g, 1);
}
}, Q.wbg.__wbg_mark_7438147ce31e9d4b = function(A, C) {
performance.mark(c(A, C));
}, Q.wbg.__wbg_measure_fb7825c11612c823 = function() {
return QA(function(A, C, B, g) {
let E, G, F, U;
try {
E = A, G = C, F = B, U = g, performance.measure(c(A, C), c(B, g));
} finally {
I.__wbindgen_export_2(E, G, 1), I.__wbindgen_export_2(F, U, 1);
}
}, arguments);
}, Q.wbg.__wbg_new_405e22f390576ce2 = function() {
const A = new Object();
return V(A);
}, Q.wbg.__wbg_new_8a6f238a6ece86ea = function() {
const A = new Error();
return V(A);
}, Q.wbg.__wbg_new_a12002a7f91c75be = function(A) {
const C = new Uint8Array(R(A));
return V(C);
}, Q.wbg.__wbg_set_3f1d0b984ed272ed = function(A, C, B) {
R(A)[w(C)] = w(B);
}, Q.wbg.__wbg_set_65595bdd868b3009 = function(A, C, B) {
R(A).set(R(C), B >>> 0);
}, Q.wbg.__wbg_stack_0ed75d68575b0f3c = function(A, C) {
const B = R(C).stack, g = p(B, I.__wbindgen_export_0, I.__wbindgen_export_1), E = b;
N().setInt32(A + 4 * 1, E, !0), N().setInt32(A + 4 * 0, g, !0);
}, Q.wbg.__wbg_suggestion_new = function(A) {
const C = D.__wrap(A);
return V(C);
}, Q.wbg.__wbindgen_boolean_get = function(A) {
const C = R(A);
return typeof C == "boolean" ? C ? 1 : 0 : 2;
}, Q.wbg.__wbindgen_debug_string = function(A, C) {
const B = z(R(C)), g = p(B, I.__wbindgen_export_0, I.__wbindgen_export_1), E = b;
N().setInt32(A + 4 * 1, E, !0), N().setInt32(A + 4 * 0, g, !0);
}, Q.wbg.__wbindgen_error_new = function(A, C) {
const B = new Error(c(A, C));
return V(B);
}, Q.wbg.__wbindgen_in = function(A, C) {
return R(A) in R(C);
}, Q.wbg.__wbindgen_is_object = function(A) {
const C = R(A);
return typeof C == "object" && C !== null;
}, Q.wbg.__wbindgen_is_undefined = function(A) {
return R(A) === void 0;
}, Q.wbg.__wbindgen_jsval_loose_eq = function(A, C) {
return R(A) == R(C);
}, Q.wbg.__wbindgen_memory = function() {
const A = I.memory;
return V(A);
}, Q.wbg.__wbindgen_number_get = function(A, C) {
const B = R(C), g = typeof B == "number" ? B : void 0;
N().setFloat64(A + 8 * 1, v(g) ? 0 : g, !0), N().setInt32(A + 4 * 0, !v(g), !0);
}, Q.wbg.__wbindgen_object_clone_ref = function(A) {
const C = R(A);
return V(C);
}, Q.wbg.__wbindgen_object_drop_ref = function(A) {
w(A);
}, Q.wbg.__wbindgen_string_get = function(A, C) {
const B = R(C), g = typeof B == "string" ? B : void 0;
var E = v(g) ? 0 : p(g, I.__wbindgen_export_0, I.__wbindgen_export_1), G = b;
N().setInt32(A + 4 * 1, G, !0), N().setInt32(A + 4 * 0, E, !0);
}, Q.wbg.__wbindgen_string_new = function(A, C) {
const B = c(A, C);
return V(B);
}, Q.wbg.__wbindgen_throw = function(A, C) {
throw new Error(c(A, C));
}, Q;
}
function t(Q, A) {
return I = Q.exports, j.__wbindgen_wasm_module = A, M = null, y = null, I.__wbindgen_start(), I;
}
function RA(Q) {
if (I !== void 0) return I;
typeof Q < "u" && (Object.getPrototypeOf(Q) === Object.prototype ? { module: Q } = Q : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
const A = q();
Q instanceof WebAssembly.Module || (Q = new WebAssembly.Module(Q));
const C = new WebAssembly.Instance(Q, A);
return t(C, Q);
}
async function j(Q) {
if (I !== void 0) return I;
typeof Q < "u" && (Object.getPrototypeOf(Q) === Object.prototype ? { module_or_path: Q } = Q : console.warn("using deprecated parameters for the initialization function; pass a single object instead")), typeof Q > "u" && (Q = new URL());
const A = q();
(typeof Q == "string" || typeof Request == "function" && Q instanceof Request || typeof URL == "function" && Q instanceof URL) && (Q = fetch(Q));
const { instance: C, module: B } = await cA(await Q, A);
return t(C, B);
}
const UA = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
Language: L,
Lint: m,
Linter: T,
Span: Z,
Suggestion: D,
SuggestionKind: FA,
apply_suggestion: EA,
default: j,
get_default_lint_config: GA,
get_default_lint_config_as_json: NA,
initSync: RA,
setup: BA,
to_title_case: gA
}, Symbol.toStringTag, { value: "Module" })), bA = "data:application/wasm;base64,AGFzbQEAAAAB7gIxYAJ/fwF/YAJ/fwBgAX8AYAN/f38Bf2ADf39/AGAFf39/f38Bf2ABfwF/YAR/f39/AGAFf39/f38AYAR/f39/AX9gBn9/f39/fwBgAAF/YAAAYAJ/fwF+YAJ/fgBgA39/fwF+YAd/f39/f39/AX9gAn9+AX9gA35+fwF+YAV/f39+fwBgA39/fgBgBH9/fn4AYAZ/f39/f38Bf2AHf39/f39/fwBgCH9/f39/f39/AGAEf3x/fwF/YAV/fn9/fwBgB39/fn5+fn4BfmADfn9/AGADf35/AX9gBH5+f38Bf2ADf35+AGACfn8AYAl/f39/f39+fn4AYAN+f38Bf2AJf39/f39/f39/AX9gBX9/fn5+AX5gC39/f39/f39/f39/AX9gBH9+fn4AYAN/fn8AYAR/fn5/AGAAAX5gA39/fABgBX9/fn9/AGAEf35/fwBgBX9/fX9/AGAEf31/fwBgBX9/fH9/AGAEf3x/fwACrAghA3diZxdfX3diaW5kZ2VuX2lzX3VuZGVm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cG9ydF9pZ25vcmVkX2xpbnRzAIMDGmxpbnRlcl9jbGVhcl9pZ25vcmVkX2xpbnRzAIEDDXRvX3RpdGxlX2Nhc2UA4wMQYXBwbHlfc3VnZ2VzdGlvbgD+ARVfX3diZ19zdWdnZXN0aW9uX2ZyZWUArQMfc3VnZ2VzdGlvbl9nZXRfcmVwbGFjZW1lbnRfdGV4dAD8Ag9zdWdnZXN0aW9uX2tpbmQAsQQPX1
let pA = bA;
function e() {
return pA;
}
async function l() {
const Q = await Promise.resolve().then(() => UA);
return await Q.default({ module_or_path: e() }), Q;
}
class lA {
constructor() {
i(this, "inner");
}
/** Initialize the WebAssembly and construct the inner Linter. */
async initialize() {
if (!this.inner) {
const A = await l();
A.setup(), this.inner = A.Linter.new();
}
}
async setup() {
await this.initialize(), this.inner.lint("", L.Plain);
}
async lint(A, C) {
return await this.initialize(), this.inner.lint(
A,
(C == null ? void 0 : C.language) === "plaintext" ? L.Plain : L.Markdown
);
}
async applySuggestion(A, C, B) {
return (await l()).apply_suggestion(A, B, C);
}
async isLikelyEnglish(A) {
return await this.initialize(), this.inner.is_likely_english(A);
}
async isolateEnglish(A) {
return await this.initialize(), this.inner.isolate_english(A);
}
async getLintConfig() {
return await this.initialize(), this.inner.get_lint_config_as_object();
}
async getDefaultLintConfigAsJSON() {
return (await l()).get_default_lint_config_as_json();
}
async getDefaultLintConfig() {
return (await l()).get_default_lint_config();
}
async setLintConfig(A) {
await this.initialize(), this.inner.set_lint_config_from_object(A);
}
async getLintConfigAsJSON() {
return await this.initialize(), this.inner.get_lint_config_as_json();
}
async setLintConfigWithJSON(A) {
await this.initialize(), this.inner.set_lint_config_from_json(A);
}
async toTitleCase(A) {
return (await l()).to_title_case(A);
}
async getLintDescriptions() {
return await this.initialize(), this.inner.get_lint_descriptions_as_object();
}
async getLintDescriptionsAsJSON() {
return await this.initialize(), this.inner.get_lint_descriptions_as_json();
}
async ignoreLint(A) {
await this.initialize(), this.inner.ignore_lint(A);
}
async exportIgnoredLints() {
return await this.initialize(), this.inner.export_ignored_lints();
}
async importIgnoredLints(A) {
return await this.initialize(), this.inner.import_ignored_lints(A);
}
async clearIgnoredLints() {
return await this.initialize(), this.inner.clear_ignored_lints();
}
}
async function wA(Q) {
return {
procName: Q.procName,
args: await Promise.all(Q.args.map(r))
};
}
async function r(Q) {
const { Lint: A, Span: C, Suggestion: B } = await l();
if (Array.isArray(Q))
return { json: JSON.stringify(await Promise.all(Q.map(r))), type: "Array" };
switch (typeof Q) {
case "string":
case "number":
case "boolean":
case "undefined":
return { json: JSON.stringify(Q), type: typeof Q };
}
if (Q.to_json != null) {
const g = Q.to_json();
let E;
if (Q instanceof A ? E = "Lint" : Q instanceof B ? E = "Suggestion" : Q instanceof C && (E = "Span"), E == null)
throw new Error("Unhandled case");
return { json: g, type: E };
}
throw new Error("Unhandled case");
}
async function O(Q) {
const { Lint: A, Span: C, Suggestion: B } = await l();
switch (Q.type) {
case "undefined":
return;
case "boolean":
case "number":
case "string":
return JSON.parse(Q.json);
case "Suggestion":
return B.from_json(Q.json);
case "Lint":
return A.from_json(Q.json);
case "Span":
return C.from_json(Q.json);
case "Array":
return await Promise.all(JSON.parse(Q.json).map(O));
default:
throw new Error(`Unhandled case: ${Q.type}`);
}
}
const f = "dmFyIFkgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CnZhciBaID0gKG4sIHQsIGUpID0+IHQgaW4gbiA/IFkobiwgdCwgeyBlbnVtZXJhYmxlOiAhMCwgY29uZmlndXJhYmxlOiAhMCwgd3JpdGFibGU6ICEwLCB2YWx1ZTogZSB9KSA6IG5bdF0gPSBlOwp2YXIgTSA9IChuLCB0LCBlKSA9PiBaKG4sIHR5cGVvZiB0ICE9ICJzeW1ib2wiID8gdCArICIiIDogdCwgZSk7CnZhciBxID0gIiI7CmxldCBKID0gcTsKZnVuY3Rpb24gdHQoKSB7CiAgcmV0dXJuIEo7Cn0KZnVuY3Rpb24gZXQobikgewogIEogPSBuOwp9CmFzeW5jIGZ1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Z1bmN0aW9uIjsKICB9CiAgaWYgKEFycmF5LmlzQXJyYXkobikpIHsKICAgIGNvbnN0IGkgPSBuLmxlbmd0aDsKICAgIGxldCBzID0gIlsiOwogICAgaSA+IDAgJiYgKHMgKz0gRihuWzBdKSk7CiAgICBmb3IgKGxldCBhID0gMTsgYSA8IGk7IGErKykKICAgICAgcyArPSAiLCAiICsgRihuW2FdKTsKICAgIHJldHVybiBzICs9ICJdIiwgczsKICB9CiAgY29uc3QgZSA9IC9cW29iamVjdCAoW15cXV0rKVxdLy5leGVjKHRvU3RyaW5nLmNhbGwobikpOwogIGxldCByOwogIGlmIChlICYmIGUubGVuZ3RoID4gMSkKICAgIHIgPSBlWzFdOwogIGVsc2UK
function YA(Q) {
let A;
try {
if (A = H && (self.URL || self.webkitURL).createObjectURL(H), !A) throw "";
const C = new Worker(A, {
type: "module",
name: Q == null ? void 0 : Q.name
});
return C.addEventListener("error", () => {
(self.URL || self.webkitURL).revokeObjectURL(A);
}), C;
} catch {
return new Worker(
"data:text/javascript;base64," + f,
{
type: "module",
name: Q == null ? void 0 : Q.name
}
);
}
}
class ZA {
constructor() {
i(this, "worker");
i(this, "requestQueue");
i(this, "working", !0);
this.worker = new YA(), this.requestQueue = [], this.worker.onmessage = () => {
this.setupMainEventListeners(), this.worker.postMessage(e()), this.working = !1, this.submitRemainingRequests();
};
}
setupMainEventListeners() {
this.worker.onmessage = (A) => {
const { resolve: C } = this.requestQueue.shift();
O(A.data).then((B) => {
C(B), this.working = !1, this.submitRemainingRequests();
});
}, this.worker.onmessageerror = (A) => {
const { reject: C } = this.requestQueue.shift();
C(A.data), this.working = !1, this.submitRemainingRequests();
};
}
setup() {
return this.rpc("setup", []);
}
lint(A, C) {
return this.rpc("lint", [A, C]);
}
applySuggestion(A, C, B) {
return this.rpc("applySuggestion", [A, C, B]);
}
isLikelyEnglish(A) {
return this.rpc("isLikelyEnglish", [A]);
}
isolateEnglish(A) {
return this.rpc("isolateEnglish", [A]);
}
async getLintConfig() {
return JSON.parse(await this.getLintConfigAsJSON());
}
setLintConfig(A) {
return this.setLintConfigWithJSON(JSON.stringify(A));
}
getLintConfigAsJSON() {
return this.rpc("getLintConfigAsJSON", []);
}
setLintConfigWithJSON(A) {
return this.rpc("setLintConfigWithJSON", [A]);
}
toTitleCase(A) {
return this.rpc("toTitleCase", [A]);
}
getLintDescriptionsAsJSON() {
return this.rpc("getLintDescriptionsAsJSON", []);
}
async getLintDescriptions() {
return JSON.parse(await this.getLintDescriptionsAsJSON());
}
getDefaultLintConfigAsJSON() {
return this.rpc("getDefaultLintConfigAsJSON", []);
}
async getDefaultLintConfig() {
return JSON.parse(await this.getDefaultLintConfigAsJSON());
}
async ignoreLint(A) {
return this.rpc("ignoreLint", [A]);
}
async exportIgnoredLints() {
return this.rpc("exportIgnoredLints", []);
}
async importIgnoredLints(A) {
return this.rpc("importIgnoredLints", [A]);
}
async clearIgnoredLints() {
return this.rpc("clearIgnoredLints", []);
}
/** Run a procedure on the remote worker. */
async rpc(A, C) {
return new Promise((g, E) => {
this.requestQueue.push({
resolve: g,
reject: E,
request: { procName: A, args: C }
}), this.submitRemainingRequests();
});
}
async submitRemainingRequests() {
if (!this.working)
if (this.working = !0, this.requestQueue.length > 0) {
const { request: A } = this.requestQueue[0];
this.worker.postMessage(await wA(A));
} else
this.working = !1;
}
}
function crelt() {
var elt = arguments[0];
if (typeof elt == "string") elt = document.createElement(elt);
var i = 1, next = arguments[1];
if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
var value = next[name];
if (typeof value == "string") elt.setAttribute(name, value);
else if (value != null) elt[name] = value;
}
i++;
}
for (; i < arguments.length; i++) add(elt, arguments[i]);
return elt
}
function add(elt, child) {
if (typeof child == "string") {
elt.appendChild(document.createTextNode(child));
} else if (child == null) ; else if (child.nodeType != null) {
elt.appendChild(child);
} else if (Array.isArray(child)) {
for (var i = 0; i < child.length; i++) add(elt, child[i]);
} else {
throw new RangeError("Unsupported child node: " + child)
}
}
var SelectedDiagnostic = /** @class */ (function () {
function SelectedDiagnostic(from, to, diagnostic) {
this.from = from;
this.to = to;
this.diagnostic = diagnostic;
}
return SelectedDiagnostic;
}());
var LintState = /** @class */ (function () {
function LintState(diagnostics, selected) {
this.diagnostics = diagnostics;
this.selected = selected;
}
LintState.init = function (diagnostics, state) {
// Filter the list of diagnostics for which to create markers
var markedDiagnostics = diagnostics;
var diagnosticFilter = state.facet(lintConfig).markerFilter;
if (diagnosticFilter)
markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
var ranges = view.Decoration.set(markedDiagnostics.map(function (d) {
// For zero-length ranges or ranges covering only a line break, create a widget
return d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from)
? view.Decoration.widget({
widget: new DiagnosticWidget(d),
diagnostic: d
}).range(d.from)
: view.Decoration.mark({
attributes: {
class: 'cm-lintRange cm-lintRange-' + d.severity + (d.markClass ? ' ' + d.markClass : '')
},
diagnostic: d
}).range(d.from, d.to);
}), true);
return new LintState(ranges, findDiagnostic(ranges));
};
return LintState;
}());
function findDiagnostic(diagnostics, diagnostic, after) {
if (diagnostic === void 0) { diagnostic = null; }
if (after === void 0) { after = 0; }
var found = null;
diagnostics.between(after, 1e9, function (from, to, _a) {
var spec = _a.spec;
if (diagnostic && spec.diagnostic != diagnostic)
return;
found = new SelectedDiagnostic(from, to, spec.diagnostic);
return false;
});
return found;
}
function hideTooltip(tr, tooltip) {
var from = tooltip.pos, to = tooltip.end || from;
var result = tr.state.facet(lintConfig).hideOn(tr, from, to);
if (result != null)
return result;
var line = tr.startState.doc.lineAt(tooltip.pos);
return !!(tr.effects.some(function (e) { return e.is(setDiagnosticsEffect); }) ||
tr.changes.touchesRange(line.from, Math.max(line.to, to)));
}
function maybeEnableLint(state$1, effects) {
return state$1.field(lintState, false)
? effects
: effects.concat(state.StateEffect.appendConfig.of(lintExtensions));
}
/// Returns a transaction spec which updates the current set of
/// diagnostics, and enables the lint extension if if wasn't already
/// active.
function setDiagnostics(state, diagnostics) {
return {
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
};
}
/// The state effect that updates the set of active diagnostics. Can
/// be useful when writing an extension that needs to track these.
var setDiagnosticsEffect = state.StateEffect.define();
var movePanelSelection = state.StateEffect.define();
var lintState = state.StateField.define({
create: function () {
return new LintState(view.Decoration.none, null);
},
update: function (value, tr) {
if (tr.docChanged && value.diagnostics.size) {
var mapped = value.diagnostics.map(tr.changes);
var selected = null;
if (value.selected) {
var selPos = tr.changes.mapPos(value.selected.from, 1);
selected =
findDiagnostic(mapped, value.selected.diagnostic, selPos) ||
findDiagnostic(mapped, null, selPos);
}
value = new LintState(mapped, selected);
}
for (var _i = 0, _a = tr.effects; _i < _a.length; _i++) {
var effect = _a[_i];
if (effect.is(setDiagnosticsEffect)) {
value = LintState.init(effect.value, tr.state);
}
else if (effect.is(movePanelSelection)) {
value = new LintState(value.diagnostics, effect.value);
}
}
return value;
},
provide: function (f) { return [view.EditorView.decorations.from(f, function (s) { return s.diagnostics; })]; }
});
var activeMark = view.Decoration.mark({ class: 'cm-lintRange cm-lintRange-active' });
function lintTooltip(view, pos, side) {
var diagnostics = view.state.field(lintState).diagnostics;
var found = [], stackStart = 2e8, stackEnd = 0;
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), function (from, to, _a) {
var spec = _a.spec;
if (pos >= from &&
pos <= to &&
(from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
found.push(spec.diagnostic);
stackStart = Math.min(from, stackStart);
stackEnd = Math.max(to, stackEnd);
}
});
var diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
if (diagnosticFilter)
found = diagnosticFilter(found, view.state);
if (!found.length)
return null;
return {
pos: stackStart,
end: stackEnd,
above: view.state.doc.lineAt(stackStart).to < stackEnd,
create: function () {
return { dom: diagnosticsTooltip(view, found) };
}
};
}
function diagnosticsTooltip(view, diagnostics) {
return crelt('ul', { class: 'cm-tooltip-lint' }, diagnostics.map(function (d) { return renderDiagnostic(view, d); }));
}
var lintPlugin = view.ViewPlugin.fromClass(/** @class */ (function () {
function class_1(view) {
this.view = view;
this.timeout = -1;
this.set = true;
var delay = view.state.facet(lintConfig).delay;
this.lintTime = Date.now() + delay;
this.run = this.run.bind(this);
this.timeout = setTimeout(this.run, delay);
}
class_1.prototype.run = function () {
var _this = this;
clearTimeout(this.timeout);
var now = Date.now();
if (now < this.lintTime - 10) {
this.timeout = setTimeout(this.run, this.lintTime - now);
}
else {
this.set = false;
var state_1 = this.view.state, sources = state_1.facet(lintConfig).sources;
if (sources.length)
Promise.all(sources.map(function (source) { return Promise.resolve(source(_this.view)); })).then(function (annotations) {
var all = annotations.reduce(function (a, b) { return a.concat(b); });
if (_this.view.state.doc == state_1.doc)
_this.view.dispatch(setDiagnostics(_this.view.state, all));
}, function (error) {
view.logException(_this.view.state, error);
});
}
};
class_1.prototype.update = function (update) {
var config = update.state.facet(lintConfig);
if (update.docChanged ||
config != update.startState.facet(lintConfig) ||
(config.needsRefresh && config.needsRefresh(update))) {
this.lintTime = Date.now() + config.delay;
if (!this.set) {
this.set = true;
this.timeout = setTimeout(this.run, config.delay);
}
}
};
class_1.prototype.force = function () {
if (this.set) {
this.lintTime = Date.now();
this.run();
}
};
class_1.prototype.destroy = function () {
clearTimeout(this.timeout);
};
return class_1;
}()));
var lintConfig = state.Facet.define({
combine: function (input) {
return __assign({ sources: input.map(function (i) { return i.source; }).filter(function (x) { return x != null; }) }, state.combineConfig(input.map(function (i) { return i.config; }), {
delay: 750,
markerFilter: null,
tooltipFilter: null,
needsRefresh: null,
hideOn: function () { return null; }
}, {
needsRefresh: function (a, b) { return (!a ? b : !b ? a : function (u) { return a(u) || b(u); }); }
}));
}
});
/// Given a diagnostic source, this function returns an extension that
/// enables linting with that source. It will be called whenever the
/// editor is idle (after its content changed). If `null` is given as
/// source, this only configures the lint extension.
function linter(source, config) {
if (config === void 0) { config = {}; }
return [lintConfig.of({ source: source, config: config }), lintPlugin, lintExtensions];
}
function renderDiagnostic(view, diagnostic, inPanel) {
var _a;
var keys = [];
return crelt('li', { class: 'cm-diagnostic cm-diagnostic-' + diagnostic.severity }, crelt('span', { class: 'cm-diagnosticTitle' }, diagnostic.title), crelt('span', { class: 'cm-diagnosticText' }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map(function (action, i) {
var fired = false;
var click = function (e) {
e.preventDefault();
if (fired)
return;
fired = true;
var found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
if (found)
action.apply(view, found.from, found.to);
};
var name = action.name, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
var nameElt = keyIndex < 0
? name
: [
name.slice(0, keyIndex),
crelt('u', name.slice(keyIndex, keyIndex + 1)),
name.slice(keyIndex + 1)
];
return crelt('button', {
type: 'button',
class: 'cm-diagnosticAction',
onclick: click,
onmousedown: click,
'aria-label': " Action: ".concat(name).concat(keyIndex < 0 ? '' : " (access key \"".concat(keys[i], ")\""), ".")
}, nameElt);
}), diagnostic.ignore &&
crelt('div', {
class: 'cm-diagnosticIgnore',
onclick: function (e) {
e.preventDefault();
if (diagnostic.ignore) {
diagnostic.ignore();
}
}
}, 'Ignore Diagnostic'), diagnostic.source && crelt('div', { class: 'cm-diagnosticSource' }, diagnostic.source));
}
var DiagnosticWidget = /** @class */ (function (_super) {
__extends(DiagnosticWidget, _super);
function DiagnosticWidget(diagnostic) {
var _this = _super.call(this) || this;
_this.diagnostic = diagnostic;
return _this;
}
DiagnosticWidget.prototype.eq = function (other) {
return other.diagnostic == this.diagnostic;
};
DiagnosticWidget.prototype.toDOM = function () {
return crelt('span', { class: 'cm-lintPoint cm-lintPoint-' + this.diagnostic.severity });
};
return DiagnosticWidget;
}(view.WidgetType));
function svg(content, attrs) {
return "url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" ".concat(attrs, ">").concat(encodeURIComponent(content), "</svg>')");
}
function underline(color) {
return svg("<path d=\"m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0\" stroke=\"".concat(color, "\" fill=\"none\" stroke-width=\"1\"/>"), "width=\"6\" height=\"3\"");
}
var baseTheme = view.EditorView.baseTheme({
'.cm-diagnostic': {
padding: '4px',
marginLeft: '0px',
display: 'flex',
flexDirection: 'column',
whiteSpace: 'pre-wrap'
},
'.cm-diagnosticTitle': {
boxShadow: 'inset 0 -2px #DB2B39',
width: 'max-content',
fontWeight: 'bold'
},
'.cm-diagnosticText': {
marginTop: '8px'
},
'.cm-diagnosticAction': {
font: 'inherit',
border: 'none',
marginTop: '8px',
display: 'flex',
alignItems: 'center',
gap: 'var(--size-4-2)',
padding: 'var(--size-4-1) var(--size-4-2)',
cursor: 'var(--cursor)',
fontSize: 'var(--font-ui-small)',
borderRadius: 'var(--radius-s)',
whiteSpace: 'nowrap',
width: '100%'
},
'.cm-tooltip': {
padding: 'var(--size-2-3) !important',
border: '1px solid var(--background-modifier-border-hover) !important',
backgroundColor: 'var(--background-secondary) !important',
borderRadius: 'var(--radius-m) !important',
boxShadow: 'var(--shadow-s) !important',
zIndex: 'var(--layer-menu) !important',
userSelect: 'none !important',
maxHeight: 'calc(100% - var(--header-height)) !important',
overflow: 'hidden !important'
},
'.cm-diagnosticSource': {
fontSize: '70%',
opacity: 0.7
},
'.cm-diagnosticIgnore': {
color: 'black',
padding: 'var(--size-4-1) 0px',
fontSize: 'var(--font-ui-small)'
},
'.cm-diagnosticIgnore:hover': {
textDecoration: 'underline'
},
'.cm-lintRange': {
backgroundPosition: 'left bottom',
backgroundRepeat: 'repeat-x',
paddingBottom: '0.7px'
},
'.cm-lintRange-error': { backgroundImage: underline('#d11') },
'.cm-lintRange-warning': { backgroundImage: underline('orange') },
'.cm-lintRange-info': { backgroundImage: underline('#999') },
'.cm-lintRange-hint': { backgroundImage: underline('#66d') },
'.cm-lintRange-active': { backgroundColor: '#ffdd9980' },
'.cm-tooltip-lint': {
padding: 0,
margin: 0
},
'.cm-lintPoint': {
position: 'relative',
'&:after': {
content: '""',
position: 'absolute',
bottom: 0,
left: '-2px',
borderLeft: '3px solid transparent',
borderRight: '3px solid transparent',
borderBottom: '4px solid #d11'
}
},
'.cm-lintPoint-warning': {
'&:after': { borderBottomColor: 'orange' }
},
'.cm-lintPoint-info': {
'&:after': { borderBottomColor: '#999' }
},
'.cm-lintPoint-hint': {
'&:after': { borderBottomColor: '#66d' }
},
'.cm-panel.cm-panel-lint': {
position: 'relative',
'& ul': {
maxHeight: '100px',
overflowY: 'auto',
'& [aria-selected]': {
backgroundColor: '#ddd',
'& u': { textDecoration: 'underline' }
},
'&:focus [aria-selected]': {
background_fallback: '#bdf',
backgroundColor: 'Highlight',
color_fallback: 'white',
color: 'HighlightText'
},
'& u': { textDecoration: 'none' },
padding: 0,
margin: 0
},
'& [name=close]': {
position: 'absolute',
top: '0',
right: '2px',
background: 'inherit',
border: 'none',
font: 'inherit',
padding: 0,
margin: 0
}
}
});
var lintExtensions = [
lintState,
view.EditorView.decorations.compute([lintState], function (state) {
var _a = state.field(lintState), selected = _a.selected, panel = _a.panel;
return !selected || !panel || selected.from == selected.to
? view.Decoration.none
: view.Decoration.set([activeMark.range(selected.from, selected.to)]);
}),
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
baseTheme
];
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Built-in value references. */
var Symbol$1 = root.Symbol;
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto$1.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$1.toString;
/** Built-in value references. */
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag$1),
tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString$1.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && baseGetTag(value) == symbolTag);
}
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString$1(value) {
return value == null ? '' : baseToString(value);
}
/**
* The base implementation of `_.slice` without an iteratee call guard.
*
* @private
* @param {Array} array The array to slice.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the slice of `array`.
*/
function baseSlice(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : ((end - start) >>> 0);
start >>>= 0;
var result = Array(length);
while (++index < length) {
result[index] = array[index + start];
}
return result;
}
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
/** Used to compose unicode character classes. */
var rsAstralRange$2 = '\\ud800-\\udfff',
rsComboMarksRange$3 = '\\u0300-\\u036f',
reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f',
rsComboSymbolsRange$3 = '\\u20d0-\\u20ff',
rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3,
rsVarRange$2 = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ$2 = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasUnicode = RegExp('[' + rsZWJ$2 + rsAstralRange$2 + rsComboRange$3 + rsVarRange$2 + ']');
/**
* Checks if `string` contains Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
*/
function hasUnicode(string) {
return reHasUnicode.test(string);
}
/**
* Converts an ASCII `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function asciiToArray(string) {
return string.split('');
}
/** Used to compose unicode character classes. */
var rsAstralRange$1 = '\\ud800-\\udfff',
rsComboMarksRange$2 = '\\u0300-\\u036f',
reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f',
rsComboSymbolsRange$2 = '\\u20d0-\\u20ff',
rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2,
rsVarRange$1 = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange$1 + ']',
rsCombo$2 = '[' + rsComboRange$2 + ']',
rsFitz$1 = '\\ud83c[\\udffb-\\udfff]',
rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')',
rsNonAstral$1 = '[^' + rsAstralRange$1 + ']',
rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]',
rsZWJ$1 = '\\u200d';
/** Used to compose unicode regexes. */
var reOptMod$1 = rsModifier$1 + '?',
rsOptVar$1 = '[' + rsVarRange$1 + ']?',
rsOptJoin$1 = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*',
rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1,
rsSymbol = '(?:' + [rsNonAstral$1 + rsCombo$2 + '?', rsCombo$2, rsRegional$1, rsSurrPair$1, rsAstral].join('|') + ')';
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reUnicode = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol + rsSeq$1, 'g');
/**
* Converts a Unicode `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function unicodeToArray(string) {
return string.match(reUnicode) || [];
}
/**
* Converts `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function stringToArray(string) {
return hasUnicode(string)
? unicodeToArray(string)
: asciiToArray(string);
}
/**
* Creates a function like `_.lowerFirst`.
*
* @private
* @param {string} methodName The name of the `String` case method to use.
* @returns {Function} Returns the new case function.
*/
function createCaseFirst(methodName) {
return function(string) {
string = toString$1(string);
var strSymbols = hasUnicode(string)
? stringToArray(string)
: undefined;
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};
}
/**
* Converts the first character of `string` to upper case.
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.upperFirst('fred');
* // => 'Fred'
*
* _.upperFirst('FRED');
* // => 'FRED'
*/
var upperFirst = createCaseFirst('toUpperCase');
/**
* A specialized version of `_.reduce` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
/**
* The base implementation of `_.propertyOf` without support for deep paths.
*
* @private
* @param {Object} object The object to query.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyOf(object) {
return function(key) {
return object == null ? undefined : object[key];
};
}
/** Used to map Latin Unicode letters to basic Latin letters. */
var deburredLetters = {
// Latin-1 Supplement block.
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'C', '\xe7': 'c',
'\xd0': 'D', '\xf0': 'd',
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
'\xd1': 'N', '\xf1': 'n',
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
'\xc6': 'Ae', '\xe6': 'ae',
'\xde': 'Th', '\xfe': 'th',
'\xdf': 'ss',
// Latin Extended-A block.
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
'\u0134': 'J', '\u0135': 'j',
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
'\u0163': 't', '\u0165': 't', '\u0167': 't',
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
'\u0174': 'W', '\u0175': 'w',
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
'\u0132': 'IJ', '\u0133': 'ij',
'\u0152': 'Oe', '\u0153': 'oe',
'\u0149': "'n", '\u017f': 's'
};
/**
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
* letters to basic Latin letters.
*
* @private
* @param {string} letter The matched letter to deburr.
* @returns {string} Returns the deburred letter.
*/
var deburrLetter = basePropertyOf(deburredLetters);
/** Used to match Latin Unicode letters (excluding mathematical operators). */
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
/** Used to compose unicode character classes. */
var rsComboMarksRange$1 = '\\u0300-\\u036f',
reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
/** Used to compose unicode capture groups. */
var rsCombo$1 = '[' + rsComboRange$1 + ']';
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
*/
var reComboMark = RegExp(rsCombo$1, 'g');
/**
* Deburrs `string` by converting
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
* letters to basic Latin letters and removing
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to deburr.
* @returns {string} Returns the deburred string.
* @example
*
* _.deburr('déjà vu');
* // => 'deja vu'
*/
function deburr(string) {
string = toString$1(string);
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
}
/** Used to match words composed of alphanumeric characters. */
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/**
* Splits an ASCII `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function asciiWords(string) {
return string.match(reAsciiWord) || [];
}
/** Used to detect strings that need a more robust regexp to match words. */
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
/**
* Checks if `string` contains a word composed of Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a word is found, else `false`.
*/
function hasUnicodeWord(string) {
return reHasUnicodeWord.test(string);
}
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f',
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
rsComboSymbolsRange = '\\u20d0-\\u20ff',
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
rsDingbatRange = '\\u2700-\\u27bf',
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
rsPunctuationRange = '\\u2000-\\u206f',
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
rsVarRange = '\\ufe0e\\ufe0f',
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
/** Used to compose unicode capture groups. */
var rsApos$1 = "['\u2019]",
rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
rsLower = '[' + rsLowerRange + ']',
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
rsUpper = '[' + rsUpperRange + ']',
rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptContrLower = '(?:' + rsApos$1 + '(?:d|ll|m|re|s|t|ve))?',
rsOptContrUpper = '(?:' + rsApos$1 + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
/** Used to match complex or compound words. */
var reUnicodeWord = RegExp([
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
rsUpper + '+' + rsOptContrUpper,
rsOrdUpper,
rsOrdLower,
rsDigits,
rsEmoji
].join('|'), 'g');
/**
* Splits a Unicode `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function unicodeWords(string) {
return string.match(reUnicodeWord) || [];
}
/**
* Splits `string` into an array of its words.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to inspect.
* @param {RegExp|string} [pattern] The pattern to match words.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the words of `string`.
* @example
*
* _.words('fred, barney, & pebbles');
* // => ['fred', 'barney', 'pebbles']
*
* _.words('fred, barney, & pebbles', /[^, ]+/g);
* // => ['fred', 'barney', '&', 'pebbles']
*/
function words(string, pattern, guard) {
string = toString$1(string);
pattern = pattern;
if (pattern === undefined) {
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
}
return string.match(pattern) || [];
}
/** Used to compose unicode capture groups. */
var rsApos = "['\u2019]";
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/**
* Creates a function like `_.camelCase`.
*
* @private
* @param {Function} callback The function to combine each word.
* @returns {Function} Returns the new compounder function.
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}
/**
* Converts `string` to
* [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
*
* @static
* @memberOf _
* @since 3.1.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the start cased string.
* @example
*
* _.startCase('--foo-bar--');
* // => 'Foo Bar'
*
* _.startCase('fooBar');
* // => 'Foo Bar'
*
* _.startCase('__FOO_BAR__');
* // => 'FOO BAR'
*/
var startCase = createCompounder(function(result, word, index) {
return result + (index ? ' ' : '') + upperFirst(word);
});
var HarperSettingTab = /** @class */ (function (_super) {
__extends(HarperSettingTab, _super);
function HarperSettingTab(app, plugin) {
var _this = _super.call(this, app, plugin) || this;
_this.plugin = plugin;
_this.updateDescriptions();
_this.updateSettings();
return _this;
}
HarperSettingTab.prototype.updateSettings = function () {
var _this = this;
this.plugin.getSettings().then(function (v) { return (_this.settings = v); });
};
HarperSettingTab.prototype.updateDescriptions = function () {
var _this = this;
this.plugin.getDescriptions().then(function (v) { return (_this.descriptions = v); });
};
HarperSettingTab.prototype.display = function () {
var _this = this;
var containerEl = this.containerEl;
containerEl.empty();
console.log(this.settings.lintSettings);
new obsidian.Setting(containerEl).setName('Use Web Worker').addToggle(function (toggle) {
return toggle.setValue(_this.settings.useWebWorker).onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.settings.useWebWorker = value;
return [4 /*yield*/, this.plugin.initializeFromSettings(this.settings)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); });
});
var _loop_1 = function (setting) {
var value = this_1.settings.lintSettings[setting];
var description = this_1.descriptions[setting];
new obsidian.Setting(containerEl)
.setName(startCase(setting))
.setDesc(description)
.addDropdown(function (dropdown) {
return dropdown
.addOption('default', 'Default')
.addOption('enable', 'On')
.addOption('disable', 'Off')
.setValue(valueToString(value))
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.settings.lintSettings[setting] = stringToValue(value);
return [4 /*yield*/, this.plugin.initializeFromSettings(this.settings)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); });
});
};
var this_1 = this;
for (var _i = 0, _a = Object.keys(this.settings.lintSettings); _i < _a.length; _i++) {
var setting = _a[_i];
_loop_1(setting);
}
new obsidian.Setting(containerEl).setName('The Danger Zone').addButton(function (button) {
button
.setButtonText('Forget Ignored Suggestions')
.onClick(function () {
_this.settings.ignoredLints = undefined;
_this.plugin.initializeFromSettings(_this.settings);
})
.setWarning();
});
};
return HarperSettingTab;
}(obsidian.PluginSettingTab));
function valueToString(value) {
switch (value) {
case true:
return 'enable';
case false:
return 'disable';
case null:
return 'default';
}
throw 'Fell through case';
}
function stringToValue(str) {
switch (str) {
case 'enable':
return true;
case 'disable':
return false;
case 'default':
return undefined;
}
throw 'Fell through case';
}
function suggestionToLabel(sug) {
if (sug.kind() == FA.Remove) {
return 'Remove';
}
else if (sug.kind() == FA.Replace) {
return "Replace with \"".concat(sug.get_replacement_text(), "\"");
}
else if (sug.kind() == FA.InsertAfter) {
return "Insert \"".concat(sug.get_replacement_text(), "\" after this.");
}
}
var HarperPlugin = /** @class */ (function (_super) {
__extends(HarperPlugin, _super);
function HarperPlugin(app, manifest) {
var _this = _super.call(this, app, manifest) || this;
_this.harper = new ZA();
_this.editorExtensions = [];
return _this;
}
HarperPlugin.prototype.initializeFromSettings = function (settings) {
return __awaiter(this, void 0, void 0, function () {
var oldSettings;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (settings == null) {
settings = { useWebWorker: true, lintSettings: {} };
}
return [4 /*yield*/, this.getSettings()];
case 1:
oldSettings = _a.sent();
if (!(settings.useWebWorker != oldSettings.useWebWorker)) return [3 /*break*/, 2];
if (settings.useWebWorker) {
this.harper = new ZA();
}
else {
this.harper = new lA();
}
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.harper.clearIgnoredLints()];
case 3:
_a.sent();
_a.label = 4;
case 4:
if (!(settings.ignoredLints !== undefined)) return [3 /*break*/, 6];
return [4 /*yield*/, this.harper.importIgnoredLints(settings.ignoredLints)];
case 5:
_a.sent();
_a.label = 6;
case 6: return [4 /*yield*/, this.harper.setLintConfig(settings.lintSettings)];
case 7:
_a.sent();
this.harper.setup();
// Reinitialize it.
if (this.hasEditorLinter()) {
this.disableEditorLinter();
this.enableEditorLinter();
}
return [4 /*yield*/, this.saveData(settings)];
case 8:
_a.sent();
return [2 /*return*/];
}
});
});
};
HarperPlugin.prototype.reinitialize = function () {
return __awaiter(this, void 0, void 0, function () {
var settings;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getSettings()];
case 1:
settings = _a.sent();
return [4 /*yield*/, this.initializeFromSettings(settings)];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};
HarperPlugin.prototype.getSettings = function () {
return __awaiter(this, void 0, void 0, function () {
var usingWebWorker;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
usingWebWorker = this.harper instanceof ZA;
_a = {};
return [4 /*yield*/, this.harper.exportIgnoredLints()];
case 1:
_a.ignoredLints = _b.sent(),
_a.useWebWorker = usingWebWorker;
return [4 /*yield*/, this.harper.getLintConfig()];
case 2: return [2 /*return*/, (_a.lintSettings = _b.sent(),
_a)];
}
});
});
};
HarperPlugin.prototype.onload = function () {
return __awaiter(this, void 0, void 0, function () {
var data;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.loadData()];
case 1:
data = _a.sent();
return [4 /*yield*/, this.initializeFromSettings(data)];
case 2:
_a.sent();
this.registerEditorExtension(this.editorExtensions);
this.setupCommands();
this.setupStatusBar();
this.enableEditorLinter();
this.addSettingTab(new HarperSettingTab(this.app, this));
return [2 /*return*/];
}
});
});
};
HarperPlugin.prototype.getDescriptions = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.harper.getLintDescriptions()];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
HarperPlugin.prototype.setupStatusBar = function () {
var _this = this;
/** @type HTMLElement */
var statusBarItem = this.addStatusBarItem();
statusBarItem.className += ' mod-clickable';
var button = document.createElement('span');
button.style = 'width:24px';
button.innerHTML = logoSvg;
button.addEventListener('click', function (event) {
var menu = new obsidian.Menu();
menu.addItem(function (item) {
return item
.setTitle("".concat(_this.hasEditorLinter() ? 'Disable' : 'Enable', " automatic checking"))
.setIcon('documents')
.onClick(function () {
_this.toggleAutoLint();
});
});
menu.showAtMouseEvent(event);
});
statusBarItem.appendChild(button);
};
HarperPlugin.prototype.setupCommands = function () {
var _this = this;
this.addCommand({
id: 'harper-toggle-auto-lint',
name: 'Toggle automatic grammar checking',
callback: function () { return _this.toggleAutoLint(); }
});
};
HarperPlugin.prototype.enableEditorLinter = function () {
if (!this.hasEditorLinter()) {
this.editorExtensions.push(this.constructEditorLinter());
this.app.workspace.updateOptions();
console.log('Enabled');
}
};
HarperPlugin.prototype.disableEditorLinter = function () {
while (this.hasEditorLinter()) {
this.editorExtensions.pop();
}
this.app.workspace.updateOptions();
};
HarperPlugin.prototype.hasEditorLinter = function () {
return this.editorExtensions.length != 0;
};
HarperPlugin.prototype.toggleAutoLint = function () {
if (this.hasEditorLinter()) {
this.disableEditorLinter();
}
else {
this.enableEditorLinter();
}
};
/** Construct the linter plugin that actually shows the errors. */
HarperPlugin.prototype.constructEditorLinter = function () {
var _this = this;
return linter(function (view) { return __awaiter(_this, void 0, void 0, function () {
var text, lints;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
text = view.state.doc.sliceString(-1);
return [4 /*yield*/, this.harper.lint(text)];
case 1:
lints = _a.sent();
return [2 /*return*/, lints.map(function (lint) {
var span = lint.span();
return {
from: span.start,
to: span.end,
severity: 'error',
title: lint.lint_kind(),
message: lint.message(),
ignore: function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.harper.ignoreLint(lint)];
case 1:
_a.sent();
return [4 /*yield*/, this.reinitialize()];
case 2:
_a.sent();
return [2 /*return*/];
}
});
}); },
actions: lint.suggestions().map(function (sug) {
return {
name: suggestionToLabel(sug),
apply: function (view) {
if (sug.kind() === FA.Remove) {
view.dispatch({
changes: {
from: span.start,
to: span.end,
insert: ''
}
});
}
else if (sug.kind() === FA.Replace) {
view.dispatch({
changes: {
from: span.start,
to: span.end,
insert: sug.get_replacement_text()
}
});
}
else if (sug.kind() === FA.InsertAfter) {
view.dispatch({
changes: {
from: span.end,
to: span.end,
insert: sug.get_replacement_text()
}
});
}
}
};
})
};
})];
}
});
}); }, {
delay: -1
});
};
return HarperPlugin;
}(obsidian.Plugin));
module.exports = HarperPlugin;
/* nosourcemap */