1
0

Obsidian:更新插件

This commit is contained in:
周中平 2024-07-08 15:37:38 +08:00
parent 8df4bee75e
commit 3a26cd615e
Signed by: zhouzhongping
GPG Key ID: 6666822800008000
6 changed files with 477 additions and 377 deletions

View File

@ -1983,8 +1983,8 @@ var require_lib = __commonJS({
if (typeof cb !== "function") { if (typeof cb !== "function") {
opts = cb; opts = cb;
cb = null; cb = null;
deferred2 = new this.Promise(function(resolve, reject) { deferred2 = new this.Promise(function(resolve2, reject) {
deferredResolve = resolve; deferredResolve = resolve2;
deferredReject = reject; deferredReject = reject;
}); });
} }
@ -2132,17 +2132,17 @@ var require_lib = __commonJS({
if (typeof cb === "function") { if (typeof cb === "function") {
fnx(cb); fnx(cb);
} else { } else {
return new this.Promise(function(resolve, reject) { return new this.Promise(function(resolve2, reject) {
if (fnx.length === 1) { if (fnx.length === 1) {
fnx(function(err, ret) { fnx(function(err, ret) {
if (err) { if (err) {
reject(err); reject(err);
} else { } else {
resolve(ret); resolve2(ret);
} }
}); });
} else { } else {
resolve(fnx()); resolve2(fnx());
} }
}); });
} }
@ -6742,7 +6742,7 @@ var require_pify = __commonJS({
init_polyfill_buffer(); init_polyfill_buffer();
var processFn = (fn, options) => function(...args) { var processFn = (fn, options) => function(...args) {
const P = options.promiseModule; const P = options.promiseModule;
return new P((resolve, reject) => { return new P((resolve2, reject) => {
if (options.multiArgs) { if (options.multiArgs) {
args.push((...result) => { args.push((...result) => {
if (options.errorFirst) { if (options.errorFirst) {
@ -6750,10 +6750,10 @@ var require_pify = __commonJS({
reject(result); reject(result);
} else { } else {
result.shift(); result.shift();
resolve(result); resolve2(result);
} }
} else { } else {
resolve(result); resolve2(result);
} }
}); });
} else if (options.errorFirst) { } else if (options.errorFirst) {
@ -6761,11 +6761,11 @@ var require_pify = __commonJS({
if (error) { if (error) {
reject(error); reject(error);
} else { } else {
resolve(result); resolve2(result);
} }
}); });
} else { } else {
args.push(resolve); args.push(resolve2);
} }
fn.apply(this, args); fn.apply(this, args);
}); });
@ -21451,9 +21451,9 @@ var FIFO = class {
throw Error("You cannot write to a FIFO that has already been ended!"); throw Error("You cannot write to a FIFO that has already been ended!");
} }
if (this._waiting) { if (this._waiting) {
const resolve = this._waiting; const resolve2 = this._waiting;
this._waiting = null; this._waiting = null;
resolve({ value: chunk }); resolve2({ value: chunk });
} else { } else {
this._queue.push(chunk); this._queue.push(chunk);
} }
@ -21461,9 +21461,9 @@ var FIFO = class {
end() { end() {
this._ended = true; this._ended = true;
if (this._waiting) { if (this._waiting) {
const resolve = this._waiting; const resolve2 = this._waiting;
this._waiting = null; this._waiting = null;
resolve({ done: true }); resolve2({ done: true });
} }
} }
destroy(err) { destroy(err) {
@ -21482,8 +21482,8 @@ var FIFO = class {
"You cannot call read until the previous call to read has returned!" "You cannot call read until the previous call to read has returned!"
); );
} }
return new Promise((resolve) => { return new Promise((resolve2) => {
this._waiting = resolve; this._waiting = resolve2;
}); });
} }
}; };
@ -21643,7 +21643,7 @@ async function parseUploadPackResponse(stream) {
const acks = []; const acks = [];
let nak = false; let nak = false;
let done = false; let done = false;
return new Promise((resolve, reject) => { return new Promise((resolve2, reject) => {
forAwait(packetlines, (data) => { forAwait(packetlines, (data) => {
const line = data.toString("utf8").trim(); const line = data.toString("utf8").trim();
if (line.startsWith("shallow")) { if (line.startsWith("shallow")) {
@ -21671,11 +21671,11 @@ async function parseUploadPackResponse(stream) {
nak = true; nak = true;
} }
if (done) { if (done) {
stream.error ? reject(stream.error) : resolve({ shallows, unshallows, acks, nak, packfile, progress }); stream.error ? reject(stream.error) : resolve2({ shallows, unshallows, acks, nak, packfile, progress });
} }
}).finally(() => { }).finally(() => {
if (!done) { if (!done) {
stream.error ? reject(stream.error) : resolve({ shallows, unshallows, acks, nak, packfile, progress }); stream.error ? reject(stream.error) : resolve2({ shallows, unshallows, acks, nak, packfile, progress });
} }
}); });
}); });
@ -25792,7 +25792,7 @@ var __toCommonJS2 = /* @__PURE__ */ ((cache) => {
}; };
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0); })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
var __async = (__this, __arguments, generator) => { var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => { return new Promise((resolve2, reject) => {
var fulfilled = (value) => { var fulfilled = (value) => {
try { try {
step(generator.next(value)); step(generator.next(value));
@ -25807,7 +25807,7 @@ var __async = (__this, __arguments, generator) => {
reject(e); reject(e);
} }
}; };
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next()); step((generator = generator.apply(__this, __arguments)).next());
}); });
}; };
@ -29766,13 +29766,15 @@ var GitManager = class {
// Constructs a path relative to the git repository from a path relative to the vault // Constructs a path relative to the git repository from a path relative to the vault
// //
// @param doConversion - If false, the path is returned as is. This is added because that parameter is often passed on to functions where this method is called. // @param doConversion - If false, the path is returned as is. This is added because that parameter is often passed on to functions where this method is called.
getRelativeRepoPath(path2, doConversion = true) { getRelativeRepoPath(filePath, doConversion = true) {
if (doConversion) { if (doConversion) {
if (this.plugin.settings.basePath.length > 0) { if (this.plugin.settings.basePath.length > 0) {
return path2.substring(this.plugin.settings.basePath.length + 1); return filePath.substring(
this.plugin.settings.basePath.length + 1
);
} }
} }
return path2; return filePath;
} }
_getTreeStructure(children2, beginLength = 0) { _getTreeStructure(children2, beginLength = 0) {
const list = []; const list = [];
@ -29870,6 +29872,8 @@ var GitManager = class {
if (template.includes("{{files}}")) { if (template.includes("{{files}}")) {
status2 = status2 != null ? status2 : await this.status(); status2 = status2 != null ? status2 : await this.status();
const changeset = {}; const changeset = {};
let files = "";
if (status2.staged.length < 100) {
status2.staged.forEach((value) => { status2.staged.forEach((value) => {
if (value.index in changeset) { if (value.index in changeset) {
changeset[value.index].push(value.path); changeset[value.index].push(value.path);
@ -29881,7 +29885,10 @@ var GitManager = class {
for (const [action, files2] of Object.entries(changeset)) { for (const [action, files2] of Object.entries(changeset)) {
chunks.push(action + " " + files2.join(" ")); chunks.push(action + " " + files2.join(" "));
} }
const files = chunks.join(", "); files = chunks.join(", ");
} else {
files = "Too many files to list";
}
template = template.replace("{{files}}", files); template = template.replace("{{files}}", files);
} }
const moment6 = window.moment; const moment6 = window.moment;
@ -29890,7 +29897,14 @@ var GitManager = class {
moment6().format(this.plugin.settings.commitDateFormat) moment6().format(this.plugin.settings.commitDateFormat)
); );
if (this.plugin.settings.listChangedFilesInMessageBody) { if (this.plugin.settings.listChangedFilesInMessageBody) {
template = template + "\n\nAffected files:\n" + (status2 != null ? status2 : await this.status()).staged.map((e) => e.path).join("\n"); const status22 = status2 != null ? status2 : await this.status();
let files = "";
if (status22.staged.length < 100) {
files = status22.staged.map((e) => e.path).join("\n");
} else {
files = "Too many files to list";
}
template = template + "\n\nAffected files:\n" + files;
} }
return template; return template;
} }
@ -29904,18 +29918,22 @@ var SimpleGit = class extends GitManager {
async setGitInstance(ignoreError = false) { async setGitInstance(ignoreError = false) {
if (this.isGitInstalled()) { if (this.isGitInstalled()) {
const adapter = this.app.vault.adapter; const adapter = this.app.vault.adapter;
const path2 = adapter.getBasePath(); const vaultBasePath = adapter.getBasePath();
let basePath = path2; let basePath = vaultBasePath;
if (this.plugin.settings.basePath) { if (this.plugin.settings.basePath) {
const exists2 = await adapter.exists( const exists2 = await adapter.exists(
(0, import_obsidian4.normalizePath)(this.plugin.settings.basePath) (0, import_obsidian4.normalizePath)(this.plugin.settings.basePath)
); );
if (exists2) { if (exists2) {
basePath = path2 + import_path.sep + this.plugin.settings.basePath; basePath = path.join(
vaultBasePath,
this.plugin.settings.basePath
);
} else if (!ignoreError) { } else if (!ignoreError) {
new import_obsidian4.Notice("ObsidianGit: Base path does not exist"); new import_obsidian4.Notice("ObsidianGit: Base path does not exist");
} }
} }
this.absoluteRepoPath = basePath;
this.git = esm_default({ this.git = esm_default({
baseDir: basePath, baseDir: basePath,
binary: this.plugin.localStorage.getGitPath() || void 0, binary: this.plugin.localStorage.getGitPath() || void 0,
@ -29925,8 +29943,8 @@ var SimpleGit = class extends GitManager {
const envVars = this.plugin.localStorage.getEnvVars(); const envVars = this.plugin.localStorage.getEnvVars();
const gitDir = this.plugin.settings.gitDir; const gitDir = this.plugin.settings.gitDir;
if (pathPaths.length > 0) { if (pathPaths.length > 0) {
const path3 = process.env["PATH"] + ":" + pathPaths.join(":"); const path2 = process.env["PATH"] + ":" + pathPaths.join(":");
process.env["PATH"] = path3; process.env["PATH"] = path2;
} }
if (gitDir) { if (gitDir) {
process.env["GIT_DIR"] = gitDir; process.env["GIT_DIR"] = gitDir;
@ -29937,10 +29955,41 @@ var SimpleGit = class extends GitManager {
} }
import_debug2.default.enable("simple-git"); import_debug2.default.enable("simple-git");
if (await this.git.checkIsRepo()) { if (await this.git.checkIsRepo()) {
await this.git.cwd(await this.git.revparse("--show-toplevel")); const relativeRoot = await this.git.revparse("--show-cdup");
const absoluteRoot = (0, import_path.resolve)(basePath + import_path.sep + relativeRoot);
this.absoluteRepoPath = absoluteRoot;
await this.git.cwd(absoluteRoot);
} }
} }
} }
// Constructs a path relative to the vault from a path relative to the git repository
getRelativeVaultPath(filePath) {
const adapter = this.app.vault.adapter;
const from = adapter.getBasePath();
const to = path.join(this.absoluteRepoPath, filePath);
let res = path.relative(from, to);
if (import_obsidian4.Platform.isWin) {
res = res.replace(/\\/g, "/");
}
return res;
}
// Constructs a path relative to the git repository from a path relative to the vault
//
// @param doConversion - If false, the path is returned as is. This is added because that parameter is often passed on to functions where this method is called.
getRelativeRepoPath(filePath, doConversion = true) {
if (doConversion) {
const adapter = this.plugin.app.vault.adapter;
const vaultPath = adapter.getBasePath();
const from = this.absoluteRepoPath;
const to = path.join(vaultPath, filePath);
let res = path.relative(from, to);
if (import_obsidian4.Platform.isWin) {
res = res.replace(/\\/g, "/");
}
return res;
}
return filePath;
}
async status() { async status() {
this.plugin.setState(1 /* status */); this.plugin.setState(1 /* status */);
const status2 = await this.git.status((err) => this.onError(err)); const status2 = await this.git.status((err) => this.onError(err));
@ -29977,7 +30026,7 @@ var SimpleGit = class extends GitManager {
return result; return result;
} }
async getSubmodulePaths() { async getSubmodulePaths() {
return new Promise(async (resolve) => { return new Promise(async (resolve2) => {
this.git.outputHandler(async (cmd, stdout, stderr, args) => { this.git.outputHandler(async (cmd, stdout, stderr, args) => {
if (!(args.contains("submodule") && args.contains("foreach"))) { if (!(args.contains("submodule") && args.contains("foreach"))) {
return; return;
@ -29996,7 +30045,7 @@ var SimpleGit = class extends GitManager {
} }
}).filter((i) => !!i); }).filter((i) => !!i);
strippedSubmods.reverse(); strippedSubmods.reverse();
resolve(strippedSubmods); resolve2(strippedSubmods);
}); });
}); });
await this.git.subModule(["foreach", "--recursive", ""]); await this.git.subModule(["foreach", "--recursive", ""]);
@ -30472,10 +30521,10 @@ var SimpleGit = class extends GitManager {
} }
} }
} }
updateGitPath(gitPath) { updateGitPath(_) {
this.setGitInstance(); this.setGitInstance();
} }
updateBasePath(basePath) { updateBasePath(_) {
this.setGitInstance(true); this.setGitInstance(true);
} }
async getDiffString(filePath, stagedChanges = false, hash2) { async getDiffString(filePath, stagedChanges = false, hash2) {
@ -31282,8 +31331,8 @@ var GeneralModal = class extends import_obsidian5.SuggestModal {
this.inputEl.value = this.config.initialValue; this.inputEl.value = this.config.initialValue;
this.inputEl.dispatchEvent(new Event("input")); this.inputEl.dispatchEvent(new Event("input"));
} }
return new Promise((resolve) => { return new Promise((resolve2) => {
this.resolve = resolve; this.resolve = resolve2;
}); });
} }
selectSuggestion(value, evt) { selectSuggestion(value, evt) {
@ -34575,8 +34624,8 @@ var CustomMessageModal = class extends import_obsidian15.SuggestModal {
} }
open() { open() {
super.open(); super.open();
return new Promise((resolve) => { return new Promise((resolve2) => {
this.resolve = resolve; this.resolve = resolve2;
}); });
} }
onClose() { onClose() {
@ -37709,11 +37758,11 @@ if (typeof window !== "undefined")
init_polyfill_buffer(); init_polyfill_buffer();
function __awaiter(thisArg, _arguments, P, generator) { function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { function adopt(value) {
return value instanceof P ? value : new P(function(resolve) { return value instanceof P ? value : new P(function(resolve2) {
resolve(value); resolve2(value);
}); });
} }
return new (P || (P = Promise))(function(resolve, reject) { return new (P || (P = Promise))(function(resolve2, reject) {
function fulfilled(value) { function fulfilled(value) {
try { try {
step(generator.next(value)); step(generator.next(value));
@ -37729,7 +37778,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
} }
} }
function step(result) { function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
} }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
@ -39780,12 +39829,12 @@ var BranchModal = class extends import_obsidian22.FuzzySuggestModal {
} }
open() { open() {
super.open(); super.open();
return new Promise((resolve) => { return new Promise((resolve2) => {
this.resolve = resolve; this.resolve = resolve2;
}); });
} }
async onClose() { async onClose() {
await new Promise((resolve) => setTimeout(resolve, 10)); await new Promise((resolve2) => setTimeout(resolve2, 10));
if (this.resolve) if (this.resolve)
this.resolve(void 0); this.resolve(void 0);
} }
@ -39802,8 +39851,8 @@ var IgnoreModal = class extends import_obsidian23.Modal {
} }
open() { open() {
super.open(); super.open();
return new Promise((resolve) => { return new Promise((resolve2) => {
this.resolve = resolve; this.resolve = resolve2;
}); });
} }
onOpen() { onOpen() {
@ -39850,8 +39899,8 @@ var DiscardModal = class extends import_obsidian24.Modal {
} }
myOpen() { myOpen() {
this.open(); this.open();
return new Promise((resolve) => { return new Promise((resolve2) => {
this.resolve = resolve; this.resolve = resolve2;
}); });
} }
onOpen() { onOpen() {

View File

@ -5,5 +5,5 @@
"isDesktopOnly": false, "isDesktopOnly": false,
"fundingUrl": "https://ko-fi.com/vinzent", "fundingUrl": "https://ko-fi.com/vinzent",
"js": "main.js", "js": "main.js",
"version": "2.24.2" "version": "2.24.3"
} }

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"id": "obsidian-linter", "id": "obsidian-linter",
"name": "Linter", "name": "Linter",
"version": "1.24.0", "version": "1.25.0",
"minAppVersion": "1.4.16", "minAppVersion": "1.4.16",
"description": "Formats and styles your notes. It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.", "description": "Formats and styles your notes. It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.",
"author": "Victor Tao", "author": "Victor Tao",

View File

@ -210,6 +210,25 @@ textarea.full-width {
width: 50%; width: 50%;
} }
/**
* Files to ignore
*/
.linter-files-to-ignore-container div:last-child {
border: none;
}
.linter-files-to-ignore {
margin-bottom: 15px;
border: none;
border-bottom: var(--hr-thickness) solid;
border-color: var(--hr-color);
}
.linter-files-to-ignore-normal-input {
width: 40%;
}
.linter-files-to-ignore-flags {
width: 15%;
}
/** /**
* Setting item no border * Setting item no border
*/ */

View File

@ -5,7 +5,7 @@
"darkScheme": "minimal-default-dark", "darkScheme": "minimal-default-dark",
"editorFont": "", "editorFont": "",
"lineHeight": 1.6, "lineHeight": 1.6,
"lineWidth": 40, "lineWidth": 70,
"lineWidthWide": 50, "lineWidthWide": 50,
"maxWidth": 88, "maxWidth": 88,
"textNormal": 18, "textNormal": 18,